function Ajax(){  // My constructor
	this.req=null;
	this.url=null;
    this.method='GET';
	this.async=true;
	this.status=null;
	this.statusText='';
	this.postData=null;
	this.readyState=null;
	this.responseText=null;
	this.responseXML=null;
	this.handleResp=null;
	this.responseFormat='text'; // could be XML or an OBJECT
	this.mimeType=null;
};

this.init = function() {
	//this class defines the properties needed in order to work with XMLHttprequest objects
    var i = 0;
    var reqTry = [ 
	// built-in java script XMLHttP request object
      function() { return new XMLHttpRequest(); },//try to create object for firefox, safari IE7,...
      function() { return new ActiveXObject('Msxml2.XMLHTTP') },//try to create object for later versions of IE
      function() { return new ActiveXObject('Microsoft.XMLHTTP' )} ];//try to create object for early versions of IE
      
    while (!this.req && (i < reqTry.length)) {
      try { 
        this.req = reqTry[i++]();
      } 
      catch(e) {}
    }
    return true;
};

this.doReq = function() { // My main request function....

	if ( !this.init() ){ 
		alert('Could not create XMLHttpRequest object\nAre you using a very old browser?');
		return;
	}
	try{
		this.req.open(this.method,this.url,this.async);
	}
	catch(e){
		alert(e);
	}
	if ( this.method == "POST" ){
		this.req.setRequestHeader('Content-Type',
								  'application/x-www-form-urlencoded');
	}
	var self = this;//this is to fix the loss of scope in inner function
	this.req.onreadystatechange = function(){
	//onreadystatechange property stores the function that will process the response from server
		if ( self.req.readyState == 4 ){
		//readyState property holds the status of the server's response
			switch (self.responseFormat){
				case 'text':
					resp = self.req.responseText;
					//responseText property retrieves the data sent back from the server
				break;
				case 'xml':
					resp = self.req.responseXML;
				break;
				case 'object':
					resp = req;
				break;
			}
			if ( self.req.status >= 200 && self.req.status <=299 ){ // Ok response is good
				self.handleResp(resp);
			} else{
				self.handleErr(resp);
			}
		}
	};
	this.req.send(this.postData);//send the request
};
this.handleErr = function(){//check to make sure that pop ups are not blocked
	var errorW;
	try{
		errorW=window.open('','errorW');
		errorW.document.body.innerHTML=this.responseText;
	}
	catch(e){
		alert('Please disable your popup blocker! ');
	}
}
this.abort = function () {//change onreadystate event handler to an empty functions
	if ( this.req ){
		this.req.onreadystatechange = function() {};
		this.req.abort();
		this.req=null;
	}
};
this.doGet = function(url,hand,format){
	
	//var randomnumber = Math.floor(Math.random()*1000001)
	//var file = 'ajaxfile.php?dummy=' + randomnumber;
	//xmlhttp.open('GET', file , true);
	
	this.url=url;
	this.handleResp=hand;
	this.method='GET';
	this.async=true;
	this.responseFormat = format || 'test';
	this.doReq();
};
this.doPost = function(url,postData,hand,format){
	this.url=url;
	this.handleResp=hand;
	this.method='POST';
	this.async=true;
	this.postData=postData;
	this.responseFormat = format || 'test';
	this.doReq();
}