﻿// JScript 파일
// 쿠키 반환
function NoticeGetCookie(name) 
{ 
	var varCookieName = name + "="; 
	var i = 0; 
	
	while (i <= document.cookie.length) 
	{ 
    	var varCookieLength = (i + varCookieName.length); 
    	
    	if (document.cookie.substring(i, varCookieLength) == varCookieName)
    	{     		
            if ((varCookieEnd = document.cookie.indexOf(";", varCookieLength)) == -1) 
            {
            	varCookieEnd = document.cookie.length; 
			}   
			                 
            return unescape(document.cookie.substring(varCookieLength, varCookieEnd)); 
    	} 
    	
    	i = document.cookie.indexOf(" ", i) + 1; 
    	if (i == 0) 
    	{
            break; 
        }
	} 
	
	return ""; 
}

// 쿠키 설정
function NoticeSetCookie(name, value, nExpire) 
{ 
	var varToday = new Date(); 
	varToday.setDate(varToday.getDate() + nExpire); 
	
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + varToday.toGMTString() + ";";
} 

// 오늘하루 이창을 열지 않음 수행
// parameter: popup_name
function NoticeCloseWin(obj, sName) 
{ 
	if (obj.checked)
    {
    	 // 1 = 하룻동안 공지창 열지 않음 
    	NoticeSetCookie(sName, "YES" , 1);
    }
        
    self.close(); 
}

// 팝업창 띄우기 (항상 정중앙에 위치)
// sUrl = 팝업창 경로
// sName = 팝업창 이름
// sWidth = 팝업창 가	로 사이즈
// sHeight = 팝업창 세로 사이즈
// sLeft = 팝업창 좌측 위치
// sTop = 팝업창 상단 위치
// sScroll = 스크롤 유무(yes / no / auto)
// sStatus = 상태바 유무(yes / no)
// sResize = 크기조정 유무(yes / no)
function Popup(sUrl, sName, sWidth, sHeight, sLeft, sTop, sScroll, sStatus, sResize)
{
	// 팝업창 옵션값
	var varOpt = "width=" + sWidth + ",height=" + sHeight;
	varOpt += ",left=" + sLeft + ",top=" + sTop;
	varOpt += ",scrollbars=" + sScroll;
	varOpt += ",status=" + sStatus;
	varOpt += ",resizable=" + sResize;
	varOpt += ",menubar=no,toolbar=no,locationbar=no";
	varOpt += ",directories=no";	

	return window.open(sUrl, sName, varOpt);
}




	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 SetCookie (name, value) {
		var argv = SetCookie.arguments;
		var argc = SetCookie.arguments.length;
		var expires = (argc > 2) ? argv[2] : null;
	//  var path = (argc > 3) ? argv[3] : null;
	//	var path = "/";
		var path = "";
		var domain = (argc > 4) ? argv[4] : null;
		var secure = (argc > 5) ? argv[5] : false;

	//  document.cookie = name + "=" + escape (value) +
		document.cookie = name + "=" + (value) +
			((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
			((path == null) ? "" : ("; path=" + path)) +
			((domain == null) ? "" : ("; domain=" + domain)) +
			((secure == true) ? "; secure" : "");
	}
	function DeleteCookie (name) {
		var exp = new Date();
		exp.setTime (exp.getTime() - 1);  // This cookie is history
		var cval = GetCookie (name);
		document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
	}


