var videoID = null;

function openVideo( id, uri )
{
	var container = document.getElementById( id + "Video" );
	var link = document.getElementById( id + "Link" );

	try
	{
		link.blur();
	}
	catch( error )
	{
		window.focus();
	}

	if( videoID != null )
	{
		closeVideo( true );

		if( id == videoID )
		{
			videoID = null;
			return;
		}
	}

	container.innerHTML = "<object id=\"flashVideo\" type=\"application/x-shockwave-flash\" "
	                    + "data=\"media/video-player.swf\">"
	                    + "<param name=\"movie\" value=\"media/video-player.swf\"/>"
						+ "<param name=\"allowScriptAccess\" value=\"always\"/>"
						+ "<param name=\"flashVars\" value=\"vid=" + uri + "\"/>"
						+ "</object>";

	link.innerHTML = "Close Video";

	videoID = id;
}

function closeVideo( jsCall )
{
	if( videoID == null || jsCall !== true )
	{
		return;
	}

	var o = document.getElementById( "flashVideo" );

	if( jsCall === true && o )
	{
		o.close();
	}

	var container = document.getElementById( videoID + "Video" );
	container.innerHTML = "";

	var link = document.getElementById( videoID + "Link" );
	link.innerHTML = "Play Video";

	if( jsCall !== true )
	{
		videoID = null;
	}
}
