
// Script for popup window

function popupSetCookie( name, value )
{
	var argc = popupSetCookie.arguments.length;
	var argv = popupSetCookie.arguments;

	var path = (argc > 2) ? argv[2] : null;
	var domain = (argc > 3) ? argv[3] : null;
	var expires = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;

	if ( value.length == 0 )
	{
		expires = new Date();
		expires.setDate( expires.getDate()-1 );
	}

	/* Cookie SET */
	document.cookie = name + "=" + escape( value ) +
		( (path == null) ? "" : ("; path=" + path) ) +
		( (domain == null) ? "" : ("; domain=" + domain) ) +
		( (expires == null) ? "" : ("; expires=" + expires.toGMTString()) ) +
		( (secure == true) ? "; secure" : "" );
}

function popupGetCookie( name )
{
	var search = name + "=";

	if ( document.cookie.length > 0 ) /* if there are any cookies */
	{
		offset = document.cookie.indexOf( search );
		if ( offset != -1 ) /* if cookie exists */
		{
			offset += search.length;
			/* set index of beginning of value */
			end = document.cookie.indexOf( ";", offset );
			/* set index of end of cookie value */
			if ( end == -1 ) 
				end = document.cookie.length;
			return unescape( document.cookie.substring( offset, end ) );
		} 
	}
	return "";
}

function popupIsDisabled( name )
{
	var v;
	v = popupGetCookie(name);
	if (v == "1") return true;
	return false;
}

function popupDisable( name, expdate )
{
	var expire = new Date();
	expire.setDate( expire.getDate() + expdate );

	popupSetCookie( name, "1", "/", ".dreamwiz.com", expire );
}

