var http = createRequestObject();

function createRequestObject() {
  var objXMLHttp=null
  if (window.XMLHttpRequest) { // Mozilla, recent IE, others
  objXMLHttp=new XMLHttpRequest()
  }
  else if (window.ActiveXObject) { // IE 5, 6
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
  return objXMLHttp 
}

function getCount(){
  queryString="?" + Math.random();

  // Send request off to server, get ready for reply
  url='cgi-bin/counter.cgi' + queryString;
  http.open('GET',url,true);
  http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http.onreadystatechange = updateNewContent;
  http.send(null);

  return false;
}

function updateNewContent(){
  if(http.readyState == 4){
    document.getElementById('hitcounter').innerHTML = http.responseText;
  }
}

