// flag
_domHasLoaded = false;	

function skipIntro()
{
	hideFlash();
}

// add flash video player
function insertFlash()
{
	var a = new Element('div', {'id':'swfContainer'});
	$('flashContent').appendChild(a);
	
	// a flashvar of 'video' can be specificed to direct the player to a video file; SWF will default to /flash/media/video/mov/home-default.mov
	var flashVars = {};
	var params = { base:"", scale:"noscale", allowScriptAccess:"always", quality:"best", wmode:"opaque", allowFullScreen:"false" };
	var attributes = { id:"videoPlayer" };
	swfobject.embedSWF( "/flash/simple-player.swf", "swfContainer", "978px", "398px", "10.0.0", "/flash/expressInstall.swf", flashVars, params, attributes );
//	swfobject.createCSS("#site","outline:none;"); 

	// initially hide all containers for tab content
	$('replayButton').hide();
	$('skipButton').show();
}

function removeFlash()
{			
	$('replayButton').show();
	$('skipButton').hide();
	
	swfobject.getObjectById('videoPlayer').dispose();
//	swfobject.removeSWF('videoPlayer');	
//  swfobject.removeSWF() doesn't work properly, so just clear out the html content of Flash's container
	$('flashContent').innerHTML= '';
}

//--------- API for flash -----------

function hideFlash()
{
	$('homePageLargeBucketTextOverlay').setStyle({'display':'inline'});
	$('homePageLargeBucketButton').setStyle({'display':'inline'});
	
	// flash will call videoComplete() once it's hidden
	swfobject.getObjectById('videoPlayer').hide();
}

function onHidden()
{
	removeFlash();
}
//------------------------------------

// get ready
document.observe("dom:loaded", function() 
{
	$('homePageLargeBucketTextOverlay').setStyle({'display':'none'});
	$('homePageLargeBucketButton').setStyle({'display':'none'});

	// this flag is a hack because, for some reason, dom:loaded get's called twice...
	if(!_domHasLoaded ){
		_domHasLoaded = true;
		init();
	}
});

// init
function init()
{
	insertFlash();
}