function get_XMLObject()  //XML OBJECT
{
   var xmlHttp = false;
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   }
   catch (e) {
     try {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
     }
     catch (e2) {
       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
     }
   }
   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   }
   return xmlHttp;  // Mandatory Statement returning the ajax object created
}
	 
	var xmlhttpStats = new get_XMLObject();	//xmlhttpStats holds the ajax object

	function stats(page) {
	  var getdate = new Date();  //Used to prevent caching during ajax call
	  if(xmlhttpStats) 
			{ 
		    xmlhttpStats.open("POST","php/access_stats.php",true); //calling testing.php using POST method
		    xmlhttpStats.onreadystatechange  = handleServerResponseStats;
		    xmlhttpStats.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		    
		    variable = 	"page=" + page;
		    
		    xmlhttpStats.send(variable); //Posting variables to PHP File
	  	}
	}
		
function handleServerResponseStats() {
   if (xmlhttpStats.readyState == 4) {
     if(xmlhttpStats.status == 200) {
       document.getElementById("message").value=xmlhttpStats.responseText; //Update the HTML Form element 
     }
     else {
        alert("Error during AJAX call. Please try again");
     }
   }
}
