function createXmlHttpRequestObject(){	
  var xmlHttp;
  if(window.ActiveXObject) {
    try{
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e){
      xmlHttp = false;
    }
  }else{
    try{
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
      xmlHttp = false;
    }
  }

  if (!xmlHttp) 
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}



function c_request(url,type){
	var requester = null;
	this.url = url;
	var write_func;
	var info_func;
	this.text = '';
	this.ret_type = type;
	this.async = true;
	
	this.connect = function (){		
	       try{
				this.requester = createXmlHttpRequestObject();
			}
			catch (error){
				return false;
			}
	
		return true;
	}
	
	this.stateHandler = function (){		
		if (this.requester.readyState == 4)
		{
			if (this.requester.status == 200)
			{					
				if(this.ret_type == "xml")
					this.write_func(this.requester.responseXML);
				else
					this.write_func(this.requester.responseText);
			}
			else if (this.requester.status != 0)
			{	
				alert("There was an error while retrieving the URL: " + this.requester.statusText);
			}
			if (this.info_func)
                this.info_func(2);
		}
		else{
			if (this.info_func)
                this.info_func(1);
		}
		return true;
	}
	
	this.load_data = function(){		
		this.connect();		
		var t = this;
		this.requester.open("GET", this.url,this.async);		
		if (this.async) {// pokud volame asynchrone
             this.requester.onreadystatechange = function () {t.stateHandler ();};
        }
		this.requester.send(null);		
		if (!this.async) { // pokud voláme synchrone
            t.stateHandler (); 
        }
		return true;
	}	
	
	this.set_url = function(url){
		this.url = url;
	}
	
}
