//----------------------------------------------
//Ajax v1.0 Source By Bermann
//----------------------------------------------

function BermannAjax(Method,Url,Async,Type,Params,userFunction,statusFunction,readyStateFunction)
{
	this.Req;
	this.Method = Method;
	this.Url = Url;
	this.Async = Async;
	this.Type = Type;
	this.Params = Params;
	this.userFunction = userFunction;
	this.statusFunction = statusFunction;
	this.readyStateFunction = readyStateFunction;
	this.Result = null;
	this.initialize();
	this.execute();
}

BermannAjax.prototype =
{
	initialize: function () {
		if (window.ActiveXObject) {
			try {
				this.Req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					this.Req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e1) {
					return null;
				}
			}
		} else if (window.XMLHttpRequest) {
			try {
				this.Req = new XMLHttpRequest();
			} catch (e) {
				return null;
			}
		}
	},
	callback: function () {
		if (this.Req.readyState == 4) {
			if (this.Req.status == 200) {
				if (this.Type == "TEXT") {
					this.Result = this.Req.responseText;
				} else if (this.Type == "XML") {
					this.Result = this.Req.responseXML;
				}
				if (typeof this.userFunction == "function") { this.userFunction(); }
			} else {
				this.Result = this.Req.statusText;
				if (typeof this.statusFunction == "function") { this.statusFunction(); }
			}
		} else {
			if (typeof this.readyStateFunction == "function") { this.readyStateFunction(); }
		}
	},
	execute: function () {
		var This = this;
		this.Req.onreadystatechange = function () { This.callback(); }
		this.Method = (this.Method != "POST" && this.Method != "GET") ? "GET" : this.Method;
		this.Url = (this.Method == "GET" && this.Params) ? this.Url + "?" + this.Params : this.Url;
		this.Async = (this.Async != true && this.Async != false) ? true : this.Async;
		this.Type = (this.Type != "TEXT" && this.Type != "XML") ? "TEXT" : this.Type;
		this.Params = (this.Method == "POST") ? this.Params : null;
		try {
			this.Req.open(this.Method,this.Url,this.Async);
			if (this.Method == "POST") this.Req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			this.Req.send(this.Params);
		} catch (e) {}
	}
}
