var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");

function CheckUIElements()
{
        var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

        if ( bExplorer4plus ) {  // IE 용 설정
                //yButtonFrom = parseInt (divLinkButton.style.top, 10);
                //yButtonTo   = document.body.scrollTop + document.body.clientHeight - 55;
                if (document.compatMode && document.compatMode != 'BackCompat') 
                {
                    bodyscrollTop = document.documentElement.scrollTop;
                }
                else 
                {
                    bodyscrollTop = document.body.scrollTop;
                }

                yMenuFrom   = parseInt (_E('idBtnGoTop').style.top, 10);
                yMenuTo     = bodyscrollTop + 149; // 위쪽 위치 91
                //yMenuTo     = bodyscrollTop + document.body.clientHeight - 200;

        }

        timeoutNextCheck = 100;

        if ( Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom ) {
                setTimeout ("CheckUIElements()", timeoutNextCheck);
                return;
        }


        if ( yButtonFrom != yButtonTo ) {
                yOffset = Math.ceil( Math.abs( yButtonTo - yButtonFrom ) / 10 );
                if ( yButtonTo < yButtonFrom )
                        yOffset = -yOffset;

                if ( bExplorer4plus )
                        divLinkButton.style.top = parseInt (divLinkButton.style.top, 10) + yOffset;

                timeoutNextCheck = 10;
        }
        if ( yMenuFrom != yMenuTo ) {
                yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 20 );
                if ( yMenuTo < yMenuFrom )
                        yOffset = -yOffset;

                if ( bExplorer4plus )
                        _E('idBtnGoTop').style.top = parseInt (_E('idBtnGoTop').style.top, 10) + yOffset;

                timeoutNextCheck = 10;
        }

        setTimeout ("CheckUIElements()", timeoutNextCheck);
}

function Slide()
{
        var y;

        // 페이지 로딩시 포지션
        if ( bExplorer4plus ) {
                _E('idBtnGoTop').style.top = document.body.scrollTop + 250;
                //_E('idBtnGoTop').style.top = document.body.scrollTop + document.body.clientHeight - 200;
                _E('idBtnGoTop').style.visibility = "visible";
        }

        CheckUIElements();
        
        return true;
}

function slide_close()
{
	setCookie( "r_quick_menu", "done" , 1, "/");
	
	if ( bExplorer4plus ) {
		_E('idBtnGoTop').style.visibility = "hidden";
	}
}

//Get Cookie Function
function getCookie(name) {
    var cname = name + "=";
    var dc = document.cookie;
    if (dc.length > 0) {
        begin = dc.indexOf(cname);
        if (begin != -1) {
            begin += cname.length;
            end = dc.indexOf(";", begin);
            if (end == -1) end = dc.length;
            return unescape(dc.substring(begin, end));
        }
    }
    return null;
}

//Set Cookie Function
function setCookie(name, value, expiredays, path, domain, secure) {
    var toDate = new Date();
    toDate.setHours(23);
    toDate.setMinutes(59);
    toDate.setSeconds(59);
    toDate.setDate(toDate.getDate() + expiredays);
    document.cookie = name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + toDate.toGMTString()) + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + ((secure == null) ? "" : "; secure");
}


document.writeln("<div id='idBtnGoTop' style='position:absolute;left:expression( document.body.clientWidth - 131);z-index:1; width: 22; height: 32;'><table width='131' border='0' cellspacing='0' cellpadding='0'>");
document.writeln("<tr>");
document.writeln("<td height='25' align='right'><a href='javascript:slide_close();'><img src='" + _IMG_BASE_URL_ + "/common/quick_btn_close.gif' hspace='5' /></a></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td height='16'><img src='" + _IMG_BASE_URL_ + "/common/quick_top.gif' width='131' height='16' /></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td align='center' background='" + _IMG_BASE_URL_ + "/common/quick_bg.gif'><table width='101' border='0' cellspacing='0' cellpadding='0'>");
document.writeln("<tr>");
document.writeln("<td  align='center' bgcolor='#EEEAE8' style='padding:4px'><img src='" + _IMG_BASE_URL_ + "/common/quick_bbi.jpg' width='93' /></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td background=''><a href='/customer/catalog?q_id_board=index'><img src='" + _IMG_BASE_URL_ + "/common/quick_c_list.gif' width='101' border='0' /></a></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td background=''><a href='/doevent/catalog?q_id_board=ev_2:open'><img src='" + _IMG_BASE_URL_ + "/common/quick_c_event.gif' width='101' border='0' /></a></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td height='19' background=''><a href='/customer/catalog?q_id_board=reader'><img src='" + _IMG_BASE_URL_ + "/common/quick_c_bbs.gif' width='101' border='0' /></a></td>");
document.writeln("</tr>");
document.writeln("</table></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td><img src='" + _IMG_BASE_URL_ + "/common/quick_link.gif' width='131' height='74' /></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td align='center' valign='top' background='" + _IMG_BASE_URL_ + "/common/quick_bg2.gif'><table width='107' border='0' cellspacing='0' cellpadding='0'>");
document.writeln("<tr>");
document.writeln("<td width='52' height='69' align='center' valign='middle' bgcolor='#B8ACA6'><a href='http://www.mlounge.co.kr/woman/' target='_blank'><img src='" + _IMG_BASE_URL_ + "/common/quick_womi.jpg' width='50' height='67' /></a></td>");
document.writeln("<td width='3'>&nbsp;</td>");
document.writeln("<td width='52' align='center' valign='middle' bgcolor='#B8ACA6'><a href='http://www.mlounge.co.kr/living/' target='_blank'><img src='" + _IMG_BASE_URL_ + "/common/quick_livingi.jpg' width='50' height='67' /></a></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td valign='top'><img src='" + _IMG_BASE_URL_ + "/common/quick_wom.gif' /></td>");
document.writeln("<td>&nbsp;</td>");
document.writeln("<td valign='top'><img src='" + _IMG_BASE_URL_ + "/common/quick_living.gif' /></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td height='69' align='center' valign='middle' bgcolor='#B8ACA6'><a href='http://www.mlounge.co.kr/essen/' target='_blank'><img src='" + _IMG_BASE_URL_ + "/common/quick_esi.jpg' width='50' height='67' /></a></td>");
document.writeln("<td>&nbsp;</td>");
document.writeln("<td align='center' valign='middle' bgcolor='#B8ACA6'><a href='http://www.ismg.co.kr/magazine/contents_table.php?srh[magazine]=9' target='_blank'><img src='" + _IMG_BASE_URL_ + "/common/quick_arei.jpg' width='50' height='67' /></a></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td height='20' valign='top'><img src='" + _IMG_BASE_URL_ + "/common/quick_es.gif' /></td>");
document.writeln("<td>&nbsp;</td>");
document.writeln("<td valign='top'><img src='" + _IMG_BASE_URL_ + "/common/quick_are.gif' /></td>");
document.writeln("</tr>");
document.writeln("</table></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td height='6' align='center' background='" + _IMG_BASE_URL_ + "/common/quick_bg2.gif'></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td><img src='" + _IMG_BASE_URL_ + "/common/quick_btn.gif' width='131' height='10' /></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td height='15'></td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td align='center'><a href='#TOP' onfocus='this.blur()'><img src='" + _IMG_BASE_URL_ + "/common/quick_ic_top.gif' width='35' height='15' /></a></td>");
document.writeln("</tr>");
document.writeln("</table></div>");
Slide();

if( getCookie("r_quick_menu") == "done" ) {
	if ( bExplorer4plus ) {
		_E('idBtnGoTop').style.visibility = "hidden";
	}
}