//Jonathan's Simple FLV player Script
//requires SWFObject

document.onclick = function (e) //global click handler -- used to detect when the user clicks anywhere on the page
{
	e = e || event; //get the click event
	target = e.target || e.srcElement; //find out what the target element of the click was
	obj = document.getElementById("videoPlayer"); //reference the video player container div
	if(obj != null)
	{
		if(target.id.indexOf("Link") == -1 && obj.style.display != "none") //if the video player is visible, and the user clicked anywhere besides the "play a video" links
		{
			closeVideo(); //close the video player
		}
	}
}

function loadVideo(videoName) //load and start playing a video
{
	obj = document.getElementById("videoPlayer"); //reference video player container
	obj2 = document.getElementById("videoBackground"); //reference video player background
	obj2.style.display = "block"; //unhide the background
	obj.style.display = "block"; //unhide the container

	pageTracker._trackPageview("/video/start/"+videoName+".flv"); //send google tracking data

	var sfo = new SWFObject("../VideoPageResources/simpleflv/simpleflv_480.swf", "SimpleFLV", "480", "360", "7", "#ffffff", true);
	sfo.addParam("allowScriptAccess", "always");
	sfo.addParam("base", ".");
	sfo.addVariable('FilePath','../'+videoName);
	sfo.write("videoPlayer");
}

function closeVideo() //close the video player -- this function is called by the global click handler when the user clicks in the document, and is called by Flash if the user clicks anywhere on the video itself
{
	obj = document.getElementById("videoPlayer"); //reference video player container
	obj2 = document.getElementById("videoBackground"); //reference video player background
	obj.style.display = "none"; //make the player invisible
	if(obj2 != null)
	{
		obj2.style.display = "none"; //make the background hidden
	}
	obj.innerHTML = ""; //clean out the code that was inside so the video stops playing
}