function Ajax(url, callback_function, return_xml ){
		
	this.req = null;
	
	this.url = null;
	
	this.method = 'GET';
	
	this.async = true;
	
	this.status = null;
	
	this.statusText = '';
	
	this.showError = false; //if an error happens either, show the message displayed from the default error class, or don't don't
	
	this.postData = null; //If the request is a post then this will be set
	
	this.readyState = null; //Changes during life of the GET or POST request
	
	this.responseText = null; //Text Return value if the request was successfull
	
	this.responseXML = null; //XML Return value if the request was successful
	
	this.handleResp = null; // callback function-handler that handles the response
	
	this.handleRespErr = null; //custom callback function-handler 
	
	this.responseFormat = 'text', // 'text', 'xml', or 'object'
	
	this.mimeType = null; //default mime type

	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 object for later versions of IE.
					this.req = new ActiveXObject('MSXML2.XMLHTTP');
			
				} catch (e) {
			
					try {
						
						// Try to create object for early versions of IE.
						this.req = new ActiveXObject('Microsoft.XMLHTTP');
					
					} catch (e) {
						
						// Could not create an XMLHttpRequest object.
						return false;
					
					}
				
				}
			
			}
	
		}
		
		return this.req;
	
	};
    //ACTS AS AN INTERFACE BETWEEN THE APP AND "doReq" FUNCTION. THE APP CALLS THIS WHEN IT WANTS TO USE HTML GET
	this.doGet = function( url, hand, format ) {
		
		this.url = url;
		
		this.handleResp = hand;
		
		this.responseFormat = format || 'text';
		
		this.doReq();
	
	};

    //ACTS AS AN INTERFACE BETWEEN THE APP AND "doReq" FUNCTION. THE APP CALLS THIS WHEN IT WANTS TO USE HTML POST
    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();
	
	};

    this.doReq = function() {
		
		if( !this.init() ) {
			
			alert('Could not create XMLHttpRequest object.');
	   
		    return;
			
		}
		
		this.req.open( this.method, this.url, this.async );

		if (this.method == "POST") {
		
    		this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		}

        if (this.mimeType) {
			
			try {
			
			    this.req.overrideMimeType(this.mimeType);
			
			} catch (e) {
			
			// couldn't override MIME type -- IE6 or Opera?
			
			}
		
		}

        var self = this; // Fix loss-of-scope in inner function

		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;
	
				}
				
				//NO ERROR
				if( self.req.status >= 200 && self.req.status <= 299 ) {
				    
					self.handleResp( resp );
				
				//CUSTOM ERROR FUNCTION USED
				} else if( self.handleRespErr ){
					
					self.handleRespErr(resp);
				
				//USE DEFAULT ERROR HANDLER OF THE AJAX CLASS IF "showError" IS TRUE
				} else {
					
					if( self.showError ){
					
	    				self.handleErr(resp);
					
					}
				
				}
			
			}
	
		};	
	
		this.req.send(this.postData);

	}

	this.handleErr = function() {
		
		var errorWin;
		
		try {
		
			errorWin = window.open('', 'errorWin');
			
			errorWin.document.body.innerHTML = this.responseText;
			
		} catch (e) {
		
			alert('An error occurred, but the error message cannot be '
			+ 'displayed. This is probably because of your browser\'s '
			+ 'pop-up blocker.\n'
			+ 'Please allow pop-ups from this web site if you want to '
			+ 'see the full error messages.\n'
			+ '\n'
			+ 'Status Code: ' + this.req.status + '\n'
			+ 'Status Description: ' + this.req.statusText);
		
		}
	
	};

	this.abort = function() {
		
		if ( this.req ) {
			
			this.req.onreadystatechange = function() { };
			
			this.req.abort();
			
			this.req = null;
		
		}
	
	};

}

