MetaWrap.Bigpond.Movies.Entertainmentportal.Video.Player.WMP = MetaWrap.Bigpond.Movies.Entertainmentportal.Video.Player.extend
    (
        {

			m_not_ie : false,

			m_states : ["undefined","stopped","paused","playing","forwarding","rewinding","buffering","waiting","completed","transitioning","ready","reconnecting"],

            constructor: function()
            {
				//debug("WMP:constructor");
            },

			embed: function()
			{
				document.write('<div id="divVideo" class="VideoWMP9" ><div id="divVideo_VideoOut"></div></div>');
			},

            include: function()
            {
				document.write('<style type="text/css">');
				//document.write('    div.VideoWMP9 { position:absolute;  border:0px;  margin:0px; padding: ' + this.m_video_x + 'px; left:' + this.m_video_y + 'px; top:8px;  width:' + this.m_video_w  + 'px; height:' + this.m_video_h + 'px; font-size:13px; font-family:vardana; z-index:100; visibility:hidden; cursor:hand; background-color:#FF0000;}');
				document.write('    div.VideoWMP9 { position:absolute;  border:0px;  margin:0px; padding: ' + this.m_video_x + 'px; left:' + this.m_video_y + 'px; top:8px;  width:' + this.m_video_w  + 'px; height:' + this.m_video_h + 'px; font-size:13px; font-family:vardana; z-index:100; visibility:hidden; cursor:hand;}');
				document.write('</style>');

				document.write('<script for="wmpVideo_Player" event="buffering(Start)">');
				document.write('    g_video_player.videoBuffering(Start);');
				document.write('</script>');

				document.write('<script for="wmpVideo_Player" event="ScriptCommand(p_type,p_param)">');
				document.write('try');
				document.write('{');
				document.write('    g_video_player.videoMessage(p_type,p_param);');
				document.write('}');
				document.write('catch(e)');
				document.write('{');
				document.write('}');
				document.write('</script>');

				document.write('<script for="wmpVideo_Player" event="MediaError(pMediaObject)">');
				document.write('try');
				document.write('{');
				document.write('    g_video_player.videoMediaError(pMediaObject);');
				document.write('}');
				document.write('catch(l_e)');
				document.write('{');
				document.write('}');
				document.write('</script>');


				document.write('<script for="wmpVideo_Player" event="error()">');
				document.write('try');
				document.write('{');
				document.write('    g_video_player.videoError();');
				document.write('}');
				document.write('catch(l_e)');
				document.write('{');
				document.write('}');
				document.write('</script>');

				document.write('<script for="wmpVideo_Player" event="playStateChange(NewState)">');
				document.write('try');
				document.write('{');
				document.write('    g_video_player.videoState(g_video_player.m_states[NewState]);');
				document.write('}');
				document.write('catch(l_e)');
				document.write('{');
				document.write('}');
				document.write('</script>');


				l_script = '<script src="'+ this.m_include_path +'mw_lib_bigpond_movies_entertainmentportal_video_player_wmp_implementation.js"></script>';
				document.write(l_script);

			},


            type: function()
            {
				return "WMP";
            },

			launchVideo: function(p_id)
            {
				//debug("WMP:launchVideo " + p_id);
				WMPlaunch(p_id);
			},

			closeVideo: function()
			{
				this.base();

				//debug("WMP:closeVideo");
				WMPclose();
			},

			// Play this video
			playVideo: function()
            {
				//debug("WMP:playVideo");
				this.base();

				WMPplay();
			},

			// Pause this video
			pauseVideo: function()
            {
				//debug("base:pauseVideo");
				WMPpause();
			},


			// Rewind this video
			restartVideo: function()
            {
				//debug("base:restartVideo");

				WMPrestart();
			},

			// mute the video
			muteVideoVolume : function(p_muted)
			{
				//debug("WMP:muteVideoVolume " + p_muted);

				WMPmute(p_muted);
			},

			// mute the video
			fullscreenVideo : function(p_fullscreen)
			{
				//debug("WMP:fullscreenVideo " + p_fullscreen);
				WMPfullscreen(p_fullscreen);
			},

			isBuffering: function()
			{
				return WMPisBuffering();
			},

			getBufferingPercentage: function()
			{
				return WMPgetBufferingPercentage();;
			},


			videoBuffering: function(p_starting)
			{
				if (p_starting)
				{
					return 0;
				}

				this.setBuffering(this.getBufferingPercentage());
			},


			// mute the video
			getDuration : function()
			{
				//debug("WMP:getDuration");
				return Math.ceil(WMPgetDuration());
			},


			// get the position (seconds)
			getPosition : function()
			{
				//debug("WMP:getPosition");
				return Math.ceil(WMPgetPosition());
			}

	    }
	    ,
	    {

			sniff: function()
			{
				debug("IE:sniff");

				// if we are using IE - then we assume that we can get the media player
				if (MetaWrap.Platform.MediaManager.SpecCheck.checkBrowser())
				{
					debug("Got IE");

					//return true;
					//debug("WMP:sniff");
					if (MetaWrap.Platform.MediaManager.SpecCheck.checkWMP())
					{

						debug("Got WMP");
						return true;
					}
				}
				else
				if (MetaWrap.Platform.MediaManager.SpecCheck.checkOS())
				{
					// lets assume that Firefox will get the correct plugin for us

					//debug("Use windows media player in firefox - no matter what");
					return true;
				}

				debug("failed to detect anything");

				// loop through each plugin and have a look
				for (var i = 0; i < navigator.plugins.length; i++)
				{
					debug(navigator.plugins[i].name);
					// Do we have the Flip4Mac plugin?
					if ((navigator.plugins[i].name.indexOf("Flip4Mac Windows Media Plugin")) != -1)
					{
						return true;
					}

					// Do we have the windows media firefox plugin?
					if ((navigator.plugins[i].name.indexOf("Windows Media Player Firefox Plugin")) != -1)
					{
						return true;
					}

				}

				return false;
			}

		}

    );


