function getXMLHTTP() {
	var xmlhttp = false;	
	try {
		xmlhttp = new XMLHttpRequest();
	}
	catch(e) {		
		try {			
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e) {
			try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e1) {
				xmlhttp = false;
			}
		}
	}
	return xmlhttp;
}

function getDestinace(countryId) {		
	var strURL="fdestinace.php?countryId=" + countryId;
	var req = getXMLHTTP();
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('destinacediv').innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function getHotely(southwest_lat, southwest_lng, northeast_lat, northeast_lng, center_lat, center_lng, zoom, layout, page) {		
	var strURL="fhotely.php?southwest_lat=" + southwest_lat + "&southwest_lng=" + southwest_lng + "&northeast_lat=" + northeast_lat + "&northeast_lng=" + northeast_lng + "&center_lat=" + center_lat + "&center_lng=" + center_lng + "&zoom=" + zoom + "&layout=" + layout + "&page=" + page;
	var req = getXMLHTTP();
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('hotelydiv').innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function getMarkers(southwest_lat, southwest_lng, northeast_lat, northeast_lng, center_lat, center_lng, zoom, tab, mistaId) {
	var strURL="fhotely.php?event=2&southwest_lat=" + southwest_lat + "&southwest_lng=" + southwest_lng + "&northeast_lat=" + northeast_lat + "&northeast_lng=" + northeast_lng + "&center_lat=" + center_lat + "&center_lng=" + center_lng + "&tab=" + tab + "&mistaId=" + mistaId + "&zoom=" + zoom;
	
	// odmazeme stary skript, pokud existoval
	var hlavicka = document.getElementsByTagName('head')[0];
	var dataLoader = document.getElementById('scriptLoader');
	if(dataLoader) hlavicka.removeChild(dataLoader);
	
	// vytvorime novy element script
	script = document.createElement('script');
	script.id = 'scriptLoader';
	script.src = strURL;
	
	// POZOR, DULEZITE!! Skript musime vlozit do stranky pomoci DOM - appendChild()
	// Ihned po vlozeni prohlizec stahne skript a spusti jej
	x = document.getElementsByTagName('head')[0];
	x.appendChild(script);
	
	return false;
}
