/* AJAX Object */
//Header("content-type: application/x-javascript"); -- php
function AJAX(){
 this.xmlHttp = null;
 this.myData = "";
}
//================================================================================================
AJAX.prototype.GetXmlHttpObject = function(handler){ // Main AJAX Handler - get's Request.
 var objXMLHttp = null; // IE May be "Msxml2.XMLHTTP" as well
 objXMLHttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
 return objXMLHttp; 
}
//================================================================================================
AJAX.prototype.doAJAX = function(url,funct){ //note funct MUST be in QUOTES
 var f = "";
 if ((window.XMLHttpRequest || window.ActiveXObject) && url) {
  this.xmlHttp = this.GetXmlHttpObject();	
  if (funct) this.xmlHttp.onreadystatechange = eval(funct); // calls sub function if there is one.  
  //this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // for "Post" ??
  this.xmlHttp.open("POST",url,true);
  this.xmlHttp.send(null);
 } // end if
}
//
// Can't do any of the following functions without calling doAJAX or GetXmlHttpObject 1st.
//================================================================================================
AJAX.prototype.getData = function(){ // can use obj.getData() or obj.Data  :)
 var ajXpr = /(4)|(complete)/ig;
 if (ajXpr.test(this.xmlHttp.readyState)) {
  this.myData = (this.xmlHttp.responseText) ? this.xmlHttp.responseText : this.xmlHttp.responseXML;
  return this.myData;
 }
}
//================================================================================================
AJAX.prototype.readyState = function (){
 return (this.xmlHttp.readyState) ? this.xmlHttp.readyState : null;
}
//================================================================================================
AJAX.prototype.status = function (){
 return (this.xmlHttp.status) ? this.xmlHttp.status : null;
}
//================================================================================================
AJAX.prototype.statusText = function (){
 return (this.xmlHttp.statusText) ? this.xmlHttp.statusText : null;
}
//================================================================================================
AJAX.prototype.getHeaders = function (){
 return this.xmlHttp.getAllResponseHeaders();
}
//================================================================================================
AJAX.prototype.getHeader = function (iVal){
 return this.xmlHttp.getResponseHeader(iVal);
}
//================================================================================================
AJAX.prototype.cancel = function (){
 return this.xmlHttp.abort();
}
//================================================================================================
AJAX.prototype.abort = function (){
 return this.xmlHttp.abort();
}

var aj = new AJAX();
