function AjaxRequest()
{
	var self = this;

	this.reqHandler = null;
	this.response = null;

	/**
	 * Starts a new post ajax request.
	 */
	this.openPost = function(url, postData, async, callbackFunction) {
		url = fixAjaxURL(url);
		if (this.openXMLHttpRequest(callbackFunction)) {
			this.reqHandler.open('POST', url, async);
			this.reqHandler.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			this.reqHandler.send(postData);
			return true;
		}
		return false;
	}

	/**
	 * Starts a new get ajax request.
	 */
	this.openGet = function(url, async, callbackFunction) {
		url = fixAjaxURL(url);
		if (this.openXMLHttpRequest(callbackFunction)) {
			this.reqHandler.open('GET', url, async);
			this.reqHandler.send(null);
			return true;
		}
		return false;
	}

	/**
	 * Opens a new XMLHttpRequest.
	 */
	this.openXMLHttpRequest = function(callbackFunction) {
		if(this.reqHandler) {
			if (this.reqHandler.readyState != 0 && this.reqHandler.readyState != 4) {
				return false;
			}
		
			this.reqHandler.abort();
		}

		// Internet Explorer
		try {
			this.reqHandler = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e) {
			try {
				this.reqHandler = new ActiveXObject('Microsoft.XMLHTTP');
			} 
			catch (e) {
				this.reqHandler  = null;
			}
		}

		// Mozilla, Opera und Safari
		if (!this.reqHandler) {
			if (typeof XMLHttpRequest != 'undefined') {
				this.reqHandler = new XMLHttpRequest();
				if (this.reqHandler.overrideMimeType) {
					//this.reqHandler.overrideMimeType('text/xml; charset=UTF-8');
					this.reqHandler.overrideMimeType('text/xml; charset=ISO-8859-1');
				}
			}
			else {
				return false;
			}
		}

		// add event listener
		if (callbackFunction) {
			this.reqHandler.onreadystatechange = callbackFunction;
		}
		else {
			this.reqHandler.onreadystatechange = this.handleResponse;
		}

		return true;
	}

	/**
	 * Handles the response of the called script.
	 */
	this.handleResponse = function()
	{
		if(typeof this.readyState == "undefined") {
			if(self.reqHandler.readyState == 4) {
				if(self.reqHandler.status != 200) {
					// throw an exception
					alert('ajax request http error '+this.status);
				} else if(self.reqHandler.responseText != '') {
					// store response
					self.response = self.reqHandler.responseText;
				}
			}
			return;
		}

		if(this.readyState == 4) {
			if(this.status != 200) {
				// throw an exception
				alert('ajax request http error '+this.status);
			} else if(this.responseText != '') {
				// store response
				this.response = this.responseText;
			}
		}
		return;
	}

}
