/*
	Function Name	: getCookie(name)
	Writtern By		: neosky7
	Parameter Info	: name:ÄíÅ°ÀÌ¸§
	Return Info		: true, false
	Description		: ÇØ´çÄíÅ°À¯¹« booleanÀ¸·Î ¸®ÅÏ
*/
function getCookie(name) {
	var Found = false;
	var start, end;
	var i = 0;
	while(i<= document.cookie.length)
	{
		start = i;
		end = start + name.length;
		
		if(document.cookie.substring(start, end) == name)
		{
			Found = true;
			break;
		}
		i++;
	}
	
	if(Found == true) return true;
	else return false;
}

/*
	Function Name	: Win_pop_Banner(newwin,popname,w,h)
	Writtern By		: neosky7
	Parameter Info	: newwin : ¿ÀÇÂÀ©µµ¿ì, popname : ÆË¾÷ÀÌ¸§, w:Ã¢°¡·ÎÅ©±â, h:Ã¢¼¼·ÎÅ©±â
	Return Info		: None
	Description		: ÆË¾÷È£Ãâ ÇÔ¼ö
*/
function Win_pop_Banner(newwin,popname,w,h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'width='+w+',height='+h+',top='+wint+',left='+winl+',resizable=no,scrollbars=no,status=no,menu=no';
	win = window.open(newwin, popname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/*
	Function Name	: mainPop(url,imgsrc,popname,cookiename,w,h)
	Writtern By		: neosky7
	Parameter Info	: url:ÆË¾÷url,imgsrc:ÆË¾÷ÀÌ¹ÌÁö,popname:ÆË¾÷ÀÌ¸§,cookiename:ÄíÅ°ÀÌ¸§,
					  w:Ã¢°¡·ÎÅ©±â, h:Ã¢¼¼·ÎÅ©±â
	Return Info		: None
	Description		: ÄíÅ°Ã¼Å©ÇÏ¿© ¸ÞÀÎÆË¾÷È£Ãâ
*/
function mainPop(url,imgsrc,popname,cookiename,w,h) 
{
	if(!getCookie(cookiename))
	{
		Win_pop_Banner(url+"?ImgUrl="+imgsrc,popname,w,h);
	}
}

/*
	Function Name	: setCookie(name,value,days,domain)
	Writtern By		: neosky7
	Parameter Info	: name:ÄíÅ°ÀÌ¸§,value:ÄíÅ°°ª,days:À¯È¿ÀÏ¼ö,domain:ÄíÅ°µµ¸ÞÀÎ
	Return Info		: none
	Description		: ÄíÅ°¼¼ÆÃ
*/
function setCookie(name,value,days,domain)
{
	var today = new Date();
	today.setDate(today.getDate() + days);
	var cookieString = name + "=" + value + ";path=/;expires=" + today.toGMTString();
	if (domain != null)
		cookieString += ";domain=." + domain;
	document.cookie = cookieString;
}

/*
	Function Name	: setCookieCheck(name,value,days,domain,popname)
	Writtern By		: neosky7
	Parameter Info	: name:ÄíÅ°ÀÌ¸§,value:ÄíÅ°°ª,days:À¯È¿ÀÏ¼ö,domain:ÄíÅ°µµ¸ÞÀÎ,popname:ÆË¾÷ÀÌ¸§
	Return Info		: none
	Description		: ÇØ´çÆË¾÷ÄíÅ°¸¦ ¼¼ÆÃÇÏ°í Ã¢À» ´Ý´Â´Ù.
*/
function setCookieCheck(name,value,days,domain,popname) 
{
	setCookie(name,value,days,domain);
	document.getElementById(popname).style.display = "none";
}

/*
	Function Name	: goUrl(url,popname,target)
	Writtern By		: neosky7
	Parameter Info	: url:ÀÌµ¿ÇÒÁÖ¼Ò
					  popname:ÆË¾÷ÀÌ¸§
					  target:1:ÇöÀçÃ¢, 2:»õÃ¢
	Return Info		: none
	Description		: urlÀÌµ¿ÈÄ ÆË¾÷Ã¢À» ´Ý´Â´Ù.
*/
function goUrl(url,popname,target)
{
	if(target == 1)
	{
		document.location.href=url;
	}
	else if(target == 2)
	{
		window.open(url);
	}
	document.getElementById(popname).style.display = "none";
}

/*
	Function Name	: CloseMainPopup(popname)
	Writtern By		: neosky7
	Parameter Info	: popname:ÆË¾÷ÀÌ¸§
	Return Info		: none
	Description		: ÆË¾÷Ã¢À» ´Ý´Â´Ù.
*/
function CloseMainPopup(popname)
{
	document.getElementById(popname).style.display = "none";
}



/*
	Function Name	: setMainPop()
	Writtern By		: neosky7
	Parameter Info	: popVal1 : Ã¹¹øÂ°ÆË¾÷
					  popImg1 : Ã¹¹øÂ°ÀÌ¹ÌÁö
					  popVal2 : µÎ¹øÂ°ÆË¾÷
					  popImg2 : µÎ¹øÂ°ÀÌ¹ÌÁö
					  domain : µµ¸ÞÀÎ
					  editorsvr : ÀÌ¹ÌÁö¼­¹ö
	Return Info		: none
	Description		: ·¹ÀÌ¾î ÆË¾÷ ¶ç¿ì±â
*/
function setMainPop(popVal1, popImg1, popVal2, popImg2, domain, editorsvr)
{
	var strMainPop = "";
	var popupValue = "";
	var popupImg = "";
	for(i=0; i<2; i++)
	{
		if(i == 0)
		{
			popupValue = popVal1;
			popupImg = popImg1;
		}
		else if(i == 1)
		{
			popupValue = popVal2;
			popupImg = popImg2;
		}
	
		//ÄíÅ°°ªÃ¼Å©
		if(!getCookie(popupValue.split("^")[1]))
		{
			if(popupValue.split("^")[0] == "Y")
			{
				var wint = popupValue.split("^")[3];
				var winl = popupValue.split("^")[4];
				
				if(popupValue.split("^")[7] == "on")
				{
					//TOP È­¸éÁß¾Ó Ã¼Å©
					wint = (screen.height - eval(popupValue.split("^")[6])) / 2;		
				}
				if(popupValue.split("^")[8] == "on")
				{	
					//LEFT È­¸éÁß¾Ó Ã¼Å©
					winl = (screen.width - eval(popupValue.split("^")[5])) / 2;					
				}	
				
				strMainPop += "<div id='MainPop" + i + "' style='display:block;position:absolute;top:" + wint + "px;left:" + winl + "px;width:" + popupValue.split("^")[5] + "px;height:" + popupValue.split("^")[6] + "px;z-index:10'>\n" +
						"<table border='0' cellpadding='0' cellspacing='0' width='100%' height='100%'>\n" +
						"<tr>\n<td height='270'>";
						
				//ÇÃ·¡½Ã±¸ºÐ
				if(popupImg.indexOf(".swf") == -1)
				{
					strMainPop += "<a href=javascript:goUrl('" + popupValue.split("^")[2] + "','MainPop" + i + "'," + popupValue.split("^")[9] + ");><img src='" + editorsvr + "?mnf=2WAR\\Banner\\" + popupImg + "' border='0'></a>";	
				}
				else
				{							
					strMainPop += "<Script Language='JavaScript' type='text/javascript'>\n" +
						"ObjFlash('" + editorsvr + "?mnf=2WAR\\Banner\\" + popupImg + "'," + popupValue.split("^")[5] + "," + popupValue.split("^")[6] + ", 'url=" + popupValue.split("^")[2] + "&popname=MainPop" + i + "&target=" + popupValue.split("^")[9] + "');\n" +
						"</Scr" + "ipt>";
				}
			
				strMainPop += "</td>\n</tr>\n" +
					"<tr>\n<td height='30' bgcolor='#000000'>\n" + 
					"<table width='100%' border='0' cellspacing='0' cellpadding='0'>\n" +
					"<tr>\n<td width='10'>&nbsp;</td>\n" +
					"<td><p align='left' style='COLOR: #808080 ; FONT-FAMILY: µ¸À½; FONT-SIZE: 9pt;' ><input type='checkbox' onClick=javascript:setCookieCheck('" + popupValue.split("^")[1] + "','Y',1,'" + domain + "','MainPop" + i + "');>¿À´Ã ÇÏ·ç ÀÌÃ¢À» ¿­Áö ¾ÊÀ½</td>\n" +
					"<td width='49'><a href=javascript:CloseMainPopup('MainPop" + i + "');><img src='http://image.freechal.com/fcgame/2WAR/common/20070709_btn_close.gif' width='49' height='17' border='0'></a></td>\n" +
					"<td width='15'>&nbsp;</td>\n" +
					"</tr>\n" + 
					"</table></td>\n" + 
					"</tr>\n</table>\n</div>\n";
			}
		}
	}
	document.write (strMainPop);
}



/*
	Function Name	: WindowPopUp(cookieValue, url, name, w)
	Writtern By		: specteye
	Parameter Info	: url	- ÆË¾÷ÁÖ¼Ò
					  name	- ÆË¾÷Ã¢ ÀÌ¸§
					  w		- ³ÐÀÌ
					  h		- ³ôÀÌ
					  x		- xÃà À§Ä¡
					  y		- yÃà À§Ä¡
	Return Info		: none
	Description		: ·¹ÀÌ¾î ÆË¾÷ ¶ç¿ì±â
*/
function WindowPopUp(url, name, w, h, x, y)
{

	if (!getCookie('eventPopExpired'))
	{
		winprops = 'width='+w+',height='+h+',top='+y+',left='+x+',resizable=no,scrollbars=no,status=no,menu=no';
		window.open(url, name, winprops);
	}
}