function onLoad(sender, args)
{
	updater(sender);
}

function ppOva(sender, args)
{
	sender.findName("pp").Opacity = 1;
}

function ppOut(sender, args)
{
	sender.findName("pp").Opacity = 0;
}

function ppToggle(sender, args)
{
	if (theVideo == null)
	{
		theVideo = sender.findName("thevideo");
	}
	if (theVideo != null)
	{
		if(theVideo.currentState != "Paused") 
		{
			theVideo.pause();
			sender.findName("play").Opacity = 1;
			sender.findName("pause").Opacity = 0;
		}
		else 
		{
			theVideo.play();
			sender.findName("play").Opacity = 0;
			sender.findName("pause").Opacity = 1;
		}
	}
	/*
	if(sender.findName("play").Opacity == 1)
	{
		sender.findName("thevideo").play();
		sender.findName("play").Opacity = 0;
		sender.findName("pause").Opacity = 1;
	}
	else
	{
		sender.findName("thevideo").pause();
		sender.findName("play").Opacity = 1;
		sender.findName("pause").Opacity = 0;
	}
	*/
}

function muteOva(sender, args)
{
	sender.findName("mt").Opacity = 1;
}

function muteOut(sender, args)
{
	sender.findName("mt").Opacity = 0;
}

function mute(sender, args)
{
	if(sender.findName("mr").Opacity == 1)
	{
		var host = document.getElementById("SESilverlightControl");
		host.findName("thevideo").Volume = 0;
		sender.findName("mr").Opacity = 0;
		sender.findName("ac1").Opacity = 1;
		sender.findName("ac2").Opacity = 1;
	}
	else
	{
		var host = document.getElementById("SESilverlightControl");
		host.findName("thevideo").Volume = 100;
		sender.findName("mr").Opacity = 1;
		sender.findName("ac1").Opacity = 0;
		sender.findName("ac2").Opacity = 0;
	}
}

function rewOva(sender, args)
{
	sender.findName("rew").Opacity = 1;
}

function rewOut(sender, args)
{
	sender.findName("rew").Opacity = 0;
}

function rewind(sender, args)
{
	//var host = document.getElementById("SESilverlightControl");
	sender.findName("thevideo").stop();
	sender.findName("thevideo").play();
}

function getTimecode(theTime)
{
  var t = Math.round(theTime);
  var min = Math.floor(t/60);
  var sec = t%60;
  var s = "";
  if(min < 10) {
     s += "0";
  }
  if(min >= 1) {
     s += min;
  }
  else {
     s += "0";
  }
  s += ":";
  if(sec < 10) {
     s += "0";
     s += sec;
  }
  else {
     s += sec;
  }
  return s;
} 

var theVideo = null;
var theLoader = null;
var theProgress = null;
var playButton = null;
var pauseButton = null;


function updater(sender)
{
	var host = document.getElementById("SESilverlightControl");
	
	if (sender != null)
	{
		theVideo = sender.findName("thevideo");
		theLoader = sender.findName("loader");
		theProgress = sender.findName("progress");
		playButton = sender.findName("play");
		pauseButton = sender.findName("pause");
	}
	
	if (theVideo != null)
	{
		if (theLoader != null)
		{
			theLoader.width = theVideo.downloadProgress * 170;
		}
		if (theVideo.naturalDuration != null)
		{
			if (theProgress != null)
			{
				theProgress.width = (theVideo.position.seconds / theVideo.naturalDuration.seconds) * 170;
			}
		
			if(theVideo.position.seconds == theVideo.naturalDuration.seconds)
			{
				theVideo.position = "00:00:00";
				theVideo.pause();
				playButton.Opacity = 1;
				pauseButton.Opacity = 0;
			}
		}
	
	}
	
	setTimeout("updater()", 100);
}
