
/////////////////////////////////////// -------- ¸ÞÀÎ¸Þ´º ¹× Äü¸Þ´º ¸µÅ© ½ºÅ©¸³Æ® ½ÃÀÛ --------- //////////////////

//¼­ºê¸Þ´ºÀÇ 3Â÷ ¸Þ´º º¸ÀÌ±â/¼û±â±â
function ToggleMenu(pObj)
{
	for(i=1;i<=10;i++)
	{
		if(eval("document.all.Menu" + i) != null)
		{
			mObj = eval("document.all.Menu" + i);
			mObj.style.visibility = "hidden";
			mObj.style.display = "none";				
		}
	}
	pObj.style.visibility = "visible";
	pObj.style.display = "inline";	
}

//¸Þ´º ÇÃ·¡½Ã¿ë
function RunMenu(pMain,pSub)
{
	switch(pMain)
	{
		case 0:
			//ÁÖ¿ä»ç¾÷
			if(pSub == 0)
			{
				document.location = "/camtic/business/index.aspx";
			}
			if(pSub == 1)
			{
				document.location = "/camtic/business/commercial/index.aspx";
			}
			if(pSub == 2)
			{
				document.location = "/camtic/business/research/index.aspx";				
			}
			if(pSub == 3)
			{
				document.location = "/camtic/business/education/index.aspx";				
			}
			if(pSub == 4)
			{
				document.location = "/camtic/business/information/index.aspx";				
			}
			if(pSub == 5)
			{
				document.location = "/camtic/business/foundation/index.aspx";				
			}
			break;
		case 1:
			//±â¼ú±³·ù
			if(pSub == 0)
			{
				document.location = "/camtic/interchange/index.aspx";
			}
			if(pSub == 1)
			{
				document.location = "/camtic/interchange/printer/index.aspx";
			}			
			if(pSub == 2)
			{
				document.location = "/camtic/interchange/machine/index.aspx";
			}
			if(pSub == 3)
			{
				document.location = "/camtic/interchange/carmold/index.aspx";
			}
			if(pSub == 4)
			{
				document.location = "/camtic/interchange/carmachine/index.aspx";
			}
			if(pSub == 5)
			{
				document.location = "/camtic/interchange/led/index.aspx";
			}
			if(pSub == 6)
			{
				document.location = "/camtic/interchange/defense/index.aspx";
			}			
			break;			
		case 2:
			//º¥Ã³´ÜÁö
			if(pSub == 0 || pSub == 1)
			{
				document.location = "/camtic/venture/housing/index.aspx";
			}
			if(pSub == 2)
			{
				document.location = "/camtic/venture/enterprise/index.aspx";				
			}
			if(pSub == 3)
			{
				document.location = "/camtic/venture/movein/index.aspx";				
			}			
			break;
		case 3:
			//Á¤º¸±¤Àå
			if(pSub == 0 || pSub == 1)
			{
				document.location = "/camtic/information/notice/camtic/index.aspx";
			}
			if(pSub == 2)
			{
				document.location = "/camtic/information/trend/list.aspx?CID=004";
			}
			if(pSub == 3)
			{
				document.location = "/camtic/information/goodthink/list.aspx";				
			}
			if(pSub == 4)
			{
				document.location = "/camtic/information/qna/index.aspx";				
			}
			if(pSub == 5)
			{
				document.location = "/camtic/information/free/index.aspx";				
			}
			break;
		case 4:
			//¼¾ÅÍ¼Ò°³
			if(pSub == 0 || pSub == 1)
			{
				document.location = "/camtic/introduce/greeting/index.aspx";
			}
			if(pSub == 2)
			{
				document.location = "/camtic/introduce/business/index.aspx";
			}
			if(pSub == 3)
			{
				document.location = "/camtic/introduce/history/index.aspx";
			}
			if(pSub == 4)
			{
				document.location = "/camtic/introduce/organization/index.aspx";
			}
			if(pSub == 5)
			{
				document.location = "/camtic/introduce/morgue/schedule/index.aspx";
			}
			if(pSub == 6)
			{
				document.location = "/camtic/introduce/morgue/bodo/index.aspx";
			}			
			if(pSub == 7)
			{
				document.location = "/camtic/introduce/invitation/index.aspx";
			}			
			break;
	}
}

//¸ÞÀÎÈ­¸éÀÇ ÇÏ´Ü ¸Þ´º
function Menu(pLink)
{
	QuickMenu(pLink);
}

//Äü¸Þ´º ÇÃ·¡½Ã¿ë
function QuickMenu(pLink)
{
	if(pLink == 0)
	{
		document.location = "/camtic/business/commercial/index.aspx";
	}
	if(pLink == 1)
	{
		document.location = "/camtic/business/research/index.aspx";
	}
	if(pLink == 2)
	{
		document.location = "/camtic/business/education/index.aspx";
	}
	if(pLink == 3)
	{
		document.location = "/camtic/business/information/index.aspx";
	}
	if(pLink == 4)
	{
		document.location = "/camtic/business/foundation/index.aspx";
	}
	if(pLink == 10)
	{
		//document.location = "http://www.camtic.co.kr";
		window.open("http://www.camtic.co.kr");
	}
	if(pLink == 11)
	{
		//document.location = "http://edu.camtic.or.kr";
		window.open("http://edu.camtic.or.kr");
	}
	if(pLink == 12)
	{
		//document.location = "http://www.jhitech.or.kr/";
		window.open("http://www.jhitech.or.kr/");
	}			
}

/////////////////////////////////////// -------- ¸ÞÀÎ¸Þ´º ¹× Äü¸Þ´º ¸µÅ© ½ºÅ©¸³Æ® ¿Ï·á --------- //////////////////


/////////////////////////////////////// -------- ¿ÞÂÊ ¼­ºê¸Þ´º¿ë ½ºÅ©¸³Æ® ½ÃÀÛ --------- //////////////////

// ¸Þ´º¸¦ ¸¸µç´Ù.
function MFXinitMenu()
{
	IE = document.all ? 1:0;
	NN = document.layers ? 1:0;
	HIDDEN = (NN) ? 'hide' : 'hidden';
	VISIBLE = (NN) ? 'show' : 'visible';
	myLayer=new Array();
	mySpeed=5;
	subLeft=0;
	closes=true;
	
	totalMainHeight = 0;
	maxSubHeight = 0;

	initNum = 100;
	// ÃÑ ·¹ÀÌ¾î ¸ñ·Ï
	for(i=0; i <= initNum ; i++)
	{
		if(NN)	
		{
			myLayer[i] = document.MFX+i;
			
		}
		else
		{	
			obj = MM_findObj("MFX"+i)
			if(obj == null)
			{
				//ÀÚµ¿À¸·Î ·¹ÀÌ¾î °¹¼ö¸¦ ÆÄ¾ÇÇÏ±â À§ÇÔ.
				initNum = i;
				break;
			}
			myLayer[i] = obj.style ;
		}	
	}

	running=false;
	whichOpen=-1;
	lastMain=myLayer.length-2;
	MFXmain=new Array();

	for(i=0; i<myLayer.length; i++)
	{
		mainORsub= i % 2;
		MFXmain[i] = mainORsub ? 0:1;
	}
	
	myTop=new Array();
	myLeft=new Array();
	myHeight=new Array();
	myWidth=new Array();
	mySlide=new Array();
	
	for(i=0; i<myLayer.length; i++)
	{
		if(NN&&MFXmain[i])
		{
			if(i==0)
			{
				myTop[i]=myLayer[i].top;
				myLeft[i]=myLayer[i].left;
			}
			else
			{
				myLeft[i]=myLeft[i-2];
				myTop[i]=myTop[i-2]+myHeight[i-2];
			}
			myHeight[i]=myLayer[i].clip.height;
			myWidth[i]=myLayer[i].clip.width;
			myLayer[i].left=myLeft[i];
			myLayer[i].top=myTop[i];
			myLayer[i].visibility=VISIBLE;
			
			totalMainHeight += myHeight[i];
		}
		if(NN&&!MFXmain[i])
		{
			myTop[i]=myTop[i-1]+myHeight[i-1];
			myLeft[i]=myLeft[i-1]+10;
			myHeight[i]=myLayer[i].clip.height;
			myWidth[i]=myLayer[i].clip.width;
			mySlide[i]=myTop[i]+myHeight[i];
			myLayer[i].left=myLeft[i]+subLeft;
			myLayer[i].top=myTop[i];
			myLayer[i].visibility=Hidden;
			
			if (maxSubHeight < myHeight[i])
				maxSubHeight = myHeight[i];
		}
		if(IE&&MFXmain[i])
		{
			if(i==0)
			{
				myLeft[i]=myLayer[i].pixelLeft;
				myTop[i]=myLayer[i].pixelTop;
			}
			else
			{
				myLeft[i]=myLeft[i-2];
				myTop[i]=myTop[i-2]+myHeight[i-2];
			}
			myHeight[i]=myLayer[i].pixelHeight;
			myWidth[i]=myLayer[i].pixelWidth;
			myLayer[i].left=myLeft[i];
			myLayer[i].top=myTop[i];
			myLayer[i].visibility=VISIBLE;
			
			totalMainHeight += myHeight[i];
		}
		if(IE&&!MFXmain[i])
		{
			myTop[i]=myTop[i-1]+myHeight[i-1];
			myLeft[i]=myLeft[i-1]+10;
			myHeight[i]=myLayer[i].pixelHeight;
			myWidth[i]=myLayer[i].pixelWidth;
			myLayer[i].pixelLeft=myLeft[i]+subLeft;
			myLayer[i].pixelTop=myTop[i];
			mySlide[i]=myTop[i]+myHeight[i];
			myLayer[i].visibility=HIDDEN;
			
			if (maxSubHeight < myHeight[i])
				maxSubHeight = myHeight[i];
		}
	}

	ResizeTableHeight(totalMainHeight, maxSubHeight);
}

function ResizeTableHeight(mainHeight, subHeight)
{
	menutable.height = mainHeight + subHeight;
}

function MFXrunMenu(myName,newspeed)
{
	ieStep=0;
	thereS=false;
	thereC=false;
	
	if (newspeed>0)
	{
		mySpeed=newspeed;
	}
	
	first=myName;
	
	if (whichOpen==-1&&!running&&MFXmain[myName]&&!(whichOpen==myName))
	{
		running=true;
		if(NN)
		{
			myLayer[myName+1].clip.height=0;
			myLayer[myName+1].visibility=VISIBLE;
		}
		if(IE)
		{
			myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (0) +" "+ ("auto") +")";
			myLayer[myName+1].visibility=VISIBLE;
		}
		MFXopenMenuS(myName);
		MFXopenMenuC(myName);
	}
	
	if(whichOpen>=0&&!running&&!(whichOpen==myName))
	{
		running=true;
		second=whichOpen;
		ieStep1=myHeight[second+1];
		thereCS=false;
		thereCC=false;
		MFXcloseMenuS(second);
		MFXcloseMenuC(second);
	}
	
	if(whichOpen>=0&&!running&&whichOpen==myName&&closes)
	{
		running=true;
		second=whichOpen;
		ieStep1=myHeight[second+1];
		thereCS=false;
		thereCC=false;
		MFXcloseMenuS(second);
		MFXcloseMenuC(second);
	}
}

function MFXstopCloseS(myName)
{
	running=false;
	thereCS=true;
	
	if(closes&&first==whichOpen)
	{
		whichOpen=-1;
	}
	else
	{
		whichOpen=-1;
		MFXrunMenu(first);
	}
}

function MFXstopOpenS(myName)
{
	running=false;
	thereS=true;
	
	if (IE)
	{
		myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ ("auto") +" "+ ("auto") +")";
	}
	whichOpen=myName;
}

function MFXopenMenuS(myName)
{
	myStep=mySpeed;
	
	if (NN && !thereS && !(first==lastMain))
	{
		if(myLayer[first+2].top+myStep > mySlide[first+1])
		{
			myStep=mySlide[first+1]-myLayer[first+2].top;
		}
		for(i=first+2; i<myLayer.length; i+=2)
		{
			myLayer[i].top+=myStep;
		}
		if(myLayer[first+2].top==mySlide[first+1])
		{
			MFXstopOpenS(first)
		}
		if(running)
			setTimeout('MFXopenMenuS(first)',10);
	}
	
	if(IE&&!thereS&&!(first==lastMain))
	{
		if(myLayer[first+2].pixelTop+myStep>mySlide[first+1])
		{
			myStep=mySlide[first+1]-myLayer[first+2].pixelTop;
		}
		for(i=first+2; i<myLayer.length; i+=2)
		{
			myLayer[i].pixelTop+=myStep;
		}
		if(myLayer[first+2].pixelTop==mySlide[first+1])
		{
			MFXstopOpenS(first)
		}
		if(running)
			setTimeout('MFXopenMenuS(first)',10);
	}
}

function MFXopenMenuC(myName)
{
	myStep=mySpeed;
	
	if(NN&&!thereC)
	{
		if ((myLayer[first+1].clip.height+myStep)>myHeight[first+1])
		{
			myLayer[first+1].clip.height=myHeight[first+1]
		}
		if(myLayer[first+1].clip.height==myHeight[first+1])
		{
		thereC=true;
		whichOpen=first;
		MFXstopOpenS(first)
		}
		else
		{
			myLayer[first+1].clip.height+=myStep;
		}
		if(running)
			setTimeout('MFXopenMenuC(first)',10);
	}
	
	if(IE&&!thereC)
	{
		ieStep+=myStep;
		myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (ieStep) +" "+ ("auto") +")";
		
		if(ieStep>=myHeight[first+1])
		{
			thereC=true;
			whichOpen=first;
			MFXstopOpenS(first)
		}
		if(running)
			setTimeout('MFXopenMenuC(first)',10);
	}
}

function MFXcloseMenuS(myName)
{
	myStep=mySpeed;
	
	if(NN&&!thereCS&&!(second==lastMain))
	{
		if(myLayer[second+2].top-myStep<myTop[second+2])
		{
			myStep=myLayer[second+2].top-myTop[second+2];
		}
		for(i=second+2; i<myLayer.length; i+=2)
		{
			myLayer[i].top-=myStep;
		}
		if(myLayer[second+2].top==myTop[second+2])
		{
			MFXstopCloseS(second);
		}
		if(running)
			setTimeout('MFXcloseMenuS(second)',10);
	}
	
	if(IE&&!thereCS&&!(second==lastMain))
	{
		if(myLayer[second+2].pixelTop-myStep<myTop[second+2])
		{
			myStep=myLayer[second+2].pixelTop-myTop[second+2];
		}
		for(i=second+2; i<myLayer.length; i+=2)
		{
			myLayer[i].pixelTop-=myStep;
		}
		if(myLayer[second+2].pixelTop==myTop[second+2])
		{
			MFXstopCloseS(second);
		}
		if(running)
			setTimeout('MFXcloseMenuS(second)',10);
	}
}

function MFXcloseMenuC(myName)
{
	myStep=-mySpeed;
	ieStep1-=mySpeed;
	
	if(NN&&!thereCC)
	{
		if ((myLayer[second+1].clip.bottom+myStep)<0)
		{
			myLayer[second+1].clip.bottom=0;
		}
		if(myLayer[second+1].clip.bottom==0)
		{
			thereCC=true;
			if(second==lastMain)
				MFXstopCloseS(second);
		}
		else
		{
			myLayer[second+1].clip.bottom+=myStep;
		}
		if(running)
			setTimeout('MFXcloseMenuC(second)',10);
	}
	
	if(IE&&!thereCC)
	{
		if(ieStep1<=0)
		{
			myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (0) +" "+ ("auto") +")";
			thereCC=true;
			if(second==lastMain)
				MFXstopCloseS(second);
		}
		else
		{
			myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (ieStep1) +" "+ ("auto") +")";
		}
		if(running)
			setTimeout('MFXcloseMenuC(second)',10);
	}
}

/////////////////////////////////////// -------- ¿ÞÂÊ ¼­ºê¸Þ´º¿ë ½ºÅ©¸³Æ® ¿Ï·á --------- //////////////////


/////////////////////////////////////// -------- Äü¸Þ´º¿ë ½ºÅ©¸³Æ® ½ÃÀÛ --------- //////////////////

var bNetscape4plus = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4");
var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");
var y_type;

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 + y_location;   // À§ÂÊ À§Ä¡
        }
        else if ( bExplorer4plus ) {  // IE ¿ë ¼³Á¤
                //yButtonFrom = parseInt (divLinkButton.style.top, 10);
                //yButtonTo   = document.body.scrollTop + document.body.clientHeight - 55;

                yMenuFrom   = parseInt (divMenu.style.top, 10);

               if(y_type == 'sub')
               {
           yMenuTo     = document.body.scrollTop + 105; // À§ÂÊ À§Ä¡
                }
                else
                {
                   yMenuTo     = document.body.scrollTop + 105; // À§ÂÊ À§Ä¡
                }

        }

        timeoutNextCheck = 500;

        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 ( 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 QuickLoad(type)
{

    y_type = type;

        // ÇÁ·¹ÀÓ ¿¡¼­ ¹þ¾î³ª°Ô ÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù. ÇÁ·¹ÀÓ¿¡ ³ÖÀ¸·Á¸é »èÁ¦ÇÏ¼¼¿ä
        //if ( top.frames.length )
         //       top.location.href = self.location.href;

        // Æä¿¡Áö ·Îµù½Ã Æ÷Áö¼Ç
        if ( bNetscape4plus ) {
                document["divMenu"].top = top.pageYOffset + 300;
                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 +300;
                divMenu.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 = "/muju/UIControl/images/" + imageName + (bHilite == 1 ? "_hi.gif" : "_lo.gif");
        }
        else if ( bNetscape4plus ) {
                document.layers["divMenu"].document.images[imageName].src = "/muju/UIControl/images/" + imageName + (bHilite == 1 ? "_hi.gif" : "_lo.gif");
        }
        return false;
}

function JS_viewObj(objhtml) {
	document.write(objhtml);
}

/////////////////////////////////////// -------- Äü¸Þ´º¿ë ½ºÅ©¸³Æ® ¿Ï·á --------- //////////////////

