
	var Player;
        if ( document.getElementById('WMP') )
        { Player = document.getElementById ('WMP'); }
        else
        { Player = document.getElementById('FF'); }
        
	var curStatus = "Not Playing";
	var theButton;
	var theTimer;
	var theStatus;
	var theTitle;
	
	var psStopped = 1;
	var psPaused = 2;
	var psPlaying = 3;
	var psFF = 4;
	var psREW = 5;
	var psBuffering = 6;
	var psWaiting = 7;
	var psMediaEnded = 8;
	var psReady = 10;
	var psReconnect = 11;
	
	function stopFile ()
	{
		Player.controls.stop();
		theButton.src = "../images/play16.gif";
		theStatus.innerHTML = theTitle + ' (stopped)';
		window.clearInterval (theTimer);
		theButton.title = "Play";
	}
	function playFile ( o, uri, title )
	{
		var ps = Player.playState;
		if (theButton != o)
		{
			if (theButton)
			{
				// we have a pre-existing button
				stopFile(); //stop playback
			}
			theButton = o;
			Player.URL = uri;

			theButton.src = "../images/loading.gif";
			theButton.title = "Loading";
			if ( document.getElementById('WMP') )
			{
				theStatus = o.parentNode.nextSibling.nextSibling.nextSibling;
			}
			else
			{
				theStatus = o.parentNode.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling;
			}
			
			theTitle = title;
			theTimer = window.setInterval( 'checkStatus();', 250 );
		}
		else
		{
			if (ps == psPlaying)
			{
				Player.controls.pause();
			}
			else
			{
				Player.controls.play();
			}
		}
	  
	}
	function volumeUp ()
	{
		Player.settings.volume = Player.settings.volume + 10;
	}
	function volumeDown ()
	{
		Player.settings.volume = Player.settings.volume - 10;
	}
	function volumeMute ()
	{
		if (Player.settings.mute==true)
		{
			Player.settings.mute=false;
		}
		else
		{
			Player.settings.mute=true;
		}
	}

	function checkStatus ()
	{
	  try
	  {
		var plstat = "";
		if (Player.playState)
		{
			switch ( Player.playState)
			{
				case psStopped:
				case psMediaEnded:
					window.clearInterval (theTimer);
		    		theButton.src = "../images/play16.gif";
		    		theButton.title = "Play";
					theStatus.innerHTML = theTitle + ' (stopped)';
					theButton = null;
					return;
					break;
				//case psReady:
			    case psPaused:
			    		theButton.src = "../images/play16.gif";
			    		theButton.title = "Play";
			    		break;
			    case psPlaying:
						theButton.src = "../images/pause16.gif";
						theButton.title = "Pause";
						break;
				default:
						if (theButton.title != "Loading") 
						{ theButton.src = "../images/loading.gif";
						theButton.title = "Loading"; }
			}

			plstat = String(Player.status);
			if (plstat.indexOf (' ') != -1) {
				plstat = plstat.substring( 0, plstat.indexOf (' '));
			} 
			mute = '';
			if (Player.settings)
			{
				if (Player.settings.mute == true)
				{
					mute = "; Muted";
				} 
			}
			
			try
			{
			theStatus.innerHTML = theTitle + ' (' + plstat + ' ' +  Player.controls.currentPositionString + '/' + Player.currentMedia.durationString + ';' + 
			                                 ' Volume:' + Player.settings.volume + mute + ')';
			}
			catch (e)
			{
				theStatus.innerHTML = theTitle;
			}
		}
		else
		{
					theButton.src = "../images/pause16.gif";
					theButton.title = "Pause";
		}
	  }
	  catch (e)
	  {
					theButton.src = "../images/pause16.gif";
					theButton.title = "Pause";
	  }
	}
