var AJAX=new function()
{
 //GetXmlHttpObject taken from www.w3schools.com
 function GetXmlHttpObject()
 {
  var xmlHttp=null;
  try
  {
   // Firefox, Opera 8.0+, Safari
   xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
   // Internet Explorer
   try
   {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch (e)
   {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
  }
  return xmlHttp;
 }

 this.Request=function(script,type,vars)
 {
  var toRequest=GetXmlHttpObject();
  if(type != "GET" && type != "POST")
  {
   return;
  }
  var date=new Date();
  var timestamp=date.getTime();
  if(!vars.inp)
  {
   vars.inp="timestamp="+timestamp;
  }
  else
  {
   vars.inp+="&timestamp="+timestamp;
  }
  if(!vars.data)
  {
   vars.data="";
  }
  toRequest.onreadystatechange=function()
  {
   if(toRequest.readyState==4)
   {
    if(toRequest.responseText != "")
    {
     eval(toRequest.responseText);
    }
    if(vars.completedFunction)
    {
     var func=vars.completedFunction
     if(vars.completedVars)
     {
      func(vars.completedVars)
     }
     else
     {
      func();
     }
    }
   }
  }
  if(type == "GET")
  {
   toRequest.open("GET",script+"?"+vars.inp,true);
   toRequest.send(null);
  }
  else if (type == "POST")
  {
   toRequest.open("POST",script+"?"+vars.inp,true);
   toRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   toRequest.setRequestHeader("Context-length", vars.data.length);
//   toRequest.setRequestHeader("Connection", "close");
   toRequest.send(vars.data);
  }
 }
}()


