function XMLHttpRequestUtil()
{ 
	this.requestType = 'POST'; // GET, POST, PUT, or PROPFIND
	this.returnType = 'XML'; // XML or Text
	this.isAsync = true; // true for asynchronous request, false for synchronous
	this.xmlhttp = false; //init to false, will hold the XMLHttpRequest object
	this.callback = false; // the method that will be called when the request
	this.failedCallback = false; // assign this method that will be called if the request fails! (network drop, timeout of DB)
	

	// method to initialize an xmlhttpclient
	this.createHTTPRequestObject = function()
	{
		try { // Mozilla & Safari
			this.xmlhttp = new XMLHttpRequest();
		}
		catch (e) { // IE browsers
			var XMLHTTP_IDS = new Array('MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP');
			var success = false;
			for (var i=0;i < XMLHTTP_IDS.length && !success; i++) {
				try {
					this.xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);
					success = true;
				} catch (e) {}
			}
			if (!success) {
				alert('Unable to create XMLHttpRequest.');
			}
		}
	};
	
	// abort the XMLHttpRequest
	this.abort = function()
	{
		if (this.xmlhttp != false) {
			this.xmlhttp.abort();
		}
	};

	// method to make a page request
	// @param string url The page to make the request to
	// @param string payload What you're sending if this is a POST request
	this.makeRequest = function(url,payload)
	{
		if (!this.xmlhttp) {
			this.createHTTPRequestObject();
		}
		
		this.xmlhttp.open(this.requestType,url,this.isAsync);
		// set onreadystatechange here since it will be reset after a completed call in Mozilla
		var self = this;
		this.xmlhttp.onreadystatechange = function()
		{
			self.readyStateChangeCallback();
		}

		try{
		this.xmlhttp.send(payload);
		}
		catch(e) {}
	
		if (!this.isAsync) {
			if (this.returnType.toLowerCase() == 'xml')
					return this.xmlhttp.responseXML;
			else
				return this.xmlhttp.responseText;						
		}
	};

	// internal method used to handle ready state changes
	this.readyStateChangeCallback = function() {
		try // need this try for Mozilla, after aborting a request will return still, GR
		{
			switch(this.xmlhttp.readyState) {
				case 4:
					if (this.xmlhttp.status == 200) {
						if (this.returnType.toLowerCase() == 'xml')
							this.callback(this.xmlhttp.responseXML);
						else
							this.callback(this.xmlhttp.responseText);
					} else {
						if (this.failedCallback != false)
						{
							if (this.returnType.toLowerCase() == 'xml')
								this.failedCallback(this.xmlhttp.status);
							else
								this.failedCallback(this.xmlhttp.status);
						}
					}
				break;
			}
		}
		catch (e){}
	};
}