function GetCookieVal(offset)
{
	var endstr = document.cookie.indexOf(";", offset);
	if(endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if(document.cookie.substring(i,j) == arg)
			return GetCookieVal(j);
		i = document.cookie.indexOf(" ",i) + 1;
		if(i == 0) break;
	}
	return null;
}

function GetToDay()
{
	var strToday;
	var Today = new Date();
	cDay_Y = Today.getFullYear();
	cDay_M = Today.getMonth() + 1;
	cDay_D = Today.getDate();
	if(cDay_M < 10) cDay_M = "0" + cDay_M;
	if(cDay_D < 10) cDay_D = "0" + cDay_D;
	strToday = cDay_Y + "/" + cDay_M + "/" + cDay_D;
	return strToday;
}

//var oWidth,oHeight;
//oWidth = null;
//oHeight = null;
function Window_Open(WindowName,sUrl,iWidth,iHeight,iLeft,iTop,strScroll,LimitDay,strCookie,bNotLimitDayMsg)
{
	var WinFlag = true;
	var bSize = false;
	var bLimit	= (LimitDay == null)? false : true;
	var bCookie = (strCookie == null)? false : true;
	var bNLDM	= (bNotLimitDayMsg == null)? true : bNotLimitDayMsg;

	// Features
	strFeat = "";
	if(iWidth != null && iHeight != null)
	{
		if(iWidth != 0 && iHeight != 0)
		{
			strFeat = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,";
			if(strScroll != null)
			{
				if(strScroll == "yes") strFeat = strFeat + "scrollbars=yes,";
				else strFeat = strFeat + "scrollbars=no,";
				if(strScroll == "ie5")
				{
					if(document.all)
					{
						strFeat = strFeat + "scrollbars=no,";
					}
					else
					{
						strFeat = strFeat + "scrollbars=yes,";
						iWidth = iWidth + 18;
					}
				}
			}
			strFeat = strFeat + "width=" + iWidth + ",height=" + iHeight;
			var screenXY;
			if(iLeft == null)
			{
				screenXY = window.screen.availWidth;
				iLeft = Math.ceil((screenXY - iWidth) / 3 );
				strFeat = strFeat + ",left=" + iLeft;
			}
			else
			{
				strFeat = strFeat + ",left=" + iLeft;
			}
			if(iTop == null)
			{
				screenXY = window.screen.availHeight;
				iTop = Math.ceil((screenXY - iHeight) / 3 );
				strFeat = strFeat + ",top=" + iTop;
			}
			else
			{
				strFeat = strFeat + ",top=" + iTop;
			}
		}
	}

	if(bLimit)
	{
		var LDay = LimitDay.replace(/\-/g,"/");
		if(LDay.length != 10)
		{
			var rDay = LDay.split("/");
			if(rDay[1].length == 1) rDay[1] = "0" + rDay[1];
			if(rDay[2].length == 1) rDay[2] = "0" + rDay[2];
			LDay = rDay[0] + "/" + rDay[1] + "/" + rDay[2];
		}
		if(LDay < GetToDay())
		{
			// Message
			if(bNLDM) alert("Check Out.");
			WinFlag = false;
		}
	}

	// Cookie
	if(bCookie)
	{
		var TempCookie = GetCookie(strCookie);
		if(WindowName != TempCookie) WinFlag = false;
	}
	// Open
	if(WinFlag)
	{
		var objModalWin = window.open(sUrl,WindowName,strFeat);
		objModalWin.focus();
	}

}

function PopWinClose()
{
	window.close();
}

function News_nOpen(iPKNumber,sUrl,iX,iY,iS,iN)
{
	var strUrl;
	if(sUrl == "") strUrl = "news/news.asp?seNum=" + iPKNumber;
	else strUrl = sUrl;
	var sX,sY;
	if(iX != "") sX = parseInt(iX,10)
	else sX = null;
	if(iY != "") sY = parseInt(iY,10)
	else sY = null;
	Window_Open("NewsUrlWin",strUrl,sX,sY,50,50,iS,null,null,null);
}

function News_Open(iPKNumber)
{
	var strUrl;
	if(iPKNumber == null) strUrl = "news/news_list.asp";
	else strUrl = "news/news.asp?seNum=" + iPKNumber;
	Window_Open("NewsShowWin",strUrl,600,500,100,100,"ie",null,null,null);
}

function News_Open01(iPKNumber)
{
	var strUrl;
	if(iPKNumber == null) strUrl = "Board/news_list.asp";
	else strUrl = "Board/news.asp?seNum=" + iPKNumber;
	Window_Open("NewsShowWin",strUrl,600,500,100,100,"ie",null,null,null);
}

function Search_Open()
{
	var strUrl;
	var strPath = window.location.pathname;
	var iPath = strPath.length;
	//strPath = strPath.substring(iPath-1,iPath);
	//if (strPath == "/" || strPath == "p") strUrl = "search/search.html";
	//else strUrl = "../search/search.html";
	strUrl = "../search/search.html";
	Window_Open("SearchWindow",strUrl,650,500,50,50,"ie",null,null,null);
}

function GoPage(obj) {
  var obj;
  parent.location.href= obj;
}
