// JavaScript Document
var loading     = false;
var currState   = "";

 function drawWMPlayer()
 {
       if(-1 != navigator.userAgent.indexOf("MSIE"))
      {
        document.write('<OBJECT id="wmPlyr"');
        document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
        document.write(' type="application/x-oleobject" width="553" height="400"> <PARAM name="uiMode" value="none"><PARAM name="enableContextMenu" value="false"></OBJECT>');
      }
      else if(-1 != navigator.userAgent.indexOf("Firefox"))
      {
        document.write('<OBJECT id="wmPlyr"'); 
        document.write(' type="application/x-ms-wmp"'); 
        document.write(' width="553" height="400"> <PARAM name="uiMode" value="none"> <PARAM name="enableContextMenu" value="false"></OBJECT>');
      }    
	  else
	  {
		 document.write('<OBJECT id="wmPlyr"'); 
         document.write(' type="application/x-ms-wmp"'); 
         document.write(' width="553" height="400"> <PARAM name="uiMode" value="none"> <PARAM name="enableContextMenu" value="false"></OBJECT>');  
	  }
}

function getWM()
{
	var winMediaObj = document.getElementById("wmPlyr");
	
	return winMediaObj;
	
}

function wmPlay()
{
	
	if(getWM().playState== 3)
	{
		if(getWM().controls.isAvailable('Pause'))
		{
			getWM().controls.pause();
		}
				
	}
	else
	{
		getWM().controls.play();
	}	
}
function wmStop()
{
		getWM().controls.stop();
}
function wmFScreen()
{
	if(getWM().playState== 3)
	{
		getWM().fullScreen = true;
	}
	else
	{
		alert("You can make it fullscreen on playing state only.");
	}
}

function wmMute()
{
	if(getWM().settings.mute)
	{
		getWM().settings.mute = false;
		document.getElementById('volicon').src = "images/vol.png";
	}
	else
	{
		getWM().settings.mute = true;
		document.getElementById('volicon').src = "images/vol_mute.png";
	}
}
function wmGetStatus()
{

  clipState = getWM().playState;
  var clipStateStr = "";
	 if(currState != clipState){
	
	  currState = clipState;
	  switch(clipState){
		  case 0:
		   clipStateStr = "Undefined";
		   break;
		  case 1:
		   clipStateStr = "Stopped";
		   break;
		  case 2:
		   clipStateStr = "Paused";
		   break;
		  case 3:
		   clipStateStr = "Playing";
		   break;
		  case 4:
		   clipStateStr = "Fast Forwarding...";
		   break;
		  case 5:
		   clipStateStr = "Fast Rewinding...";
		   break;
		   case 6:
		   clipStateStr = "Buffering...";
		   break;
		   case 7:
		   clipStateStr = "Waiting";
		   break;
		   case 8:
		   clipStateStr = "Media Ended...";
		   break;
		    case 9:
		   clipStateStr = "Transitioning...";
		   break;
		   case 10:
		   clipStateStr = "Ready...";
		   break;
		   case 11:
		   clipStateStr = "Reconnecting...";
		   break;
	  }
		document.getElementById('plyrState').innerHTML = clipStateStr;
	 }
	 
}
function getState(){
  var timer;
  wmGetStatus();
  loading=false;
  timer = setTimeout('wmSetStatus()',100);
}
function wmSetStatus(){
   if(!loading)
     getState();

 }
 
 function wmPlayerSet()
 {
		getWM().URL = playerURL;
		getWM().enabled = true;
		getWM().fullScreen = false;
		getWM().uiMode = 'none';
		getWM().settings.autoStart = true;
		getWM().settings.balance = 0;
		getWM().settings.mute = false;
		getWM().settings.playCount = 1;
		getWM().settings.volume = 50;
 }
 window.onload = function()
 {
	 wmPlayerSet();
	 getState();
 };
 
 function mouseRollOver(objID,objSrc)
 {
	 var rollObj = document.getElementById(objID);
	 
	 if(rollObj)
	 {
		rollObj.src = "images/" + objSrc; 
	 }
 }