var gPAVideoTitle = null;
var gPAVideoFile = null;
var gPAContent = null;
var gPAPlayer = null;
var gPATryCount = 0;

/* try to show the flash, if we fail, try again in two seconds - this is a firefox workaround */
function showMyFlashWorker() {
	try {
		gPATryCount++;
		gPAPlayer.showFlash(gPAVideoTitle, gPAVideoFile);
	}
	catch (ex) {
		if (gPATryCount < 2)
		window.setTimeout("showMyFlashWorker()", 2000);
	}
}

/* set global variables and call the real flash function */
function showMyFlash( objContent, objPlayer, sTitle, sFile ) {
	gPAPlayer = objPlayer;
	gPAVideoTitle = sTitle;
	gPAVideoFile = sFile;
	gPAContent = objContent;
	gPAContent.style.zIndex='200';
	gPAContent.style.left="50%";
	showMyFlashWorker();
}

/* swap out the trigger image and blank out the href */
function swapInFlashTriggerWorker( sPath, objTrigger ) {
	var img = objTrigger.getElementsByTagName("img");
		img[0].src="/images/"+sPath+"-vid-thumb.jpg";
	var a = objTrigger.getElementsByTagName("a");
		a[0].href="#";
}

/* hide the player window and reset trycount */
function onPlayerClose() {
	gPAContent.style.zIndex='-1';
	gPAContent.style.left="-50%";
	gPATryCount = 0;
}

/* first set of video players */
function doVideoPlayer() {
	showMyFlash( document.getElementById('flashcontent'), window.player, video.title, '/media/'+video.file );
}
function swapInFlashTrigger(path) {
	swapInFlashTriggerWorker( path, document.getElementById("trigger") );
}

/* added second video to the performance page.  These can be reused for second videos added to other pages. */
function doVideoPlayer2() {
	showMyFlash( document.getElementById('flashcontent2'), window.player2, video2.title, '/media/'+video2.file );
}
function swapInFlashTrigger2(path) {
	swapInFlashTriggerWorker( path, document.getElementById("trigger2") );
}
