// global variable declarations
var bolIsPlaying, sDuration, sVideoTitle;
var intVolumeBarState=4;
var idVideoClockTimer;

var arVol_on = new Array(10);
var arVol_off = new Array(10);
function InitVideo(){
	for (i = 1 ; i <= 10 ; i++){
		arVol_on[i-1] = new Image();
		arVol_on[i-1].src = "images/vol" + i + "_on.gif";	
		arVol_off[i-1] = new Image();
		arVol_off[i-1].src = "images/vol" + i + "_off.gif";	
	}
	idVideoClockTimer = window.setInterval("videoClock()", 200); // This statement instantiates an interval timer, called twice a second. This calls the function intervalCalls() which is used to update the video clock and bandwidth text as the video is playing.
WMPlayer.filename = sVideoURL;
}


function clipInfo()
{
	var strTitle;
	var strAuthor;
	var strCopyright;

	// Media Player queries
	strTitle = objMediaPlayer.GetMediaInfoString(1);
	strAuthor = objMediaPlayer.GetMediaInfoString(2);
	strCopyright = objMediaPlayer.GetMediaInfoString(3);

	// Set to "none" if return value is null
	if(strTitle == "")
		strTitle="none";
	if(strAuthor == "")
		strAuthor="none";
	if(strCopyright == "")
		strCopyright="none";

}
function CreateVolButtons()
{
	var sHTML = "";
	for (i = 1 ; i <= 10 ; i++){
		sHTML += "<a style=\"cursor:hand\" onclick=\"SetVolume(" + i + ");\"><img border=0 id=\"vol" + i + "\" src=\"images/vol" + i + "_on.gif\" ></a>";
	}
	document.write(sHTML);
}
function Pause()
{  
   	  // if stream is not stopped
	  if(WMPlayer.PlayState != 0)
		  WMPlayer.pause();
}

function SetVolume(nVol)
{
var intVolume;
	if ( isNaN(nVol) ) return;
	for (i = 1 ; i <= 10 ; i++){
		document.getElementById("vol" + i  ).src =  (nVol >= i) ? "images/vol" + i + "_on.gif" : "images/vol" + i + "_off.gif";
	}
	intVolume=((nVol-10)*250);
	WMPlayer.Volume=intVolume;
	if (WMPlayer.Mute) ToggleMute();
//	WMPlayer.Volume = nVol;
}

function PauseVideo()
{  
   	  // if stream is not stopped
	  if(WMPlayer.PlayState != 0)
		  WMPlayer.pause();
}

function PlayVideo ()
{
	WMPlayer.play();
	//If video size breaks up page, always start playing in fullscreenmode...
//	if (WMPlayer.ImageSourceWidth > 386)  {
//		WMPlayer.DisplaySize=3;
//	}
	
}
function StopVideo ()
{
    WMPlayer.stop();
}
function ToggleMute()
{
	var objImg = document.getElementById("btn_mute");
	WMPlayer.Mute = (!WMPlayer.Mute)
	objImg.src = WMPlayer.Mute ? "images/btn_muted.gif": "images/btn_unmuted.gif";
}

function SetTitle()
{
	sVideoTitle = WMPlayer.GetMediaInfoString(8);
}
function SetDurationString(dblTime)
{
	sDuration = " / " + GetFormattedTimingString(dblTime);
}

function GetFormattedTimingString(dblTime)
{
	var intMinutes;
	var intSeconds;
	var strMinutes="00";
	var strSeconds="00";
	var strTime;
	
	dblTime=Math.floor(dblTime); // round down to the nearest integer
//	intHours=Math.floor(intTimeElapsed/3600); // get hours (3600 seconds / hour)
	intMinutes=Math.floor(dblTime/60); // get minutes (60 seconds / minite)
	intSeconds=(dblTime%60); // get seconds (total seconds modulous 60)

//	strHours=intHours;
	strMinutes=intMinutes;
	strSeconds=intSeconds;

	// insert zeros in front of time elapsed where necissary ( < 10 ) to preserve hh:mm:ss format
	if (intSeconds < 10)
		strSeconds="0" + strSeconds;
	if (intMinutes < 10)
		strMinutes="0" + strMinutes;
//	if (intHours < 10)
//		strHours="0" + strHours;
	return /* strHours + ":" + */ strMinutes + ":" + strSeconds; // create time string
	
}
function videoClock()
{

	var intTimeRemaining;
	var intMinutes;
	var intSeconds;
//	var intHours;

	var strMinutes="00";
	var strSeconds="00";
	var strTime;
	if ((bolIsPlaying) && (WMPlayer.BufferingProgress == 100)) // check to make sure video is playing and the Media player is not buffering
		{
		intTimeElapsed=WMPlayer.CurrentPosition; // get the time elapsed

		// Calculations to convert from seconds into standard 0:00:00 time format
		intTimeElapsed=Math.floor(intTimeElapsed); // round down to the nearest integer
//		intHours=Math.floor(intTimeElapsed/3600); // get hours (3600 seconds / hour)
		intMinutes=Math.floor(intTimeElapsed/60); // get minutes (60 seconds / minite)
		intSeconds=(intTimeElapsed%60); // get seconds (total seconds modulous 60)

//		strHours=intHours;
		strMinutes=intMinutes;
		strSeconds=intSeconds;

		// insert zeros in front of time elapsed where necissary ( < 10 ) to preserve hh:mm:ss format
		if (intSeconds < 10)
			strSeconds="0" + strSeconds;
		if (intMinutes < 10)
			strMinutes="0" + strMinutes;
//		if (intHours < 10)
//			strHours="0" + strHours;

		strTime= /* strHours + ":" + */ strMinutes + ":" + strSeconds; // create time string

		document.getElementById("videoStatus").innerText = strTime + sDuration + " " + sVideoTitle;
//		divVideoClock.=strTime; // update clock div
		}
		else{
			document.getElementById("videoStatus").innerText = "Buffering... " + WMPlayer.BufferingProgress + "%";
		}
}