﻿var http = null;
var httpBuffer = null;
var num=0;
function createXMLHTTPsocket()
{
   var xmlhttp=false;
   try
   {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch (e)
   {
      try
      {
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (E)
      {
         xmlhttp = false;
      }
   }
   if (!xmlhttp && typeof XMLHttpRequest!='undefined')
   {
      xmlhttp = new XMLHttpRequest();
   }
	   xmlhttp.onreadystatechange = ajaxCallback;


   return xmlhttp;
}

function ajaxCallback()
{
	if (http.readyState == 4) {
		//alert(http.responseText)
		
		start= http.responseText.indexOf('target=');
		stop= http.responseText.indexOf('>');
		target= http.responseText.substring(start+7,stop)
		document.getElementById(target).innerHTML= http.responseText;
	
		http = null;
		if (httpBuffer != null) {
    	 	ajax(httpBuffer[0]);
      		httpBuffer = null; 
	 }
	}
}

function ajax(doel)
{
	if (http != null) {
    	httpBuffer = new Object();
    	httpBuffer[0] = doel;
   	    return; 
	}
	
	
	var rightnow = new Date()
	http = createXMLHTTPsocket();
	if(doel.indexOf("?")==-1){
		com=doel + '?num=' + rightnow ;
	}
	else{
		com=doel + '&num=' + rightnow ;
	}
	http.open('get', com);
	http.send(null);

}


