// JavaScript Document
var ie = (document.all) ? true : false;
var secs
var timerID = null
var timerRunning = false
var VideoLoad = false
var delay = 1000

function LoadVideo(){
	showID("VideoLoad");	
	InitializeTimer();
	showID("Movie1");
	hideID("Logo1");
	hideID("ClickLogo2");
}

function HideVideo(){
	hideID("VideoLoad");
	hideID("Movie1");
	showID("Logo1");
	showID("ClickLogo2");
}

function hideID(objID){
    var element = (ie) ? document.all(objID) : document.getElementById(objID);
    element.style.display="none"
}
function showID(objID){
    var element = (ie) ? document.all(objID) : document.getElementById(objID);
    element.style.display="block"
}

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 15
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning){
		hideID("VideoLoad");
		//showID("ClickLogo2");
        clearTimeout(timerID)
	}
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        // alert("You have just wasted 10 seconds of your life.")
    }
    else
    {
        self.status = secs
		if (VideoLoad == false){
			showID("VideoLoad");
			VideoLoad = true;
		}
		else
			{hideID("VideoLoad");
			VideoLoad = false;
			}
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function createCookie(name,value,mins) {
	if (mins) {
		var date = new Date();
		date.setTime(date.getTime()+(mins*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function message()
{
	eraseCookie("movie");
	var test = readCookie("movie")
	alert(test);
}

function movieRun(){
	if(readCookie("movie")!=null){
		HideVideo();
	}else{
		createCookie("movie",true,5);
		LoadVideo();
	}
}
window.onload=movieRun;