/*
 This set of AJAX functions tries to help shorten code.
  instead of always retyping the code in the AJAX() function when using AJAX, this set simplifies things by just defining the AJAX() function.

 You simply would define a tUrl & call AJAX(tUrl);
  or AJAX(tUrl,myFunction); 
  
  (c) 2007 (MMVII) Bill Frederickson, nerdz4.net
  Released under GPL Licence.
  IE is either ActiveXObject("Microsoft.XMLHTTP"); or ActiveXObject("Msxml2.XMLHTTP");
*/
var xmlHttp = null;
function GetXmlHttpObject(handler){ // Main AJAX Handler - get's Request.
 var objXMLHttp = null;
 objXMLHttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
 return objXMLHttp; 
}
//================================================================================================
function AJAX(url,funct){
 var outp = "";
 if ((window.XMLHttpRequest || window.ActiveXObject) && url) {
  xmlHttp = GetXmlHttpObject();	
  if (funct) xmlHttp.onreadystatechange = eval(funct); // calls sub function if there is one.  
  // xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // for "Post" ??
  xmlHttp.open("POST",url,true);
  xmlHttp.send(null);
  /*
   -- other methods:
   abort()
   getAllResponseHeaders()
   getResponseHeader("headerLabel")
   open("method", "URL"[, asyncFlag[, "userName"[, "password"]]])
   
   -- Properties
   responseText
   readyState
   responseText
   responseXML
   status
   statusText   
  */
 }	
}
//================================================================================================
 function rAJAX(){ //getAJAX
  var ajXpr = /(4)|(complete)/ig;
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
   return (xmlHttp.responseText) ? xmlHttp.responseText : xmlHttp.responseXML;
  }
 }
 //================================================================================================
 function xAJAX(){
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
   return xmlHttp.readyState;
  }
 }
//================================================================================================

/*

//Sample usage:
function somefunction(){
 tUrl = VIRTUALBASE+"/cgi-bin/getfiles.cgi?data="+data+"&docType="+docType+"&mode=list&user="+user+"&sid="+Math.random();
 AJAX(tUrl,NewFunction);
}

function NewFunction(){
 somevar = rAJAX();
 // do things..
} 
	
*/