// ===========================================================================
// Global variables (Cookie Handling)
//
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;
}

// ===========================================================================
// Global variables (Cashin Site Specific)
//
var currentVolume = "0.7";
var isCC = 0;
// Check and get the data from the cookie.
//
function checkCookie()
{
	isCC = getCookie('iscc');
	if ((isCC == null) || (isCC > 1))
	{
		isCC = 2;
		setCookie('iscc', isCC, shortExpireTime, '/', '', '');
		isCookie = false;
	}
	currentVolume = getCookie('currentVolume');
	if ((currentVolume == null) || (currentVolume == ""))
	{
		currentVolume = "0.7";
		setCookie('currentVolume', currentVolume, longExpireTime, '/', '', '');
		isCookie = false;
	}
	// ^^^^^^^^^^^^^^^^^^^^^^^^^^
	// Add other data before this
	isCookieReady = true;
}
function readVolume()
{
	return currentVolume;
}
// Called by actionscript to save the current volume.
//
function saveVolume(value)
{
	currentVolume = value;
	setCookie('currentVolume', currentVolume, longExpireTime, '/', '', '');
}
function readCC()
{
	if (isCC == 2)
		return 0;
	return isCC;
}
function saveCC(value)
{
	isCC = value;
	setCookie('iscc', isCC, shortExpireTime, '/', '', '');
}

// ===========================================================================
// Button highlighting handling
//
function highlightItem(idd) {
	i = document.getElementById(idd);
	
	i.style.opacity = '0.5';
	i.style.filter = 'alpha(opacity=50)';
}
function clearItemHighlight(idd) {
	i = document.getElementById(idd);
	
	i.style.opacity = '0';
	i.style.filter = 'alpha(opacity=0)';
}

function prettyPhotoClose() {
	var urlquery = document.URL;
	var qi = urlquery.search(/\x23/);
	var url = urlquery.substr(0, qi);
	
	var myWindow = window.open(url, '_self');
	myWindow.focus();

}

