/* AJAX Object */
/*
 (C) CopyRight 2007 Bill Frederickson, UNDER GPL Licence 2.0 or later
  All Code by Bill Frederickson, Based on ajax from w3schools.
  Used by permission.
  Usage of this script is permitted as long as copyright stays & is not modified other than by Bill Frederickson.
 This Library is Open source and belongs to no company, yet was developed by Bill Frederickson.
 This Library can be modified by anybody as long as it is documented & conforms to GPL v1 or later.
 This Library can be claimed by nobody other than Bill Frederickson.

*/
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();

