var bNetscape4plus = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4");
var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");

function CheckUIElements()
{
        var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

        if ( bNetscape4plus ) { // ³×Ã÷ÄÉÀÌÇÁ ¿ë ¼³Á¤
                //yButtonFrom = document["divLinkButton"].top;
                //yButtonTo   = top.pageYOffset + top.innerHeight - 55;
                yMenuFrom   = document["divMenu"].top;
                yMenuTo     = top.pageYOffset + 122;   // À§ÂÊ À§Ä¡
        }
        else if ( bExplorer4plus ) {  // IE ¿ë ¼³Á¤
                //yButtonFrom = parseInt (divLinkButton.style.top, 10);
                //yButtonTo   = document.body.scrollTop + document.body.clientHeight - 55;
                yMenuFrom   = parseInt (divMenu.style.top, 10);
                yMenuTo     = document.body.scrollTop + 320; // À§ÂÊ À§Ä¡
        }

        timeoutNextCheck = 500;

        if ( Math.abs (yButtonFrom - (yMenuTo + 252)) < 6 && yButtonTo < yButtonFrom ) {
                setTimeout ("CheckUIElements()", timeoutNextCheck);
                return;
        }


        if ( yButtonFrom != yButtonTo ) {
                yOffset = Math.ceil( Math.abs( yButtonTo - yButtonFrom ) / 10 );
                if ( yButtonTo < yButtonFrom )
                        yOffset = -yOffset;

                if ( bNetscape4plus )
                        document["divLinkButton"].top += yOffset;
                else 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 ( bNetscape4plus )
                        document["divMenu"].top += yOffset;
                else if ( bExplorer4plus )
                        divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;

                timeoutNextCheck = 10;
        }

        setTimeout ("CheckUIElements()", timeoutNextCheck);
}


function OnLoad_scroll()
{
        var y;
		var ww = ""; //width
		var ew = ""; //extra width
		var posX = "";
	
		

		ww = document.body.scrollWidth;
		ew = ww - 779;
		if(ww < 779)
			ww = 779;


        // ÇÁ·¹ÀÓ ¿¡¼­ ¹þ¾î³ª°Ô ÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù. ÇÁ·¹ÀÓ¿¡ ³ÖÀ¸·Á¸é »èÁ¦ÇÏ¼¼¿ä
        if ( top.frames.length )
         //       top.location.href = self.location.href;

        // ÆäÀÌÁö ·Îµù½Ã Æ÷Áö¼Ç
        if ( bNetscape4plus ) {
                document.getElementById('divMenu').style.top = top.pageYOffset + 235;
                document.getElementById('divMenu1').style.top = top.pageYOffset + 235;
                document.getElementById('divMenu').style.left = 779 + (ew/2) + 20;
                document.getElementById('divMenu1').style.left = 779 + (ew/2) + 20;
                document.getElementById('divMenu').style.visibility = "visible";
                document.getElementById('divMenu1').style.visibility = "visible";

				
                //document["divMenu"].top = top.pageYOffset + 135;
                //document["divMenu"].left = 779 + (ew/2) + 20;
                //document["divMenu1"].left = 779 + (ew/2) + 20;
                //document["divMenu"].visibility = "visible";

                //document["divLinkButton"].top = top.pageYOffset + top.innerHeight - 55;
                //document["divLinkButton"].visibility = "visible";
        }
        else if ( bExplorer4plus ) {
                divMenu.style.top = document.body.scrollTop + 135;
                divMenu1.style.top = document.body.scrollTop + 135;
                divMenu.style.left = 779 + (ew/2) + 20;
                divMenu1.style.left = 779 + (ew/2) + 20;
                divMenu.style.visibility = "visible";
                divMenu1.style.visibility = "visible";
                //divLinkButton.style.top = document.body.scrollTop + document.body.clientHeight - 55;
                //divLinkButton.style.visibility = "visible";
        }

        // initializing UI update timer
        CheckUIElements();
        //if ( bExplorer4plus )
        //        setTimeout ( "FlashTitleStepIt(255)", 10 );
        return true;
}

function funcSwapImage(imageName, bHilite) {
// DUMB Netscape doesn't see img names if they're inside a <div which has an id
// if they're just in <div></div> - it's okay, but that's not the case :\
// Workaround (using layers) was provided by Kostya. Tnx man :)
        if ( bExplorer4plus ) {
                document.images[imageName].src = "images/" + imageName + (bHilite == 1 ? "_hi.gif" : "_lo.gif");
        }
        else if ( bNetscape4plus ) {
                document.layers["divMenu"].document.images[imageName].src = "images/" + imageName + (bHilite == 1 ? "_hi.gif" : "_lo.gif");
        }
        return false;
}

//quick menu
function clearAll3(){
	for(i = 1; i < 5; i++){
		document.getElementById("main_0"+i).style.display='block';
		document.getElementById("sub_0"+i).style.display='none';
	}
}

function showSub(mainMenu, subMenu){
clearAll3();
	document.getElementById(mainMenu).style.display='none';
	document.getElementById(subMenu).style.display='block';
}
function hideSub(mainMenu, subMenu){
clearAll3();
	document.getElementById(mainMenu).style.display='block';
	document.getElementById(subMenu).style.display='none';
}


//category
function clearAll2(){
	for(i = 1; i < 10; i++){
		document.getElementById("div"+i+"on").style.display='none';
		document.getElementById("div"+i+"off").style.display='block';
	}
}

function showSub2 (onMenu, offMenu){
	clearAll2();
	document.getElementById(onMenu).style.display='block';
	document.getElementById(offMenu).style.display='none';
}
