
function setCittaDellaRegione () {
	var selRegioni =document.getElementById("regioni");
	if (String(selRegioni.options[selRegioni.selectedIndex].value)!="") {
		var cosa = String(selRegioni.options[selRegioni.selectedIndex].value).split('-');
		$.ajax({
	        type: "GET",
	        url: baseUrl+ "cercaCitta.php?regione=" +cosa[0],
	        data: "",
	        dataType: "json",
	        success: scriviCittaInCombo
		});
		//GDownloadUrl(baseurl + "cercaCitta.php?regione=" +cosa[0],scriviCittaInCombo)
	} else {
		document.location = document.location;
	}
	
}


function scriviCittaInCombo (dati) {
	
	var listaCitta =document.getElementById("citta");
	listaCitta.length = 0
	var y=document.createElement('option');
	y.value="";
	y.text="Tutte le Citta`";
	try {
		listaCitta.add(y,null); // standards compliant
	} catch(ex) {
		listaCitta.add(y); // IE only
	}
	
	for ( var citta in dati) {
		var y=document.createElement('option');
		y.value=dati[citta].lat+"##"+dati[citta].lng;
		y.text=citta;
		try {
			listaCitta.add(y,null); // standards compliant
		} catch(ex) {
			listaCitta.add(y); // IE only
		}
	}
	
}

function setRegioneByCombo() {
	
	var selRegioni =document.getElementById("regioni");
	if (String(selRegioni.options[selRegioni.selectedIndex].value)!="") {
		var selCitta =document.getElementById("citta");
		if (String(selCitta.options[selCitta.selectedIndex].value)!="") {
			var cosa = String(selRegioni.options[selRegioni.selectedIndex].value).split('-');
			var cosaCitta = String(selCitta.options[selCitta.selectedIndex].value).split('##');
			zoomLevel = 12;
			map.setCenter(new google.maps.LatLng(parseFloat(cosaCitta[0]),parseFloat(cosaCitta[1])));
			map.setZoom(zoomLevel);
		} else {
			var cosa = String(selRegioni.options[selRegioni.selectedIndex].value).split('-');
			zoomLevel = 8;
			map.setCenter(new google.maps.LatLng(parseFloat(cosa[1]),parseFloat(cosa[2])));
			map.setZoom(zoomLevel);
		}
	} else {
		document.location = document.location;
	}
}
