// Norberth Danson 04/05/2006
function aJaX(OKprocess,ERRprocess){
	this.OK  = OKprocess;
  	this.ERR = ERRprocess;
	this.check = this.checkConnect();
	this.check.onreadystatechange = preConnect(this);
}
aJaX.prototype.checkConnect = function(){
	var AJX_request = false;
	if(window.XMLHttpRequest){
		try {
			AJX_request = new XMLHttpRequest();			
		} 
		catch(e){}
	}
	else if (window.ActiveXObject) { // IE
		var msobj = new Array(	"Msxml2.XMLHTTP.6.0",
								"Msxml2.XMLHTTP.4.0",
								"Msxml2.XMLHTTP.3.0",
								"Msxml2.XMLHTTP",
								"Microsoft.XMLHTTP");
		var x, len = msobj.length;
		for(x=0; x<len; ++x) {
			try {
			  AJX_request = new ActiveXObject(msobj[x]);
			  break;
			} catch (err) {};
		}
	}
	return AJX_request;
}
aJaX.prototype.Connect = function() {
	var AJX_response ;
    try {
		if (this.check.readyState == 4) {									
			if(this.check.status == 200) {
				// using JSON (ultrasimplified :)) over XML for speed
				AJX_response = this.check.responseText;
				this.check.onreadystatechange = new function() {};				
				if(this.OK){
					this.OK(this, AJX_response);
				}
			}
			else{
				if(this.ERR){				
					this.ERR(this);
				}
			}
		}
	} catch(e){}
}
function preConnect(aJaX_obj){
  return function () { aJaX_obj.Connect(); }
}
aJaX.prototype.modeGET = function(URL) {
	this.check.open( 'GET' , URL , true );
  	this.check.send( null );
}
aJaX.prototype.modePOST = function(URL, content) {
	this.check.open( 'POST' , URL , true );
  	this.check.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	this.check.setRequestHeader("Connection", "close");
	this.check.send( content );
}