function LoadVars() {

	if (window.XMLHttpRequest){
		this.reqObj = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		this.reqObj = new ActiveXObject("Microsoft.XMLHTTP");
	}

	var lv = this;

	this.reqObj.onreadystatechange = function(){
		lv.onStateChange();
	}

	this.content = null;
}

LoadVars.prototype.toString = function(){
	var lvString ="";

	for (var prop in this){
		if (typeof this[prop] != "function" && typeof this[prop] != "object" && prop != "parseVarString"){
			var nextVar = escape(prop) +'='+escape(this[prop])+'&';
			lvString += nextVar;
		}
	}
	return lvString;
}

LoadVars.prototype.onStateChange = function(){
	if (this.reqObj.readyState == 4){
		if (this.reqObj.status == 200) {
			this.onData();
		}else{
			var statusObj = {statusNum:this.reqObj.status, statusText:this.reqObj.statusText};
			this.loaded = false;
			this.onLoadError (statusObj);
		}
	}
}

LoadVars.prototype.loaded = false;
LoadVars.prototype.contentType = "application/x-www-form-urlencoded; charset=UTF-8";
LoadVars.prototype.parseVarString = null;
LoadVars.prototype.load = function (url){
	this.openXMLReq(url, "GET");
}

LoadVars.prototype.openXMLReq = function (url, method){
	if (method == undefined){
		method = "POST";
	}

	if(method == "GET"){
		theURL = url + '?' + this.toString();
		theData = null;
	}else if(method == "POST"){
		theURL = url;
		theData = this.toString();
	}

	this.reqObj.open(method, theURL, true );

	if (method == "POST"){
		this.reqObj.setRequestHeader("Content-Type", this.contentType);
	}

	this.reqObj.send(theData);
}

LoadVars.prototype.send = function (url, method){
	this.openXMLReq(url, method);
}

LoadVars.prototype.sendAndLoad = function(url, method){
	this.openXMLReq(url, method);
}

LoadVars.prototype.onData = function(){
	if (this.parseVarString == true){
		this.decode();
	}else{
		this.content = this.reqObj.responseText;
		this.onLoad(true);
	}
}

LoadVars.prototype.decode = function(){


	this.content = new Object();
	var escText = unescape(this.reqObj.responseText);
	var varArray = escText.split('&');

	var num = varArray.length;
	var i;
	var nextPair;
	var varName;
	var varValue;

	if (varArray.length > 0){

		for (i=0; i<num; i++){

			var nextPair = varArray[i];

			var nextPairArray = new Array();

			var firstEq = nextPair.indexOf("=", 0);

			nextPairArray[0] = nextPair.substring(0, firstEq);
			nextPairArray[1] = nextPair.substring(firstEq +1, nextPair.length);

			varName = nextPairArray[0];
			varValue = nextPairArray[1];

			this.content[varName] = varValue;
		}
		this.onLoad(true);
	}else{

		this.onLoad(false);
	}

}