// ÆË¾÷Ã¢ °ü¸® °ü·Ã
var POPUP_REGISTRY = null;			// µî·ÏµÈ ÆË¾÷ °´Ã¼ ¹è¿­
function Popup_RegisterPopup(popupObject)
{
	if (POPUP_REGISTRY == null)
		POPUP_REGISTRY = new Array();
	if (popupObject != null)
		POPUP_REGISTRY[POPUP_REGISTRY.length] = popupObject;
}
function Popup_ShowPopup()
{
	if (POPUP_REGISTRY != null)
	{
		for (var i = 0; i < POPUP_REGISTRY.length; i++)
		{
			if (POPUP_REGISTRY[i] != null)
				POPUP_REGISTRY[i].show();
		}
	}
}
function PopupObject(name, url, width, height)
{
	this.name	= (name == null)? "popup": name;
	this.url	= (url == null)? "about:blank": url;
	this.width	= (width == null)? 300: width;
	this.height	= (height == null)? 400: height;
	this.top	= null;
	this.left	= null;
	this.scroll	= null;
	this.resize	= null;
	this.showFrom	= null;
	this.showTo		= null;

	this.open = PopupObject_Open;
	this.show = PopupObject_Show;
}
function PopupObject_Open()
{
	var feature = "width=" + this.width;
	feature += ",height=" + this.height;
	if (this.top != null)
		feature += ",top=" + this.top;
	if (this.left != null)
		feature += ",left=" + this.left;
	if (this.scroll != null)
		feature += ",scrollbars=" + this.scroll;
	if (this.resize != null)
		feature += ",resizable=" + this.resize;
	return window.open(this.url, this.name, feature);
}
function PopupObject_Show()
{
	// °Ô½Ã ±â°£ÀÌ ¼³Á¤µÇ¾ú´Ù¸é
	if (this.showFrom != null && this.showTo != null)
	{
		var now = new Date();
		if (this.showFrom.valueOf() > now.valueOf() || this.showTo.valueOf() < now.valueOf())
			return false;
	}

	// ÄíÅ°°¡ ¼³Á¤µÇ¾ú´Ù¸é
	if (GetCookie(this.name) == 'nothanks')
		return false;

	return this.open();
}

// ÄíÅ° °ü·Ã
var COOKIE = null;					// ºÐ¼®µÈ ÄíÅ° ¹è¿­
function GetCookie(cookie_name)
{
	if (COOKIE == null)
	{
		COOKIE = new Array();
		var s = String(document.cookie);
		var a = s.split(/\s*;\s*/);
		for (i = 0; i < a.length; i++)
		{
			var b = a[i].split(/\s*=\s*/);
			if (b[1] != null && b[1] != "")
				COOKIE[b[0]] = unescape(b[1]);
		}
	}
	return COOKIE[cookie_name];
}
function Popup_SetCookie(name, value, expire_time)
{
	if (expire_time == null)
		expire_time = 24;		// 1ÀÏ
	var today = new Date();
	today.setHours(today.getHours() + expire_time);
	document.cookie = name + "=" + escape( value ) + "; path=/; domain=.cine21.com; expires=" + today.toGMTString() + ";";
}
