function alpUrlEncode(text)
{
  var eText=escape(text);
  eText=eText.replace("+", "%2B").replace("/", "%2F");
  return(eText);
}

function alpAJAX(args)
{
	this.opts = args;
	if(typeof(this.opts.method) == "undefined"){
		this.opts.method = "GET";
	}
	if(typeof(this.opts.json) == "undefined"){
		this.opts.json = false;
	}
	if(typeof(this.opts.uri) == "undefined"){
		this.opts.uri = "";
	}
	if(typeof(this.opts.data) == "undefined"){
		this.opts.data = new Array();
	}
	this.queryText = "";
	for(var i = 0; i < this.opts.data.length; i++){
		if(i!=0){
			this.queryText += "&";
		}
		this.queryText += this.opts.data[i];
	}	
	
	this.callback = this.opts.callback;
}

alpAJAX.prototype.load = function()
{
	try
	{
		// Firefox, Opera 8.0+, Safari
		this.xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			this.xmlHttp=new ActiveXObject("Msxml2.XMLHttp");
		}
		catch (e)
		{
			try
			{
				this.xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	var _this = this;
	this.xmlHttp.onreadystatechange=function() {_this._onData();}

	if(this.opts.method == "GET"){
		this.xmlHttp.open("GET",(this.opts.uri + "?" + this.queryText),true);
		this.xmlHttp.send(null);
	}else if (this.opts.method == "POST"){
		this.xmlHttp.open("POST", this.opts.uri, true);
		//Send the proper header information along with the request
		this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.xmlHttp.setRequestHeader("Content-length", this.queryText.length);
		this.xmlHttp.setRequestHeader("Connection", "close");
		this.xmlHttp.send(this.queryText);
	}else{
		alert(this.opts.method + " is not a valid method.");
	}

}

alpAJAX.prototype._onData = function()
{
	if(this.xmlHttp.readyState==2)
	{
	}
	if(this.xmlHttp.readyState==3)
	{
	}
	if(this.xmlHttp.readyState==4)
	{
		
		if(!this.opts.json){
			this.callback(this.xmlHttp.responseText);
		}else{
			this.callback(eval('('+this.xmlHttp.responseText+')'));
		}
	}
}