function GetXmlLiveStatusHttpObject() {
  var xmlLiveStatusHttp=null;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlLiveStatusHttp=new XMLHttpRequest();
  }
  catch (e) {
    // Internet Explorer
    try {
      xmlLiveStatusHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      xmlLiveStatusHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlLiveStatusHttp;
}

function showLiveStatus() {
  xmlLiveStatusHttp=GetXmlLiveStatusHttpObject()
  url="/afl/footy/live_stats_status?sid=" + Math.random();
  fetchLiveStatus(xmlLiveStatusHttp, url);
}

function fetchLiveStatus(xmlLiveStatusHttp, url) {
  xmlLiveStatusHttp.onreadystatechange = liveStatusChanged;
  xmlLiveStatusHttp.open("GET", url, true);
  xmlLiveStatusHttp.send(null);
}

function liveStatusChanged() {
  if (xmlLiveStatusHttp.readyState==4) { 
  	response = xmlLiveStatusHttp.responseText;
  	if (response.indexOf("<!-- LIVE STATUS -->") < 0) {
  		response = "";
  	}
    document.getElementById("liveStatus").innerHTML=response;
  }
}
