function AjaxRequest(options) { /* Deprecated, please use Ajax.js for new projects */
	options = options || {};
	this.method = options.method || "GET";
	this.url = options.url || window.location.href;
	this.requestHeaders = options.requestHeaders || {};
	this.onSuccess = options.onSuccess;
	this.onFailure = options.onFailure;
	this.onComplete = options.onComplete;
	this.synchronous = options.synchronous;
	this.thisObject = options.thisObject || window;
	this.contents = options.contents;

	if (this.contents && typeof this.contents !== "string") {
		var params=[];
		for (var p in this.contents) {
			if (options.contents.hasOwnProperty(p)) {
				var value = options.contents[p];
				if (Object.prototype.toString.apply(value) === '[object Array]') {
					/* Assume array to be rolled out as param=val1&param=val2...
					 * The array detection technique is described here:
					 * http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=916 */
					for (var i=0 ; i<value.length ; i++) {
						params.push(encodeURIComponent(p)+"="+encodeURIComponent(value[i]));
					}
				}else{
					params.push(encodeURIComponent(p)+"="+encodeURIComponent(value));
				}
			}
		}
		this.requestBody = params.join("&");
		if (this.method.toUpperCase() !== 'GET') {
			if (!this.requestHeaders['Content-Type']) {
				this.requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
			}
		}
	}else{
		this.requestBody = this.contents;
	}

	if (this.requestBody && this.method.toUpperCase() === 'GET') {
		this.url += (this.url.indexOf("?")>-1 ? "&" : "?") + this.requestBody;
		this.requestBody = null;
	}
}

AjaxRequest.prototype = {
	handleResponse: function() {
		var status;
		try {
			status = this.xmlhttprequest.status; /* Fails if the request was interrupted, e.g. by the stop button */
		}catch(e) {
			status = null;
		}
		if (status === 200 || status === 304 || (BO.safari && typeof(status) === "undefined")) {
			if (this.onSuccess) {
				this.onSuccess.call(this.thisObject, this);
			}
		}else if (this.onFailure) {
			this.onFailure.call(this.thisObject, this);
		}
		if (this.onComplete) {
			this.onComplete.call(this.thisObject, this);
		}
		this.xmlhttprequest = null; /* Avoid IE leaks */
	},

	execute : function() {
		try {
			this.xmlhttprequest = new XMLHttpRequest();
		}catch (e) {
			try {
				this.xmlhttprequest = new ActiveXObject('Microsoft.XMLHTTP');
			}catch (e) {
				return null;
			}
		}

		this.xmlhttprequest.open(this.method, this.url, !this.synchronous);

		for (var header in this.requestHeaders) {
			if (this.requestHeaders.hasOwnProperty(header)) {
				this.xmlhttprequest.setRequestHeader(header, this.requestHeaders[header]);
			}
		}

		if (this.synchronous) {
			this.xmlhttprequest.send(this.requestBody);
			this.handleResponse();
		}else{
			var This=this;
			this.xmlhttprequest.onreadystatechange = function() {
				if (This.xmlhttprequest && This.xmlhttprequest.readyState === 4) {
					This.handleResponse();
				}
			};
			this.xmlhttprequest.send(this.requestBody);
		}
		return this;
	}
};
