// ===========================================================================
// Global variables
//
var isCookieReady = false;
var isCookie = true; // Assume a cookie file was already saved
var longExpireTime = 365;
var shortExpireTime = 1;


// Get the data from the cookie, if any.
//
function getCookie(c_name)
{
	if (document.cookie.length > 0)
	{
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1)
		{
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";",c_start);
			if (c_end == -1)
				c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return null;
}

// Save the data to the cookie.
//
function setCookie(c_name, value, expiredays, path, domain, secure)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	
	document.cookie = c_name + "=" + escape(value) +
		((expiredays == null) ? "" : ";expires=" + exdate.toUTCString()) + 
		((path) ? ";path=" + path : "") +
		((domain) ? ";domain=" + domain : "") +
		((secure) ? ";secure" : "" );
}

function deleteCookie(c_name, path, domain)
{
	if (getCookie(c_name))
		document.cookie = c_name + '=' +
			(( path ) ? ";path=" + path : "") +
			(( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// Called by actionscript just to verify that there is communication between
// Flash and HTML. If javascript is not enabled, this will fail. Also, it depends
// on when the cookie file was read. This is useful if the Flash also depends on
// what is stored in the cookie file.
//
function isJSready()
{
	return true;
}


