
var popupedWindow; 


// ÆË¾÷Ã¢ ¶ç¿ì±â: ÀÎÀÚ (ÆË¾÷Ã¢ ÆÄÀÏ¸í,width,height,scrollbar,ÄíÅ°°ªÀÌ¸§[,Á¾·á½ÃÁ¡,½ÃÀÛ½ÃÁ¡])
// popup_check_cookie('event.html', 200, 300, 0, 'eventcookie','200202010130','200202050100');
function popup_check_cookie(filename, width, height, scrollbar, yp,xp,cookiename, enddate, startdate)
{ 
	var openwindow = "yes";

	// ÄíÅ° È®ÀÎ 
	var cookies = document.cookie.split("; ");
	for (var i=0 ; i < cookies.length ; i++)
	{
		var cont = cookies[i].split("=");

		if (cont[0] == cookiename && cont[1] == "DoNotOpen")
			openwindow = "no";
	}

	// ³¯Â¥ È®ÀÎ 
	var today = new Date();
	strNow = String(today.getYear())
            	+ ((today.getMonth() + 1 > 9) ? today.getMonth() + 1 : '0' + (today.getMonth() + 1))
	            + ((today.getDate() > 9) ? today.getDate() : '0' + today.getDate()) 
	            + ((today.getHours() > 9) ? today.getHours() : '0' + today.getHours()) 
	            + ((today.getMinutes() > 9) ? today.getMinutes() : '0' + today.getMinutes());
	if (enddate <= strNow || startdate > strNow) openwindow = "no";
	if (openwindow=="yes") {
		popupedWindow = window.open(filename,cookiename,'width='+parseInt(width)+',height='+parseInt(height)+',scrollbars='+parseInt(scrollbar)+',toolbar=no,location=no,directories=no,status=no,resizable=no,menubar=no,top=' + yp + ',left=' + xp + '');
	} 
	else 
	{
		popupedWindow = "none";
    }
}

// Ç×»ó ÆË¾÷Ã¢ ¶ç¿ì±â 
// popup_always('event.html', 200, 300, 0, '20020301');
function popup_always(filename, width, height, scrollbar, untildate )
{
    // ³¯Â¥ È®ÀÎ 
	var today = new Date();
	var strToday = today.getYear() + ((today.getMonth() + 1 > 9) ? today.getMonth() + 1 : '0' + (today.getMonth() + 1)) + ((today.getDate() > 9) ? today.getDate() : '0' + today.getDate());
	if (untildate < strToday) openwindow = "no"; 
	
	// ÆË¾÷À» ¶ç¿ò 
	if (openwindow=="yes")
    	popupedWindow = window.open(filename,'popupWin','width='+parseInt(width)+',height='+parseInt(height)+',scrollbars='+parseInt(scrollbar)+',toolbar=no,location=no,directories=no,status=no,resizable=no,menubar=no,top=100,left=100');
    else 
		popupedWindow = "none";
	return;
}

// unload ½Ã ÆË¾÷Ã¢ ´Ý±â 
function onunload_close_popup()
{
	if ( popupedWindow != "none" && popupedWindow != self ) popupedWindow.close();
	return;
}

// ÄíÅ°¸¦ ¼³Á¤ÇÏ°í À©µµ¿ì¸¦ ´ÝÀ½ 
// setcookie_close_window("event", 7); 
function setcookie_close_window(cookiename, day) 
{ 
    set_cookie( cookiename, "DoNotOpen" , parseInt(day), '/');
	self.close();
}

// ÄíÅ°¸¦ ¼³Á¤ÇÏ°í À©µµ¿ì¸¦ ´ÝÀ¸¸ç, ¿ÀÇÁ³Ê ¶Ç´Â »õ·Î¿î À©µµ¿ì¸¦ ÁöÁ¤ÇÑ ÆäÀÌÁö·Î º¸³¿ 
// setcookie_close_window_go("event", 7, "/", "yes"); 
function setcookie_close_go(cookiename, day, goToUrl, isNewWindow) 
{ 
	set_cookie( cookiename, "DoNotOpen" , parseInt(day), '/');
	if (isNewWindow == 'yes' || isNewWindow == '1') {
		window.open(goToUrl, 'NewWindow');
	} else 
	{
		opener.location.href = goToUrl;
	}
	self.close();
}

// ÄíÅ° ¼³Á¤ 
function set_cookie(name,value,expiresday,path,domain,secure) {
   
    var today = new Date();
    today.setDate( today.getDate() + expiresday );
    
    document.cookie = name + "=" + escape(value) +
        ( (expiresday) ? ";expires=" + today.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
	return;
}

