// JavaScript Document
var xmlHttp = createXmlHttpRequestObject(); 
function createXmlHttpRequestObject() 
{	
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  if (!xmlHttp)
  alert("Error creating the XMLHttpRequest object.");
  else 
  return xmlHttp;
}

function recordvisits(str)
{
  
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    xmlHttp.open("GET", "record_visits.php?bid="+str+"&sid="+Math.random(), true);  
    xmlHttp.onreadystatechange = handleServerResponse;
    xmlHttp.send(null);
  }
}
function handleServerResponse() 
{
  if (xmlHttp.readyState == 4) 
  { 
    if (xmlHttp.status == 200) 
     {
		 xmlResponse = xmlHttp.responseText;
		 document.getElementById("divMessage").innerHTML='';
	     document.getElementById("divMessage").innerHTML =xmlHttp.responseText;
    } 
    else 
    {
		alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}
