// JavaScript Document
function Async_Ajax(){
	this.GetXmlHttpObject();
}
Async_Ajax.prototype.GetXmlHttpObject = function(){
	var xmlHttp = null;
    try {
        // Mozilla / Safari
        this.xmlHttp = new XMLHttpRequest();
    } 
	catch (e) {
        // Explorer
        var _ieVersions = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
        var success = false;
        for (var i=0;i < _ieVersions.length && !success; i++) {
        	try {
                this.xmlHttp = new ActiveXObject(_ieVersions[i]);
                success = true;
            } 
			catch (e) { }
        }
        if ( !success ) {
			alert('Status: Cound not create XmlHttpRequest Object.  Consider upgrading your browser.')
            return false;
        }
        return true;
    } 	
}
Async_Ajax.prototype.init = function(vMethod,oServer,param){ 
  	var oThis = this;
	this.php = oServer;
	if(this.xmlHttp != null){
		switch(vMethod){ 
			case 'post':
			case 'POST':
				this.xmlHttp.open("POST",this.php,true);	
				this.xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				this.xmlHttp.onreadystatechange = function(){
					oThis.statechanged();
				}			
				this.xmlHttp.send(param);
			break;
			
			case 'get':
			case 'GET': 
                this.xmlHttp.open("GET",this.php+'?'+param,true);
                //this.xmlHttp.open("GET",this.php,true);
				this.xmlHttp.onreadystatechange = function(){
					oThis.statechanged();
				}
				this.xmlHttp.send(null); 
			break;
		}
  	}
  	else{
    	alert("Browser does not support HTTP Request")
  	}
}
Async_Ajax.prototype.statechanged = function(){ 
  	if(this.xmlHttp.readyState == 4 && this.xmlHttp.status == 200){ 
		this.callback(this.xmlHttp.responseText,this.xmlHttp.responseXML);	
  	}
}