var Ajax = function(){
	this.Method = "POST";
	this.Url = "index.php";
	this.Async = true;
	this.CallBack = "AfterRequest";
	this.FilePath = "";
	this.ClassName = "";
	this.MethodName = "";
	this.Arguments = "";
	this.Attributes = null;
	this.CustomURL = "";
	this.RegisterArgument = function(Name, Value){
		this.Arguments += "&Arguments[" + Name + "]=" + Value;
	}

	this.Send = function(){
		var xmlHttp;
		
		try{ xmlHttp = new XMLHttpRequest(); xmlHttp.overrideMimeType('text/xml');} // Firefox, Opera 8.0+, Safari
		
		catch (e){// Internet Explorer
			try{
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e){
				try{
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e){
					alert("AJAX not possible!");
					return false;
				}
			}

		}
		var Url = this.Url + "?Ajax=1";
		this.Arguments += "&FilePath=" + this.FilePath + "&ClassName=" + this.ClassName + "&MethodName=" + this.MethodName + this.CustomURL;
		var CallBack = this.CallBack;
		var Attributes = this.Attributes;
		if(typeof(this.Attributes) != "undefined"){
			var Attributes = this.Attributes;
		}
		xmlHttp.onreadystatechange = function(){
			if (xmlHttp.readyState==4){
				if (xmlHttp.status == 200) {
					eval(CallBack + "(xmlHttp, Attributes);");
				}
			}
		}
		//alert(Url);
		xmlHttp.open(this.Method, Url, this.Async);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", this.Arguments.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(this.Arguments);
		
		return xmlHttp;
	}
}
