function readCookie(name)
{
	var nameEQ = name + "="; var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;
}

// COOKIE SET
if (document.cookie && document.cookie !=""){
	var flashPlayStatus = readCookie('FlashPlay');
}

function setFlashNoPlay() {document.cookie="FlashPlay=PlayFalse";}
function setFlashPlay() {document.cookie="FlashPlay=PlayTrue";}

// REFRESH CHECKER
function checkRefresh()
{
	var today = new Date();var now = today.getUTCSeconds();var cookie = document.cookie;var cookieArray = cookie.split('; '); for(var loop=0; loop < cookieArray.length; loop++){var nameValue = cookieArray[loop].split('=');if( nameValue[0].toString() == 'SHTS' ){var cookieTime = parseInt( nameValue[1] );}else if( nameValue[0].toString() == 'SHTSP' ){var cookieName = nameValue[1];}}

	if( cookieName && cookieTime && cookieName == escape(location.href) && 
	Math.abs(now - cookieTime) < 5  )
	{
		// Refresh detected
		setFlashPlay();
		/*flashPlayStatus = 'PlayFalse';*/
		/*document.cookie="FlashPlay=PlayFalse";*/
		/*alert(flashPlayStatus);*/
	}
	
}

function prepareForRefresh(){if( refresh_prepare > 0 ){var today = new Date();var now = today.getUTCSeconds();document.cookie = 'SHTS=' + now + ';';document.cookie = 'SHTSP=' + escape(location.href) + ';';}else {document.cookie = 'SHTS=;';document.cookie = 'SHTSP=;';}} var refresh_prepare = 1;


window.onLoad = checkRefresh();
window.onUnload = prepareForRefresh();

