//Support function: checks to see if target
//element is an object or embed element
var adViewed = false;
var timer = null;
var countdown = 10;

var m_swf_file = '';
var m_height = 0;
var m_width = 0;
var m_bgcolor = '#FFFFFF';
var m_title = '';
var m_flashvars = '';

function setupMovie(title, w, h, color, vars, file)
{
	m_swf_file = file;
	m_height = h;
	m_width = w;
	m_title = title;
	m_flashvars = vars;
	m_bgcolor = color;

}
function load() {
	create();
	if(adViewed == false)
	{
		document.getElementById("game_intro").style.display = 'block';
		document.getElementById("flash_game").style.display = 'none';
		timer = setTimeout('onTimer()', 1000);

	}
	else
	{

		show();
	}
	return true;
}
function loadNoAd()
{
	adViewed = true;
	load();
}
function onTimer()
{    
	countdown --;
	var elem = document.getElementById("counter");
	elem.innerHTML = countdown;
	if(countdown <= 0)
	{
		show();
	}
	else
	{
		timer = setTimeout('onTimer()', 1000);
	}
}
function skipAd()
{
	if(timer) clearTimeout(timer);
	adViewed = true;
	show();
}

function show()
{
	adViewed = true;
	document.getElementById("game_intro").style.display = 'none';


	document.getElementById("flash_game").style.display = 'block';

}
function create()
{
	if (swfobject.hasFlashPlayerVersion("9"))
	{
		// check if SWF hasn't been removed, if this is the case, create a new alternative content container
		var c = document.getElementById("content");
		if (!c)
		{
			//var d = document.createElement("div");
			c = document.createElement("div");
			c.setAttribute("id", "content");			
			document.getElementById("content-container").appendChild(c);

		}
		// create SWF
		var att = {};
		att.data = m_swf_file; 
		att.width = m_width;
		att.height = m_height;
		att.name = m_title;

		var par = {};
		par.menu = "false";
		par.quality = "high";
		par.wmode = "transparent";
		par.bgcolor = m_bgcolor;
		par.allowfullscreen = "true";
		par.allowscriptaccess = "always";
		par.swliveconnect = "true";
		par.flashvars = m_flashvars;

		var id = "content";
		swfobject.embedSWF(m_swf_file, id, m_width, m_height, "9.0.0", "expressInstall.swf", m_flashvars, par, att);
	}
}
function remove() {
	if(timer) clearTimeout(timer);
	swfobject.removeSWF("content");
}

function swf_show(show)
{
	var c = document.getElementById("content");
	var c1 = document.getElementById("content1");
	if (c)
	{


		if (show)
		{
			c.style.width="";
			c.style.height="";
			c.style.visibility = "visible";

		}
		else
		{
			c.style.width="0px";
			c.style.height="0px";
			c.style.visibility = "hidden";

		}  
	}
	if (c1)
	{


		if (show)
		{
			c1.style.width="";
			c1.style.height="";
			c1.style.visibility = "visible";

		}
		else
		{
			c.style.width="0px";
			c.style.height="0px";
			c1.style.visibility = "hidden";

		}  
	} 
}
