function AjaxRequest(params) {
	this.params = params;	
	this.transport = null;
	this.responseDocument = null;
	//this.responseCode = 0;
	//this.responseText = null;
	this.url = null;
	this.onSuccess = function() {};
	this.onFailure = function() {};
	
	try {
		this.transport = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
		this.transport = new XMLHttpRequest();
	}
	
	AjaxRequest.prototype.onStateChange = function() { 
		if (this.transport.readyState == 4) {
			if (this.transport.status >= 200 && this.transport.status < 300) {
				// DEBUG
				//alert(this.transport.responseText);
				
				/*this.responseDocument = this.transport.responseXML.documentElement;
				this.responseCode = this.responseDocument.attributes.getNamedItem("code").value;
				this.responseText = this.responseDocument.attributes.getNamedItem("text").value;
				if (this.responseCode == null || this.responseCode != 200) {
					this.onFailure();		
				}
				else {
					this.onSuccess();
				}*/
				this.onSuccess();
			}
			else {
				this.responseText = "Chyba č. " + this.transport.status + " při komunikace se serverem.";
				this.onFailure();		
			}
		}
	};
	
	AjaxRequest.prototype.validate = function() { 
	};

	AjaxRequest.prototype.get = function(url) {
		// uncacher
		this.url = url;
		if (this.url.indexOf("?") >= 0) {
			this.url += "&";
		}
		else {
			this.url += "?";
		}
		this.url += "t=" + (new Date()).getTime();
		this.transport.onreadystatechange = delegate(this, this.onStateChange);
		this.transport.open("GET", this.url, true);
		this.transport.send(null);
	};

	AjaxRequest.prototype.post = function(url, data) {
		this.url = url;
		this.transport.onreadystatechange = delegate(this, this.onStateChange);
		this.transport.open("POST", url + "?t=" + (new Date()).getTime(), true);
		this.transport.send(data);
	};

}
