var VideoPlayer = Class.create();
VideoPlayer.prototype = {

//local variables
m_surface: null,
m_highlight: null,
m_lastElement: null,

//
// Constructor
initialize: function(objectOptions)
	{
		ParseOptions(objectOptions, this);
/*
		if (this.m_renderSurfaceId!=null)
		{
			this.m_surface = document.getElementById(this.m_renderSurfaceId);
		}

		this.m_surface.innerHTML = "?";
		this.m_surface.style.border = "1px";

		this.m_highlight = createDiv("HelpHighlight");
		this.m_highlight.style.display = 'none';
		this.m_highlight.title = "Click for help on this item";
		document.body.appendChild(this.m_highlight);

*/
		mSpaceApplication.Subscribe("VideoPlayer.Play", this);
		mSpaceApplication.Subscribe("VideoPlayer.Hide", this);
		mSpaceApplication.Subscribe("VideoPlayer.Show", this);

	},
	
Notify: function(eventName, eventParams)
	{
		switch(eventName)
		{
			case 'VideoPlayer.Play' : this.Play(eventParams); break;
			case 'VideoPlayer.Hide' : this.Hide(eventParams); break;
			case 'VideoPlayer.Show' : this.Show(eventParams); break;
			default: break;
		}
	},

Play: function(eventParams)
	{
		var surface = $("videoSurface");
		
		
		surface.className = "videolding";
		
		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.innerHTML = 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.innerHTML = embed;
				break;
		}
	},
	
Hide: function()
	{
		var surface = $("videoSurface");
		if (surface)
		{
			surface.style.visibility = "hidden";
		}
	},
	
Show: function()
	{
		var surface = $("videoSurface");
		if (surface)
		{
			surface.style.visibility = "visible";
		}		
	}
}
