//////////////////////////////////////////////
// VideoPLayer Object 
//////////////////////////////////////////////
//
// The vide player control is a simple object 
// that handles playing the news film online 
// video clips.  It listens for the user to 
// click a button to play the video clip in 
// their preferred format, and then adds the 
// correct embedded player to the page.
//
//////////////////////////////////////////////



var VideoPlayer = Class.create();
VideoPlayer.prototype = {

//local variables
m_surface: null,
m_highlight: null,
m_lastElement: null,

//
// Constructor
initialize: function()
	{

		//listen to events
		document.observe('VideoPlayer:Play',			this.Play.bindAsEventListener(this));
		document.observe('VideoPlayer:Hide',			this.Hide.bindAsEventListener(this));
		document.observe('VideoPlayer:Show',			this.Show.bindAsEventListener(this));

	},

//Play function call, adds the relevant embedd code to the page
Play: function(e)
	{
		var eventParams = e.memo;
		
		var surface = $("videoSurface");
		
		
		surface.className = "videolding";
		
		//Check the format flag
		switch(eventParams.format)
		{
			case 'quicktime':
				var embed = '<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="' + eventParams.width + '" height="' + eventParams.height + '" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">';
				embed += '<param name="src" value="'+eventParams.url+'">';
				embed += '<param name="saveembedtags" value="true">';
				embed += '<param name="scale" value="Aspect">';
				embed += '<embed width="' + eventParams.width + '" height="' + eventParams.height + '" src="'+eventParams.url+'" name="mSpaceEmbeddedVideoControl" enablejavascript="true" scale="Aspect" saveembedtags="true" /></object>'
				surface.update(embed);
				break;

			case 'mediaplayer':
				var embed = '<object id="MediaPlayer" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Microsoft® Windows® Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" width="' + eventParams.width + '"> ';
				embed += '<param name="FileName" value="'+eventParams.url+'">';
				embed += '<param name="Autostart" value="true">';
				embed += '<param name="ShowDisplay" value="false">';
				embed += '<param name="ShowControls" value="true">';
				embed += '<param name="ShowTracker" value="true">';
				embed += '</object>';
				surface.update(embed);
				break;
		}
	},
	
//hide the video surface
Hide: function(e)
	{
		var surface = $("videoSurface");
		if (surface)
		{
			surface.style.visibility = "hidden";
		}
	},
	
//show the video surface
Show: function(e)
	{
		var surface = $("videoSurface");
		if (surface)
		{
			surface.style.visibility = "visible";
		}		
	}
}
