
// sets flash activation cookie
function setFlashCookie()
{
	var expiration = new Date();
	expiration.setTime(expiration.getTime() + 1000 * 600); // valid for 10 minutes
	document.cookie = "rFlashPlayed=1" + ";expires=" + expiration.toGMTString();
}

// checks if flash cookie exists
function checkFlashCookie()
{
	if (document.cookie.length > 0)
	{
		pos = document.cookie.indexOf("rFlashPlayed="); //12
		if (pos != -1)
		{ 
			if (document.cookie.charAt(pos + 13) == "1")
				return true;
		}
	}
	return false;
}		

// performs a check on the flash cookie and controls the flash banner
function onLoadFlashHandler(movieName)
{
	var returned;
	
	if (checkFlashCookie())
	{
		setFlashCookie();
		//statusField.innerHTML = "flash has already been played";
		movie = getFlashMovie(movieName);
		movie.setStatus("END");
	}
	else
	{
		setFlashCookie();
		//statusField.innerHTML = "flash has not been played yet";
		movie = getFlashMovie(movieName);
		movie.setStatus("START");
	}
}

// returns flash movie object
function getFlashMovie(movieName) 
{
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

// checks (recursively by setTimeout) if flash banner has loaded itself completely
function isMovieReady(movieName)
{
	movie = getFlashMovie(movieName);
	if (typeof(movie.setStatus) != "undefined") // checks if flash banner internal method is callable
		//alert("movie is ready");
		onLoadFlashHandler(movieName);
	else
		setTimeout("isMovieReady(\'" + movieName + "\')", 100); // continue checking
}