function Ajax(chyba){

	var zpracuj = null;
	var xmlHttp = null;
	var JSON = {};

	if(window.ActiveXObject) xmlHttp = new window.ActiveXObject("Microsoft.XMLHTTP");
 	else xmlHttp = new XMLHttpRequest();

	this.get = function(co){

	   if(co == 'responseJSON'){
	   
	      if(xmlHttp.responseText == '') return {};

			try{
			with(this){
				eval('JSON = '+xmlHttp.responseText);
			}
			}catch(ex){

				throw ex;
			   //alert('Při vytváření objektu JSON doško k chybě:\n\n'+ex.name + ': ' + ex.message);
			}

			return JSON;
	   }
	   return xmlHttp[co];
	};

	this.getResponseHeader = function(jaka){

	   return xmlHttp.getResponseHeader(jaka);
	};

	this.getAllResponseHeaders = function(){
	   return xmlHttp.getAllResponseHeaders();
	};

	this.setRequestHeader = function(){

	   xmlHttp.setRequestHeader();
	};

	this.abort = function(){

	   xmlHttp.abort();
	};

	this.send = function(zprc, kam, jak, data, asyn){


		if(!jak) jak = "GET";
		if(!data) data = null;
		if(!asyn) asyn = true;

		jak = jak.toUpperCase();

		if(data != null && jak == 'GET'){

			if(kam.indexOf('?') == -1) kam += '?' + data;
		   else kam += '&' + data;

		   data = null;
		}

		if(jak != "POST" && jak != "GET" && jak != "HEAD"){ alert("Dotazy mohou být pouze typu 'GET', 'POST' nebo 'HEAD'"); return;}

		zpracuj = zprc;
		xmlHttp.onreadystatechange = funkceZpracuj;
		xmlHttp.open(jak, kam, asyn);
		if(jak == "POST") xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(data);
	}

	var funkceZpracuj = function(){

		if(zpracuj == null) return;

		if(xmlHttp.readyState == 4){

			if(xmlHttp.status == 200){

				zpracuj();
				if(window.ActiveXObject) xmlHttp = new window.ActiveXObject("Microsoft.XMLHTTP");
			}else{

				if(!chyba){

					errorText = "Error: " + xmlHttp.status + "\n\n" + xmlHttp.statusText;
					alert(errorText);
					return;
				}else{

				   chyba(xmlHttp);
				}
			}
		}
	};
}
