var nil = 'nada';
var isSWFReady = false;
var viewTolerance = 5;

function UpdateCookie(visitNum)
{
	if(visitNum == nil)
	{
		visitNum = (parseInt(readCookie("elcintro"))+1);
		visitNum = (visitNum == NaN) ? 0 : visitNum;
	}
	createCookie("elcintro",visitNum.toString(),120);
}

function HidePlayer(value)
{
	if(value == "true")
	{
		UpdateCookie(5);
	}
	document.getElementById("video").style.visibility = "hidden";
	document.getElementById("video").style.display = "none";
	document.getElementById("textBlock").style.visibility = "visible";
	document.getElementById("textBlock").style.display = "block";
}

function ShowPlayer()
{
	document.getElementById("textBlock").style.visibility = "hidden";
	document.getElementById("textBlock").style.display = "none";
	document.getElementById("video").style.visibility = "visible";
	document.getElementById("video").style.display = "block";
}

function createCookie(name,value,days) 
{
	var expires = "";
	if (days) 
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires=date.toGMTString();
	}
	document.cookie = name+"="+value+";expires="+expires+";path=/";
}

function readCookie(name) 
{
	var rtrnValue = null;
	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) 
		{
			rtrnValue = c.substring(nameEQ.length,c.length);
		}
	}
	return rtrnValue;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}

function getSWF(movieName)
{
    if (navigator.appName.indexOf("Microsoft") != -1)
    {
        return window[movieName];
    }
    else
    {
        return document[movieName];
    }
}


function DiscoverObj(obj)
{
	var str = ""; //variable which will hold property values
	for(prop in obj)
	{
		str += prop + " value : " + obj[prop] + "\n"; //Concate prop and its value from object
	}
	return str; //Show all properties and its value
}

function vidOnLoad()
{
	var loopCount = 0;
	do 
	{
		loopCount++;
		if(loopCount > 100000)
		{
			break;
		}
		else
		{
			continue;
		}
	} 
	while (!isSWFReady)
	if(isSWFReady)
	{
		if((readCookie("elcintro") == null) || (parseInt(readCookie("elcintro"))<viewTolerance))
		{
			UpdateCookie((readCookie("elcintro") == null) ? 0 : nil);
			RestartVideo();
		}
		else
		{
			UpdateCookie(nil);
			HidePlayer(false);
			getSWF("ELCIntro").PauseVid();
		}
	}
}

var restartTimerId = 0;

function RestartVideo()
{
	ShowPlayer();
	if(getSWF("ELCIntro").PlayVid == null)
	{
		//restartTimerId = window.setTimeout("RestartVideo();", 2000);
	}
	else
	{
		//window.clearTimeout(restartTimerId);
		getSWF("ELCIntro").PlayVid();
	}
}

function swfReady()
{
	isSWFReady = true;
}

function noShowState()
{
	if(readCookie("elcintro") == null) {return false;}
	return (parseInt(readCookie("elcintro")) < viewTolerance) ? false : true;
}

function WriteSWFTags()
{
	if (AC_FL_RunContent == 0)
	{
		document.write("This page requires AC_RunActiveContent.js.");
	} 
	else 
	{
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '330',
			'height', '240',
			'src', 'ELCIntro',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'false',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', 'ELCIntro',
			'bgcolor', '#ffc000',
			'name', 'ELCIntro',
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','always',
			'movie', 'ELCIntro',
			'salign', ''
			); //end AC code
	}
}