function Ajax(){
	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.responeXML		= null;
	this.handleResp		= null;
	this.responseFormat	= 'text'; 	// text, xml or object
	this.mimeType		= null;

	// creates an XMLHttpRequest object
	this.init	= function(){
		if( !this.req ){
			try {
				// try to create object for Firefox, Safari, IE7, etc
				this.req	= new XMLHttpRequest();
			} 
			catch(e) {
				try {
					// try to create obj for later versions of IE
					this.req	= new ActiveXObject('MSXML2.XMLHTTP');

				} 
				catch(e) {
					try {
						// try for early IE versions
						this.req	= new ActiveXObject('Microsoft.XMLHTTP');
					} 
					catch(e) {
						// no dice
						return false;
					}
				}
			}
		}
	return this.req;
	};
	// executes an ajax request
	this.doReq	= function(){
		if( !this.init() ){
			// init failed, output an error
			alert('Couldn\'t create XMLHttpRequest object.');
			return;
		}
		this.req.open(this.method, this.url, this.async);
		if( this.mimeType ){
			try {
				req.overrideMimeType(this.mimeType);
			} catch(e) {
				// couldn't override mimetype, 
				// browser must be IE6 or opera
			}
		}
		var self	= this;
		if( this.method == "POST" ){
			this.req.setRequestHandler("Content-Type", "application/x-www-form-urlencoded");
		}
		this.req.onreadystatechange	= function(){
			var resp = null;
			if( self.req.readyState == 4 ){
				switch( self.responseFormat ){
					case 'text':	
						resp	= self.req.responseText;
						break;
					case 'xml':
						resp	= self.req.responseXML;
						break;
					case 'object':
						resp 	= req;
						break;
				}
				// 200->299 are good responses, anything else (404, 500, etc) are errors
				if( self.req.status >= 200 && self.req.status <= 299 ){
					self.handleResp(resp);
				} else {
					self.handleError(resp);
				}
			}
			
		};
		this.req.send(this.postData);
	};
	// sets the mimeType 
	this.setMimeType	= function(mimeType){
		this.mimeType	= mimeType;
	};
	// tries to output an error message about the error
	// that occurred.
	this.handleErr		= function(){
		var errorWin;
		try {
			errorWin	= window.open('', 'errorWin');
			errorWin.document.body.innerHTML	= this.responseText;
		} catch(e) {
			alert('An error occured, but the error message can\'t be '
				+ 'display. This is probably because of your browser\'s '
				+ 'pop-up blocker.\n '
				+ 'Status Code: '+ this.req.status + '\n'
				+ 'Status Description: ' + this.req.statusText);
		}
	};
	// overrides the default errorHandler
	this.setHandlerErr	= function(funcRef){
		this.handleErr	= funcRef;
	};
	// overrides both handlers
	this.setHandlerBoth	= function(funcRef){
		this.handleResp	= funcRef;
		this.handleErr	= funcRef;
	};
	// aborts a request entirely
	this.abort		= function(){
		if( this.req ){
			this.req.onreadystatechanged	= null;
			this.req.abort();
			this.req			= null;
		}
	};
	// a wrapper around all the work
	this.doGet		= function(url, hand, format){
		this.url	= url;
		this.handleResp	= hand;
		this.responseFormat	= format || 'text';
		this.doReq();
	};
	// use doPost if you need to either:
	// send a large amount of data back to the server
	// the data needs to be formatted in a very specific way ( eg: XML-RPC)
	// your sending sensitive data such as passwords
	this.doPost			= function(url, postData, hand, format) {
		this.url		= url;
		this.handleResp		= hand;
		this.responseFormat	= format || "text";
		this.method		= "POST";
		this.postData		= postData;
		this.doReq();
	};
// end of class
};

