hova = ""

function urit(mit) {
	hossz = mit.options.length;
	
	for (i=1; i<=hossz; i++) {
		mit.options[0] = null;
	}
}

function jelenik(hely, feladat, kod) { 
	hova = hely;
	
	if (feladat == 1) {
		urit(document.getElementById('regio'))
	}
	
	urit(document.getElementById('hotel'))
	
	if (kod == 0) {
		return false
	}
	
	// Mozilla and Friends 
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		// Internet Explorer
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	req.onreadystatechange = processChoices;
	req.open("GET", "xmlhttp_hotels.php?kod="+kod+"&feladat="+feladat, true);
	req.send(null);
}

function processChoices() { 
	// wait until the request is done
	if (req.readyState == 4) { 
		// Make sure request came back OK
		if (req.status == 200) { 
			vissza = req.responseText;
			if (vissza.length > 0) {
				newOptionName = new Option("--- Bitte wählen ---", 0);
				document.getElementById(hova).options[0] = newOptionName;
				sor = vissza.split(';');
				for (i=0; i<sor.length; i++) { 
					adat = sor[i].split(",");
					document.getElementById(hova).options[i+1] = new Option(adat[1], adat[0]);
				} 
			}
			else {
				alert("Nincs adat!");
			}
		}
  		else {
			alert("Can't retrieve XML: " + req.statusText);
		} 
	} 
}
