function HttpConnector()
{
	this.http = null;
	this.response = null;
	this.data = "";
	this.working = "";
	this.id = null;
	this.hash = null;

	if(navigator.appName == "Microsoft Internet Explorer") 
	{
	  this.http = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	else 
	{
	  this.http = new XMLHttpRequest();
	}

	// provede GET dotaz na URL query a po dokonceni zavola metodu response(data)
	this.getQuery = function(query, response, working)
	{
		this.response = response;
		this.working = working;
	
		this.http.abort();
		this.http.open("GET", query, true);		
		
		this.http.onreadystatechange = 
			(function(obj) 
			{			
				return function()
				{ 
					obj.httpResponse();
				}
			})(this);
			
		this.http.send(null);
		
		this.setWorking(true);

		this.hash = Math.random();
		this.hash = this.hash + query;
		return this.hash;
	}	

	// provede POST dotaz na URL query a po dokonceni zavola metodu response(data)
	this.postQuery = function(url, params, response, working)
	{
		this.response = response;
		this.working = working;
	
		this.http.abort();
		this.http.open("POST", url, true);		
		
		this.http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		//this.http.setRequestHeader("Content-length", params.length);
		//this.http.setRequestHeader("Connection", "close");					
		
		this.http.onreadystatechange = 
			(function(obj) 
			{			
				return function()
				{ 
					obj.httpResponse();
				}
			})(this);
			
		this.http.send(params);
		
		this.setWorking(true);
		
		this.hash = Math.random();
		this.hash = this.hash + url;
		return this.hash;
	}
	
	this.httpResponse = function()
	{		
		if (this.http.readyState != 4) return;
		
		this.setWorking(false);
		
		if (this.http.status == 200)
		{
			this.data =  this.http.responseText;
	
			this.response(this, this.data);
		}
		else
		{
			this.data = '';
			this.response(this, this.data);
		}
	}
	
	this.setWorking = function(work)
	{
		if (this.working != "")
		{
			workObj = document.getElementById(this.working);
			
			if (workObj != null)
			{			
				if (work)
					//workObj.style.visibility = "visible";
					workObj.className="ajax-on";
				else
					//workObj.style.visibility = "hidden";
					workObj.className="ajax-off";
			}
			
			var elems = document.getElementsByName (this.working)
			
			if (elems.length != 0)
			{
				for (var i = 0; i < elems.length; i++) 
				{  
					if (work)
						//workObj.style.visibility = "visible";
						elems[i].className="ajax-on";
					else
						//workObj.style.visibility = "hidden";
						elems[i].className="ajax-off";
				}
			}
		}	
	}
}
