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.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;

		if (window.XMLHttpRequest) {
            currentRequest = new XMLHttpRequest();
            if (currentRequest.overrideMimeType) {
                currentRequest.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                currentRequest = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    currentRequest = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
		
		currentRequest.open('POST', "/RPC.aspx?RPC=1", 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 +"]);}");
		
		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("Index.php?hNoMarkup=1&SuppressRedirect=1&XmlHttpRequest=1&Debug=1"+ this.QueryString);
			window.open("/RPC.aspx?RPC=1"+ this.QueryString);
		}
		currentRequest.send(this.QueryString);
		
		return currentRequest;
	}
}

function __ClearRequestArray(){
	self.__Requests = null;
}