function ForsiamAjax(method, url, parameter, onCompleteFunc, onProcessFunc){
	this.xmlhttp = null;
	this.response = null;
	this.method = method;
	this.url = url;
	this.parameter = parameter;
	this.onCompleteFunc = onCompleteFunc;
	this.onProcessFunc = onProcessFunc;
	
	this.loadXMLDoc();
}


ForsiamAjax.prototype.ConnXmlHttp = function(){

	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			isIE = true;
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			xmlhttp = null;
		}
	}
	
	if(!xmlhttp && document.createElement) xmlhttp = new XMLHttpRequest();
	return xmlhttp;
}


ForsiamAjax.prototype.loadXMLDoc = function(){
	var self = this;
	this.xmlhttp = this.ConnXmlHttp();

	if(this.xmlhttp != null){
		var url = this.url + "?" +this.parameter;

		switch(this.method.toUpperCase()){
			case "GET":
				this.xmlhttp.open(this.method, url, true);
				break;
			case "POST":
				this.xmlhttp.open(this.method, url, true);
				this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				break;
		}

		this.xmlhttp.onreadystatechange = function(){
			if((self.xmlhttp.readyState==4) && (self.xmlhttp.responseText != null)){
				self.onProcess();
				if ((self.xmlhttp.status == 200) || (self.xmlhttp.status == 0)) {
					self.response = self.xmlhttp.responseText;
					self.onComplete();
				}
			}else{
				self.onProcess();
			}
		}

		this.xmlhttp.send(this.parameter);

	}

}

ForsiamAjax.prototype.onComplete = function(){
	if((this.onCompleteFunc==null) || (typeof(this.onCompleteFunc) == 'undefined')) this.onCompleteFunc = null;
	if(this.onCompleteFunc != null){
		try
		{
			var func = eval(this.onCompleteFunc);
			func( this.response );
		}
		catch(e){}
	}
}


ForsiamAjax.prototype.onProcess = function(){
	if((this.onProcessFunc==null) || (typeof(this.onProcessFunc) == 'undefined')) this.onProcessFunc = null;
	if(this.onProcessFunc != null){
		try
		{
			var func = eval(this.onProcessFunc);
			func();
		}
		catch(e){}
	}
}