var xmlhttp;
var minofhour;
var nowPlayingTimer;

function loadXMLDoc(url)
{
if (location.host == "www.ksmu.org")
  { url1 = "http://www.ksmu.org" + url;
  }
else 
  { url1 = "http://ksmu.org" + url;
  }

xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Opera, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.open("GET",url1,false);
  xmlhttp.send(null);
  //document.getElementById('A1').innerHTML=xmlhttp.status;
  //document.getElementById('A2').innerHTML=xmlhttp.statusText;
  document.getElementById('whatson').innerHTML=xmlhttp.responseText;
  //alert(xmlhttp.responseText);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }

//alert("In the load xml function");
}

function checkNowPlaying(streamnum)
{
   var d = new Date();
   minofhour = d.getMinutes();
   //minofhour = 2;
   if ((minofhour==2)||(minofhour==32))
   {
      loadXMLDoc('/extras/whatsonv2.php?type=ext&stream='+streamnum);
      //alert("Checked the url");
   }
   //alert("Entered checkNowPlaying() at minute " + minofhour);
   nowPlayingTimer = setTimeout("checkNowPlaying(" + streamnum + ");",18000);
}

function stopCheckingNP()
{
   clearTimeout(nowPlayingTimer);
}
