//************************	º¼º¸ °øÅëÇÔ¼ö ****************************************/
//Last update : 2003.12.18 by ÃÖ¿µ½Å
//Revision
//	No.	:		ÇÔ¼ö				:				¿ëµµ				:	¼öÁ¤³¯Â¥
//	1.		popUpWin       			ÆË¾÷À©µµ¿ì ¿ÀÇÂ					2003/11/20
//	2.		display					¸Þ´º °¨Ãß±â						2003/11/20
//	3.		openURL					Å¸°ÙÁöÁ¤ ÆäÀÌÁö ¿ÀÇÂ				2003/11/20
//	4.		rollOver				ÀÌ¹ÌÁö ·Ñ¿À¹ö					2003/11/20
//	5.		rollOut					ÀÌ¹ÌÁö ·Ñ¾Æ¿ô					2003/11/20
//	6.		setMenu					Å¬¸¯½Ã ¸Þ´º¹øÈ£ ¼¼ÆÃ				2003/12/10
//	6-1.	checkLMenuCode			¿ÞÂÊ ´ë¸Þ´º ¹øÈ£ ¸®ÅÏ				2003/12/10
//	7.		initLMenu				ÆäÀÌÁö·Îµå½Ã ¸Þ´º ¼¼ÆÃ			2003/12/10
//	8.		setCookie				ÄíÅ°¼³Á¤							2003/12/10
//	9.		getCookieValue			ÄíÅ°ÀÐ±â							2003/12/10
//	10.		anew2Wins				2wins Ã¢¿­±â ¿­±â Å¬·¡½º	 		2003.12.18
//	11.		remoteSizeControl		¸®¸ðÆ®Ã¢ Å©±â Á¶Àý ÇÔ¼ö			2003.12.19


	//1.
	function popUpWin(popURL, popName, popTop, popLeft, popWidth, popHeight, scrl)
	{
		popWinAttr = 'top='+ popTop + ',left=' + popLeft + ',width='+ popWidth +',height=' + popHeight ;
		if (scrl=='scroll' )
		{
			popWinAttr = popWinAttr+ ',scrollbars, resizable'
		}
		
		//popWinAttr = '"' + popWinAttr  + '"'
		
		popWin = window.open(popURL, popName, popWinAttr);
		popWin.focus();
	}
	
	//2.
	function display(layerID)
	{
		displayLayer = document.getElementById(layerID)
		
		if (displayLayer.style.display=='none')
		{
			displayLayer.style.display='block';
		}
		else
		{
			displayLayer.style.display='none';
		}
	}
	
	//3.
	function openURL(URLstr, targetStr)
	{
		eval(targetStr + ".location.href ='" + URLstr + "'") 
	}  
	
	
	//4.
	function rollOver(imgID)
	{
		

		imgToChange=document.getElementById(imgID)
		overImg = eval(imgID + '_over')

		imgToChange.setAttribute("src",overImg.getAttribute("src"))
		//alert(imgToChange.getAttribute("src"))
	}
	strCurrentImgId="topMenu00"
	//&&(strCurrentImgId!=imgID)
	//5.
	function rollOut(imgID)
	{
		
		//	¼±ÅÃµÈ ¸Þ´º°¡ ´ë¸Þ´º ÀÌ¹ÌÁö ÀÌ¸é ·Ñ¾Æ¿ôÇÏÁö ¾Ê´Â´Ù.
		var mCode = getCookieValue("menuCode");
		mCode = checkLMenuCode(mCode)
		
		if(mCode!=imgID)
		{
			imgToChange=document.getElementById(imgID)
			overImg = eval(imgID + '_out')
			imgToChange.setAttribute("src",overImg.getAttribute("src"))
		}
	}

//***************************** º¼º¸ À¯ÀúÈ¨ÆäÀÌÁö ¿ÞÂÊ ¸Þ´º ¼¼ÆÃ***************************************//

	//6.
	var xIndex=0;
	var yIndex=0;
	
	function setMenu(menuId)
	{

		setCookie("menuCode", menuId,"","")
		var	LmenuCode = checkLMenuCode(menuId)
		//alert(LmenuCode)

		 if(LmenuCode!=null)
		{//1st
				objMenu = document.getElementById(menuId);

				//---ÀÌ¹ÌÁö´Â ¹«Á¶°Ç ´ë¸Þ´º·Î ¼¼ÆÃ
				rollOver(LCode[xIndex][0])
				
				//---¼Ò¸Þ´ºÀÏ °æ¿ì ÆùÆ®¸¦ ±½°Ô ¹Ù²ãÁØ´Ù
				if(yIndex!=0)
				{//2nd
	
					objMenu.style.fontWeight="bold"
					
					//---¸Þ´º ÅØ½ºÆ®°¡ ±æ¶§ º¼µå·Î µÇ¸é ÁÙ¹Ù²ÞÀÌ »ý±ä´Ù. ÀÚ°£ Á¼È÷±â
					if(objMenu.firstChild.length>14)
					{//3rd
						objMenu.style.letterSpacing="-3"
						
					}//3rd
				}//2nd
		}//1st
	}


	//6-1.
	function checkLMenuCode(menuId)
	{
		for(i=0;i<LCode.length;i++)
		{//1st

			for(j=0;j<LCode[i].length;j++)
			{//2nd
				
				if(LCode[i][j]==menuId)
				{//3rd	
					xIndex	=	i;
					yIndex	=	j;
					return LCode[i][0];

				}//3rd
			}//2nd
		}//1st
	
		
	}
	
	
	//7.
	function initLMenu()
	{
		var mCode = getCookieValue("menuCode");
		setMenu(mCode)
	}


	//***************************** ÄíÅ°ÇÔ¼ö Wrox.com ÂüÁ¶***************************************//
	//8.
	function setCookie(cookieName, cookieValue, cookiePath, cookieExpires)
	{
		cookieValue = escape(cookieValue);
		
		if (cookieExpires == "")
		{
			var nowDate = new Date();
			nowDate.setMonth(nowDate.getMonth() + 6);
			cookieExpires = nowDate.toGMTString();
		}
		
		if (cookiePath != "")
		{
			cookiePath = ";Path=" + cookiePath;
		}
		
		document.cookie = cookieName + "=" + cookieValue + 
		";expires=" + cookieExpires + cookiePath;
	}

	//9.
	function getCookieValue(cookieName)
	{
		var cookieValue = document.cookie;
		var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
	
		if (cookieStartsAt == -1)
		{
			cookieStartsAt = cookieValue.indexOf(cookieName + "=");
		}
		
		if (cookieStartsAt == -1)
		{
			cookieValue = null;
		}
		else
		{
			cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
			var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
		
		if (cookieEndsAt == -1)
		{
			cookieEndsAt = cookieValue.length;
		}
			cookieValue = unescape(cookieValue.substring(cookieStartsAt,
			cookieEndsAt));
		}
		
		return cookieValue;
	}


//***************************** ÄíÅ°ÇÔ¼ö ³¡*********************************************//

	//10.
//*****************************	2wins Ã¢¿­±â ¿­±â Å¬·¡½º********************************//

//					»ç¿ë¹ý 
//	var obj2Wins = new anew2Wins();

//	obj2Wins.anewUrl	=	"http://www.2wins.com/"
//	obj2Wins.remoteUrl	=	"#"


//	obj2Wins.open2Wins() : Ã¢ µÎ°³¸¦ ¿¬´Ù
//	obj2Wins.anew 	¼Ó¼º, ¸Þ¼Òµå	:	location.href,  close(), focus(), ... µîµî window¿Í °°À½
//	obj2Wins.remote ¼Ó¼º, ¸Þ¼Òµå	:	location.href,  close(), focus(), ... µîµî window¿Í °°À½




	function anew2Wins()
	{
		//¿À¸¥ÂÊÃ¢ Ã¢ ³ôÀÌ
		this.myh = screen.height-57;
		
		//¿À¸¥ÂÊÃ¢ ¿ÞÂÊ  ÁÂÇ¥
		this.myl = screen.width-302;
		
		//¿À¸¥ÂÊÃ¢ À©µµ¿ì ¼Ó¼º
		this.myhAnew			=	this.myh+29;
		
		this.remoteAttr			=	'scrollbars=auto,width=295'+',height='+this.myh+',resizable=0,top=0,left='+this.myl;

		//¿ÞÂÊÃ¢ À©µµ¿ì ¼Ó¼º
		this.anewAttr			=	'location=1, toolbar=1, directories=0, status=1, menubar=1, resizable=1,scrollbars=1,width='+this.myl+',height='+this.myhAnew+',top=0,left=0'
		
		//2Wins Load
		this.twoWinsLoader		=	"/include/2wins.asp";
		
		//¿ÞÂÊÃ¢ url ÃÊ±â°ª
		this.anewUrl			=	"";
		
		//¿À¸¥ÂÊÃ¢ ³ÐÀÌ
		this.remoteWidth		=	'301'
		
		//¿À¸¥ÂÊÃ¢ url ÃÊ±â°ª
		this.remoteUrl			=	"";
		
		//¿ÞÂÊÃ¢ ¿­±âÇÔ¼ö
		this.openAnew			=	openAnew
		
		//¿À¸¥ÂÊÃ¢ ¿­±âÇÔ¼ö
		this.openRemote			=	openRemote
		
		//2wins ½ÃÀÛ ÇÔ¼ö
		this.open2Wins			=	open2Wins
		
		//¿ÞÂÊÃ¢  url ¹Ù²Ù±â ÇÔ¼ö
		this.setAnewUrl			=	setAnewUrl
		
		//¿À¸¥ÂÊÃ¢ url ¹Ù²Ù±âÇÔ¼ö
		this.setRemoteUrl		=	setRemoteUrl

		//¿À¸¥ÂÊÃ¢ ³ÐÀÌ ¹Ù²Ù±â ÇÔ¼ö
		this.setRemoteWidth		=	setRemoteWidth
		
		//relog ÆäÀÌÁö
		this.relogUrl	=	"/include/isLogin_form.asp"
		
		// ·Î±×ÀÎ ÆäÀÌÁö·Î ÀÌµ¿
		this.setToRelog			=	setToRelog

		//¸®¸ðÆ® ³ÐÀÌ Á¶Àý
		this.remoteControl		=	new remoteSizeControl();

		function openAnew()
		{
			this.anew =	window.open(this.anewUrl, "anew", this.anewAttr)
		}

		function openRemote()
		{
			//alert(this.remoteUrl)
			this.remote = window.open(this.twoWinsLoader+"?url="+this.remoteUrl+"&width="+this.remoteWidth, "Remote", this.remoteAttr)
			this.remote.focus()
		}

		function open2Wins()
		{
			//alert(ordnum)
			this.openAnew()
			this.openRemote()
		}
		
		function setAnewUrl(newUrl)
		{
				this.anewUrl = newUrl
				this.openAnew()
				this.anew.focus()
		}
		
		function setRemoteUrl(newUrl)
		{
				this.remoteUrl = newUrl
				this.openRemote()
				this.remote.focus()
		}
		
		function setRemoteWidth(numWidth)
		{
				//this.remote.top.frames.document.title	=	"@@" + numWidth //¾ÈµÈ´Ù..
				this.remote = window.open(this.twoWinsLoader+"?url="+this.remoteUrl+"&width="+numWidth, "Remote", this.remoteAttr)
		}

		function setToRelog()
		{
			alert('Á¢¼ÓÀÌ ²ö°å½À´Ï´Ù. \n  ·Î±×ÀÎ ÇÏ½Ã±â ¹Ù¶ø´Ï´Ù.');
			
			this.anewUrl	=	this.relogUrl
			
			//·Î±×ÀÎ Ã¢À» ¿¬´Ù.
			this.openAnew()
			this.anew.focus()


			// ¿ÞÂÊÃ¢ÀÌ³ª µ¿¿µ»ó Ã¢¿¡¼­ È£ÃâµÉ¶§
			if(top.self.name != "anew")
			{
				if(top.self.name=="Remote")
				{
					top.self.close()
				}
				else if(top.self.opener.top.name=="Remote")
				{
					//¸®¸ðÆ®Ã¢À» ¸ÕÀú ´Ý´Â´Ù
					top.self.opener.top.close()		
				}
				// ¸®¸ðÆ®Ã¢¿¡¼­ ¿¬ Ã¢À» ´Ý´Â´Ù
				
				top.self.close()
				
			}
					
		}		

}



	//¸®¸ðÆ®Ã¢ »çÀÌÁî ÄÁÆ®·Ñ*****************
	//¸®¸ðÆ® Ã¢¿¡¼­ ·ÎµåÇÔ
	
	//¿Ö anew2Wins¿¡ ºÙ¿©ÁöÁö ¾ÊÀ»±î?....
	//anew2Wins.prototype.remoteSizeControl = function()
	
	function remoteSizeControl()
	{
		this.switchFlag			=	0
		
		//Ã¢Å©±âÁ¶Àý ÀÌ¹ÌÁö ¾ÆÀÌµð(ÀÌ¸§)
		this.ControllerImgId		=		"sizeControllerIcon"
		//this.sizeControllerImg	=	document.getElementById(ControllerImgId)
		
		this.firstSize			=	self.top.frames.document.title
		
		//¿À¸¥ÂÊÃ¢ Å©±â º¹±¸ ÇÔ¼ö
		this.restoreFirstSize	=	restoreFirstSize
		
		//¿À¸¥ÂÊÃ¢ ÁÙÀÌ±â ÇÔ¼ö
		this.minimize			=	minimize
		
		//Ã¢Å©±âÁ¶Àý Å¬¸¯ÇÔ¼ö
		this.switchSize			=	switchSize
		
		this.loadIcon 		= 	loadIcon
		
		//¾ÆÀÌÄÜ ÀÌ¹ÌÁö ·Îµù
		this.minimizeImage			=	document.createElement('img')
		this.restoreSizeImage		=	document.createElement('img')
	
		this.minimizeImageSrc		=	"/content/common/images/size_mini.gif"
		this.restoreSizeImageSrc	=	"/content/common/images/size_back.gif"
		
		function loadIcon()
		{
			this.minimizeImage.setAttribute('src', this.minimizeImageSrc)
			this.restoreSizeImage.setAttribute('src', this.restoreSizeImageSrc)		
		}
		
		//¾ÆÀÌÄÜ ÃÊ±âÈ­
		this.loadIcon()
		
		function restoreFirstSize() {
			self.top.frames.document.title	=	this.firstSize
			document.images[this.ControllerImgId].src	=	this.minimizeImage.getAttribute('src')
		}
		
		function minimize()
		{
			self.top.frames.document.title = '##ÀúÀÛ±Ç,Æ¯ÇãÃâ¿ø(2WinsÃ¢ºÐÇÒ) @@10'
			document.images[this.ControllerImgId].src	=	this.restoreSizeImage.getAttribute('src')
		}
		
		function switchSize()
		{			
			if(this.switchFlag==0)
			{

				this.minimize();
				this.switchFlag	=	1;
			}
			else
			{
				this.restoreFirstSize();
				this.switchFlag	=	0;
			}
		}

	}
	//¸®¸ðÆ®Ã¢ »çÀÌÁî ÄÁÆ®·Ñ ³¡*****************

//**************************** 2wins Å¬·¡½º ³¡*********************************************//
