function xHttpRequest(){
    // publics props
    this.method='get';
    this.XMLmessage=null;
    this.async=false;
    this.responseText=null;
    this.responseXML=null;
    this.no_cache = true; 
	this.applyTo=this;
    

    // private props
    var me=this;
    var xr=null;
    // events
    this.oncomplete=new Function();
    this.onstart=new Function();
    this.completed=false;
    
    
   		
    
    // publics methods
    this.call=function(sUrl,sMethod,sXML){
        
    	if (me.no_cache){    		 
    		if (sUrl.indexOf('?')>=0) 
	   			sUrl+="&xcache=" +  Math.random();
	   		else
	   			sUrl+="?xcache=" + Math.random();	   		
        }        
        
        if (sMethod==undefined)
        sMethod=this.method;
        if (sXML==undefined)
        sXML=this.XMLmessage;
    
        this.responseText=null;
        this.responseXML=null;
        this.onstart();
                
        
        xr.open(sMethod, sUrl, this.async);
        if (sXML!=null)
        xr.setRequestHeader("Content-type", "text/xml");
        
        xr.send(sXML);
        
        if (this.async==false){           
           if (xr.readyState == 4 ){
              if(xr.status == 200) {
    	   	      this.responseText=xr.responseText;
    		      this.responseXML=xr.responseXML;
                  this.oncomplete.apply(me.applyTo,new Array(me));			
    		      return true;
   		      }
              else{                  
                  e=new Error(xr.status, xr.statusText);
                  throw e;                  
                  this.oncomplete.apply(me.applyTo,new Array(me));			
                  return false;
              }
           }
           else{
                e=new Error('Not connected');                
                this.oncomplete.apply(me.applyTo,new Array(me));
                throw e;			
                return false;
           }
        }        
    }
    
    this.reqChange=function(){        
		if (me.async==false){
            if (xr.readyState == 4)
            me.completed=true;
            else            
            me.completed=false;
        }
        else{
            // only if req shows "loaded"            
    	    if (xr.readyState == 4) {
                me.completed=true;            
    	        // only if "OK"
    	        if (xr.status == 200) {
    			   me.responseText=xr.responseText;
     		       me.responseXML=xr.responseXML;
                   me.oncomplete.apply(me.applyTo,new Array(me));			
    	        } else {                   
    	           me.oncomplete.apply(me.applyTo,new Array(me));
				   e=new Error(xr.status, xr.statusText);
                   throw e;
    	        }
    	    }
            else{
                me.completed=false;
            }
        }
	}
        
    // constructor
    if (window.XMLHttpRequest) {
	    xr = new XMLHttpRequest();	
	} else if (window.ActiveXObject) {
	    xr = new ActiveXObject("Microsoft.XMLHTTP");
	}

    xr.onreadystatechange = this.reqChange; 
}

