//Cross-Browser XMLHttpRequest
//exmple posting url-encoded data
//loginRequest.Open("POST", url, true);
//loginRequest.SendRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//var data = "user=" + user + "&";
//data += "pass=" + pass ;
//loginRequest.Send(data);

//method declaration
XMLHttpObject.prototype.Open = Open;
XMLHttpObject.prototype.Send = Send;
XMLHttpObject.prototype.SetRequestHeader = SetRequestHeader;
XMLHttpObject.prototype.GetResponseText = GetResponseText;
XMLHttpObject.prototype.GetResponseXML = GetResponseXML;
XMLHttpObject.prototype.SetUsername = SetUsername;
XMLHttpObject.prototype.SetPassword = SetPassword;
XMLHttpObject.prototype.GetStatus = GetStatus;
XMLHttpObject.prototype.GetStatusText = GetStatusText;
XMLHttpObject.prototype.GetReadyState = GetReadyState;
XMLHttpObject.prototype.Abort = Abort;
XMLHttpObject.prototype.GetAllResponseHeaders = GetAllResponseHeaders;
XMLHttpObject.prototype.GetResponseHeader = GetResponseHeader;

//Event handler declaration
XMLHttpObject.prototype.SetResponseHandler = SetResponseHandler;

//Methods
function Abort() 						{ this.xmlObj.abort(); }
function SetUsername(name) 				{ this.username = name; }
function SetPassword(pass)				{ this.password = pass; }
function Open(method, url, async)		{ this.xmlObj.open(method, url, async, this.username, this.password); }
function Send(content) 					{ this.xmlObj.send(content); }
function SetRequestHeader(name, value)	{ this.xmlObj.setRequestHeader(name, value); }
function GetAllResponseHeaders()		{ return this.xmlObj.getAllResponseHeaders(); }
function GetResponseHeader(headername)	{ return this.xmlObj.getResponseHeader(headername); }
function GetResponseText()				{ return this.xmlObj.responseText; }
function GetResponseXML()				{ return this.xmlObj.responseXML; }
function GetStatus()					{ return this.xmlObj.status; }
function GetStatusText()				{ return this.xmlObj.statusText; }
function GetReadyState()				{ return this.xmlObj.readyState; }
function SetResponseHandler(handler)
{
	//~ this.xmlObj.onload = handler;
	//~ this.xmlObj.onerror = handler;
	this.xmlObj.onreadystatechange = handler;
}

function XMLHttpObject()
{
	this.xmlObj = null;
	this.username = '';
	this.password = '';
	this.isIE = false;

	//states
	this.UNINITIALIZED = "0";
	this.LOADING = "1";
	this.LOADED = "2";
	this.INTERACTIVE = "3";
	this.COMPLETE = "4";

	if (navigator.userAgent.indexOf("Opera") >= 0) {
		this.xmlObj = new XMLHttpRequest();
	} else if (navigator.userAgent.indexOf("MSIE")>=0) {
		this.isIE = true;
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0) {
			strName="Microsoft.XMLHTTP"
		}
		try {
			this.xmlObj=new ActiveXObject(strName)
		} catch(e) {
			alert("Error. Scripting for ActiveX might be disabled")
			return
		}
	} else if (navigator.userAgent.indexOf("Mozilla") >= 0) {
		this.xmlObj = new XMLHttpRequest();
	}
	return this;
}

