﻿

 AjaxRequest=function (ajaxUpdater){
 this.xmlHttpRequest = null;
 this.ajaxUpdater = ajaxUpdater;
}


AjaxRequest.prototype= {

    createXMLHttpRequest:function(){
         if(!this.xmlHttpRequest){
              if (window.ActiveXObject) {
                  this.xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
              }
              else if (window.XMLHttpRequest) {
                   this.xmlHttpRequest = new XMLHttpRequest();
              }
         }
    },

    getDocument:function(method,url,asynch){
        this.createXMLHttpRequest();
        if(this.xmlHttpRequest){
            try {
                this.xmlHttpRequest.open(method,url,asynch);
                var o = this;
                this.xmlHttpRequest.onreadystatechange = function(){
                    o.onReadyState();
                }
                this.xmlHttpRequest.send(null);
            }catch(e){  }
        }
    },

    onReadyState:function(){
    	if(this.xmlHttpRequest.readyState == 4){
        	if(this.xmlHttpRequest.status == 200 || this.xmlHttpRequest.status == 0 ){
                              this.ajaxUpdater(this.xmlHttpRequest.responseXML);
        	}
		}
	}
}

