// JavaScript Document

function ajax(anim){
this.req=null;
this.url='';
this.method='';
this.async='';
this.ie=true;
this.readyState='';
this.handleResp=null;
this.status='';
this.statusText='';
this.respText='';
this.respFormat='text';
this.completed=false;
this.animate=anim;
this.init=function(){
try{this.req=new XMLHttpRequest; this.ie=false;
   }catch(e){
			try{this.req=new ActiveXObject("Msxml2.XMLHTTP");
			   }catch(e){
						try{this.req=new ActiveXobject("Microsoft.XMLHTTP");
						   }catch(failed){this.req=false;
										 }
						}
			}			
return this.req;
};

this.doReq=function(url,hand,async){
var self=null;
self=this;// Fix loss-of-scope in inner function
if(!this.init()){
alert('Failed to initialize XMLHttpRequest');
return;
}
//alert(this.req);
this.method='GET';
this.url=url;
this.handleResp=hand;
this.async=async;
this.req.open(this.method,this.url,this.async);
//alert(this.req.readyState);
//if(this.ie){

if (typeof window.ActiveXObject != 'undefined' ){
this.req.onreadystatechange=function(){

      self.readyState = self.req.readyState;
      if (self.req.readyState == 4) {
        
        // Make these properties available to the Ajax object
        self.status = self.req.status;
        self.statusText = self.req.statusText;
        self.respText = self.req.responseText;
        //self.responseXML = req.responseXML;
        
        // Request is successful -- pass off to response handler
        if (self.status > 199 && self.status < 300) {
           // Make sure handler is defined
              if (!self.handleResp) {
                //alert('No response handler defined ' +'for this XMLHttpRequest object.');
                return;
              }
              else {
               
				self.handleResp(self.respText);
              }
          
        }
         	
      }
};    
    // Send the request, along with any data for POSTing
    // ==========================
/*this.req.send(null);
};*/
}
else
{
	this.req.onload=function(){
	  //alert('in onload');
      self.readyState = self.req.readyState;
      if (self.req.readyState == 4) {
        
        // Make these properties available to the Ajax object
        self.status = self.req.status;
        self.statusText = self.req.statusText;
        self.respText = self.req.responseText;
        //self.responseXML = req.responseXML;
        
        // Request is successful -- pass off to response handler
        if (self.status > 199 && self.status < 300) {
           // Make sure handler is defined
              if (!self.handleResp) {
                /*alert('No response handler defined ' +
                  'for this XMLHttpRequest object.');*/
                return;
              }
              else {
               
				self.handleResp(self.respText);
              }
          
        }
         	
      }
};    
   // Send the request, along with any data for POSTing
   // ==========================
}	
this.req.send(null);
};



this.abort = function() {
    if (this.req) {
      this.req.onreadystatechange = function() { };
      this.req.abort();
      this.req = null;
    }
};
  
} //end of ajax class  




