function CHttpRequest(){
	
	if(!self.__Requests){
		self.__Requests = new Array();
		if(self.attachEvent)
			self.attachEvent('onunload', __ClearRequestArray);
		else if(self.addEventListener)
			self.addEventListener('onunload', __ClearRequestArray, false);
	}
	this.HostAddress = "index.php?";
	this.AssyncCall = true;
	this.arProperties = new Array();
	this.QueryString = "";
	this.OnResponse = "";
	this.Debug = false;
	//this._currentRequest = null;
	
	this.AddProperty = function(PropertyName, PropertyValue){
		var arProperty = new Array();
		arProperty["PropertyName"] = PropertyName;
		arProperty["PropertyValue"] = PropertyValue;
		this.arProperties.push(arProperty);
	}

	this.Send = function(){
	    
		var currentRequest = null;
		try {
			currentRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				currentRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return;
			}
		}

		currentRequest.open('POST', this.HostAddress, this.AssyncCall);
		currentRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

		var savedIndex = null;
		for(var i = 0; i < self.__Requests.length; i++){
			if(self.__Requests[i].readyState == 4){
				self.__Requests[i] = currentRequest;
				savedIndex= i;
				break;
			}
		}
		if(savedIndex == null){
			self.__Requests.push(currentRequest);
			savedIndex = self.__Requests.length - 1;
		}
		if(this.OnResponse != ""){
			currentRequest.onreadystatechange = new Function("if(self.__Requests["+ savedIndex +"].readyState == 4){"+ this.OnResponse +"(self.__Requests["+ savedIndex +"].responseXML.childNodes[0], self.__Requests["+ savedIndex +"]);}");
		}
		
		for(var i = 0; i < this.arProperties.length; i++){
			var arProperty = this.arProperties[i];
			this.QueryString += "&"+ arProperty["PropertyName"] +"="+ encodeURIComponent(arProperty["PropertyValue"]);
		}
		if(this.Debug){
			window.Debug.DumpWindow(this.HostAddress+"&"+ this.QueryString);
		}
		//alert("Gonna send request:\n\n"+ this.QueryString);
		currentRequest.send(this.QueryString);
		
		return currentRequest;
	}
}

function __ClearRequestArray(){
	self.__Requests = null;
}