// JavaScript Document
var xmlHttp;

function getMediaUrl()
{ 
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request");
    return;
  }

  var url="/lib/secure_event.php";
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}


function stateChanged() 
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
    var resStr = xmlHttp.responseText;
    //var resArr = resStr.split(",");
	if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1 ) 
	{
		document.getElementById("MediaPlayer").src=resStr;
		document.getElementById("MediaPlayer").src=resStr;
	}
	else
	{
		document.getElementById("MediaPlayer").url=resStr;
	}
	//document.getElementById("testing").innerHTML=resStr;
  } 
}

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    //Internet Explorer
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}

var countDownSeconds = 0;
var countDownContainer = 0;

function ActivateCountDown(containerID, initialValue) {
	countDownContainer = document.getElementById(containerID);
	countDownSeconds = initialValue;
	
	SetCountDownText(initialValue);
	window.setTimeout("CountDownTick()", 1000);
}

function CountDownTick() {
	if (countDownSeconds > 0) {
		countDownSeconds = countDownSeconds - 1;
	}
	SetCountDownText(countDownSeconds);
	window.setTimeout("CountDownTick()", 1000);
}

function SetCountDownText(seconds) {
	var minutes = parseInt(seconds/60);
	seconds = (seconds%60);
	
	var hours = parseInt(minutes/60);
	minutes = (minutest%60);
	
	var strText = AddZero(hours) + ":" + AddZero(minutes) + ":" + AddZero(seconds);
	
	countDownContainer.innerHTML = strText;
}

function AddZero(num) {
	return ((num >=0) && (num < 10)) ? "0"+num:num+"";
}
