function getHTTPObject() {
	var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
@else
	xmlhttp = false;
@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}



// Implement function.apply for browsers which don't support it natively
// Courtesy of Aaron Boodman - http://youngpup.net
if (!Function.prototype.apply) {
        Function.prototype.apply = function(oScope, args) {
                var sarg = [];
                var rtrn, call;

                if (!oScope) oScope = window;
                if (!args) args = [];

                for (var i = 0; i < args.length; i++) {
                        sarg[i] = "args["+i+"]";
                }

                call = "oScope.__applyTemp__(" + sarg.join(",") + ");";

                oScope.__applyTemp__ = this;
                rtrn = eval(call);
                oScope.__applyTemp__ = null;
                return rtrn;
        }
}




//function associateObjWithEvent(obj, methodName){


function HTTPRequest(method, url) {
	this.httpobj=getHTTPObject();
	this.method=method;
	this.url=url;
	this.async=true;

	this.isopen=false;

	this.open=HR_open;
	this.send=HR_send;
	this.cb4=null;
	this.caller=null;
	this.container=null;

	

//			var wddxDeserializer=new WddxDeserializer();
//			wddxDeserializer.preserveVarCase=true;
//			var data=wddxDeserializer.deserialize(http.responseText);

	function HR_open() {
		this.httpobj.open(this.method, this.url, this.async);
		this.isopen=true;
	}

	function HR_send(data) {
		if(this.isopen == false) {
			this.open();
		}

		this.httpobj.onreadystatechange=this.HR_rsc;
		
		this.httpobj.send(null);
	}
	

	this.HR_rsc=function HR_rsc() {
		if(this != arguments.callee._oScope){
			return arguments.callee.apply(arguments.callee._oScope, arguments);
		};



		switch(this.httpobj.readyState) {
			case 0: // uninitialized
				break;
			case 1: // loading
				break;
			case 2: // loaded
				break;
			case 3: // interactive
				break;
			case 4: // complete
				if(this.httpobj.status == 200) {
					if(this.cb4 != null) this.cb4.call(this.caller, this);
				} else {
					alert(''
						+ 'Failed to ' + this.method + ' data.\n'
						+ 'URL: ' + this.url + '\n'
						+ 'Status: ' + this.httpobj.status + ' ' + this.httpobj.statusText + '\n'
						+ 'Response: ' + this.httpobj.responseText + '\n'
					);
				}
				break;
		}
	}


	// setting reference
	this.HR_rsc._oScope=this;

}

