

	var http = getXMLHTTPRequest();
	var counter;

      function getXMLHTTPRequest() {
      try {
      req = new XMLHttpRequest();
      } catch(err1) {
        try {
        req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (err2) {
          try {
          req = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (err3) {
            req = false;
          }
        }
      }
      return req;
      }


      function getServerText() {
        var myurl = 'http://deeperintomusic.net/aj_TimeRemain.php'; // enter the full path to the aj_TimeRemain.php path
        myRand = parseInt(Math.random()*999999999999999);
        var modurl = myurl+"?rand="+myRand;
        http.open("GET", modurl, true);
        http.onreadystatechange = useHttpResponse;
        http.send(null);
      }

      function useHttpResponse() {
               if (http.readyState == 4) {
          if(http.status == 200) {
// parse data returned from aj_TimeRemain.php
var aj_results = http.responseText.split("|");

var aj_duration = aj_results[0];
var aj_secsremaining = aj_results[1];
var aj_title = aj_results[2];
var aj_artist = aj_results[3];
var aj_picture = aj_results[4];
var aj_url = aj_results[5];
var aj_isnew = aj_results[6];
var aj_rating = aj_results[7];
var aj_info = aj_results[8];
var aj_num_ratings = aj_results[9];
var aj_songID = aj_results[10];

var aj_queue = aj_results[11];

// update title and artist divs

document.getElementById('combine').innerHTML = "<p style=\"font-size:1.20em; padding-top:6px;\">Song: <a href='http://www.deeperintomusic.net/new-songinfo.php?songid=" + aj_songID + "' class='noline'>" + aj_title + "</a> | Artist: " +aj_artist  + aj_isnew + "</p>";
document.getElementById('picture').innerHTML = "<div style='margin: 0px 18px 10px 0px; float: left;border-style:outset; border-color: gray; border-width:2px; width:132px; height:132px;'><a href='http://www.deeperintomusic.net/new-songinfo.php?songid=" + aj_songID + "' class='noline'><img src=http://deeperintomusic.net/phpnuke2/pix/cdcovers/" + aj_picture +" width='130' height='130' class='noline' ></a></div>";
document.getElementById('rating').innerHTML = aj_rating + aj_num_ratings;
document.getElementById('info').innerHTML = aj_info + " <p>On Deck: <span style=\"font-weight:bold;\">" + aj_queue + "</span></p>";


//set seconds remaining to the countdown car - adding '-0' to convert to number

countDownInterval = aj_secsremaining - 0;
countDownTime = countDownInterval + 1;
countDown()
}
} else {
//document. getElementById('actual').innerHTML = "";
}
}


function countDown() {
countDownTime--;
if (countDownTime == 0) {
countDownTime = countDownInterval;
getServerText()
}
else if (countDownTime < 0)
countDownTime = 15;
if (document.all)
document.all.countDownText.innerText = secsToMins(countDownTime);
else if (document.getElementById)
document.getElementById("countDownText").innerHTML = "Next Song In: " + secsToMins(countDownTime);
stopCountDown();
counter = setTimeout("countDown()", 1000);
}

function secsToMins(theValue) {
var theMin = Math.floor(theValue / 60);
var theSec = (theValue % 60);
if (theSec < 10)
theSec = "0" + theSec;
return(theMin + ":" + theSec);
}

function stopCountDown()
{
clearTimeout(counter)
}

