AjaxObj = function(){
    this._xmlhttp = this.GetXmlhttp();
    this.name = "junval";
}

AjaxObj.prototype.GetXmlhttp =function(){
    var __xmlhttp;

    try{
       __xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(ex){
        try{
            __xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(ex2){
            __xmlhttp = false;
        }
    }
    if (!__xmlhttp && typeof XMLHttpRequest != 'undefined'){
        try{
            __xmlhttp = new XMLHttpRequest();
        }catch(ex3){
           __xmlhttp = false;
        }
    }
    if (__xmlhttp){
        return __xmlhttp;
    }else{

        alert('Error!');
        return false;
    }
}

AjaxObj.prototype.Callback = function(__url,__mode,__OnSucceed,__Onfailed){
    var __data;
    var __ajaxType = __mode||'GET';
    if (__ajaxType != 'GET'){
        __ajaxType = 'POST';
        var __arrData = __mode.split('$');
        __data = __arrData[1];
    }
    if (this._xmlhttp){
        if( this._xmlhttp.readyState == 4 || this._xmlhttp.readyState == 0 ){
           var oThis = this;
           this._xmlhttp.open(__ajaxType, __url);
           this._xmlhttp.onreadystatechange = function(){ oThis.ReadyStateChange(__OnSucceed,__Onfailed);};
           this._xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
           if (__ajaxType == 'GET'){
                this._xmlhttp.send(null);
           }else{
                this._xmlhttp.send(__data);
           }
        }
    }
}

AjaxObj.prototype.Get = function(__url,__OnSucceed,__Onfailed){
      this.Callback(__url,'GET',__OnSucceed,__Onfailed); 
}

AjaxObj.prototype.Post = function(__url,__data,__OnSucceed,__Onfailed){
    this.Callback(__url,'POST$'+__data,__OnSucceed,__Onfailed);
}


AjaxObj.prototype.ReadyStateChange = function(__OnSucceed,__Onfailed){
     if( this._xmlhttp.readyState == 4 )
      {
        if( this._xmlhttp.status == 200 && this._xmlhttp.statusText == "OK" )
          __OnSucceed(this._xmlhttp.responseText);
        else
          __Onfailed(this._xmlhttp.responseText);   
      }
}
var ajax = new AjaxObj();
