function getDistricts(){
	if (httpRequest.readyState == 4){
		if(httpRequest.status == 200){
			var okresy = httpRequest.responseXML.getElementsByTagName('district');
			var cell = document.getElementById("district");
			if ( cell.hasChildNodes()){
				while ( cell.childNodes.length >= 1 ){
					cell.removeChild(cell.firstChild);
				}
			}
			var cell = document.getElementById("town");
			if ( cell.hasChildNodes()){
				while ( cell.childNodes.length >= 1 ){
					cell.removeChild(cell.firstChild);
				}
			}
			document.getElementById("district").appendChild(new Option("- Vyberte -",""));
			document.getElementById("town").appendChild(new Option("- Vyberte -",""));
			for (var i=0; i < okresy.length; i++) {
				document.getElementById("district").appendChild(new Option(okresy[i].firstChild.data,okresy[i].getAttribute('id')));
			}
		} else {
			alert("Chyba při načítání stránky "+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}
}
function getTowns(){
	if (httpRequest.readyState == 4){
		if(httpRequest.status == 200){
			var mesta = httpRequest.responseXML.getElementsByTagName('town');
			var cell = document.getElementById("town");
			if ( cell.hasChildNodes()){
				while ( cell.childNodes.length >= 1 ){
					cell.removeChild(cell.firstChild);
				}
			}
			document.getElementById("town").appendChild(new Option("- Vyberte -",""));
			for (var i=0; i < mesta.length; i++) {
				document.getElementById("town").appendChild(new Option(mesta[i].firstChild.data,mesta[i].getAttribute('id')));
			}
		} else {
			alert("Chyba při načítání stránky "+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}
}
function getCDistricts(){
	if (httpRequest.readyState == 4){
		if(httpRequest.status == 200){
			var okresy = httpRequest.responseXML.getElementsByTagName('district');
			var cell = document.getElementById("cdistrict");
			if ( cell.hasChildNodes()){
				while ( cell.childNodes.length >= 1 ){
					cell.removeChild(cell.firstChild);
				}
			}
			var cell = document.getElementById("ctown");
			if ( cell.hasChildNodes()){
				while ( cell.childNodes.length >= 1 ){
					cell.removeChild(cell.firstChild);
				}
			}
			document.getElementById("cdistrict").appendChild(new Option("- Vyberte -",""));
			document.getElementById("ctown").appendChild(new Option("- Vyberte -",""));
			for (var i=0; i < okresy.length; i++) {
				document.getElementById("cdistrict").appendChild(new Option(okresy[i].firstChild.data,okresy[i].getAttribute('id')));
			}
		} else {
			alert("Chyba při načítání stránky "+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}
}
function getCTowns(){
	if (httpRequest.readyState == 4){
		if(httpRequest.status == 200){
			var mesta = httpRequest.responseXML.getElementsByTagName('town');
			var cell = document.getElementById("ctown");
			if ( cell.hasChildNodes()){
				while ( cell.childNodes.length >= 1 ){
					cell.removeChild(cell.firstChild);
				}
			}
			document.getElementById("ctown").appendChild(new Option("- Vyberte -",""));
			for (var i=0; i < mesta.length; i++) {
				document.getElementById("ctown").appendChild(new Option(mesta[i].firstChild.data,mesta[i].getAttribute('id')));
			}
		} else {
			alert("Chyba při načítání stránky "+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}
}

function getdata(url,func){
	if (url != ''){
		if (window.ActiveXObject){
			httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			httpRequest = new XMLHttpRequest();
		}
		httpRequest.open("GET", url, true);
		httpRequest.onreadystatechange= function () { eval(func); } ;
		httpRequest.send(null);
	}
}

