



// Icona 1 - Parcheggio Enabled
//var icon1 = new GIcon();
//icon1.image = "http://geososta.emunicipio.it/img/ico/1.png";
//icon1.shadow = "http://geososta.emunicipio.it/img/ico/ombra.png";
//icon1.iconSize = new GSize(22, 41);   //Dimensioni dell'icona
//icon1.shadowSize = new GSize(41, 41);  //Dimensioni dell'ombra
//icon1.iconAnchor = new GPoint(11, 41);  //Ancora dell'immagine con la mappa
//icon1.infoWindowAnchor = new GPoint(11, 1);	//Ancora della finestra di info		


function clearMap(map){
	map.clearOverlays();
}

function resetMap(map){
	map.setCenter(new GLatLng(41.354976500546604, 15.5728515625), 9);
	clearMap(map);
}

function setCenter(map, lat, lon, z){
	map.setCenter(new GLatLng(lat, lon), z);
}


function centerOnMap(lat, lon){
	map.panTo(new GLatLng(lat, lon));	
}

function setMarker(map, lat, lon){
	var point = new GLatLng(lat, lon);
    map.addOverlay(new GMarker(point));
}


function getCenterLat(map){
	return map.getCenter().lat();	
}

function getCenterLng(map){
	return map.getCenter().lng();	
}


function getIndirizzoTestuale(place){
	if (place.AddressDetails.Accuracy==0) {
		return "null";
	} else {
		return place.address;
	}	
}

function getCAP(place){
	if (place.AddressDetails.Country!=null)
		if (place.AddressDetails.Country.AdministrativeArea!=null)
			if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea!=null)
				if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality!=null)
					if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode!=null)
						if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber!=null)
							if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber!="undefined") 
								return place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;

	
	return "null";
}

function getCitta(place){
	if (place.AddressDetails.Country!=null)
		if (place.AddressDetails.Country.AdministrativeArea!=null)
			if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea!=null)
				if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality!=null)
					if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName!=null)
						return place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
	
	return "null";
}


function getRegione(place){
	if (place.AddressDetails.Country!=null)
		if (place.AddressDetails.Country.AdministrativeArea!=null)
			if (place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName!=null)
				return place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
	
	return "null";
}


function getStrada(place){
	if (place.AddressDetails.Country!=null)
		if (place.AddressDetails.Country.AdministrativeArea!=null)
			if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea!=null)
				if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality!=null)
					if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare!=null)
						if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName!=null)						
							return place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
	
	return "null";
}

function getProvincia(place){
	if (place.AddressDetails.Country!=null)
		if (place.AddressDetails.Country.AdministrativeArea!=null)
			if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea!=null)
				if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName!=null)
					return place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;
	
	return "null";
}

function espandiMappa(){
	var lt = getCenterLat(map);
	var ln = getCenterLng(map);
	var divM = document.getElementById("mapSmall");
	divM.style.width="500px";
	divM.style.height="500px";
	divM.style.top="0px";
	divM.style.left="-360px";
	divM.style.overflow="visible";
	divM.style.backgroundColor="rgb(0,0,0)";	
	document.getElementById("linkEspandi").innerHTML="<a href=\"javascript:riduciMappa();\">"+label2+"</a>";
	map.checkResize();
	map.panTo(new GLatLng(lt, ln));
}
function riduciMappa(){
	var lt = getCenterLat(map);
	var ln = getCenterLng(map);
	var divM = document.getElementById("mapSmall");
	divM.style.width="140px";
	divM.style.height="140px";
	divM.style.top="0px";
	divM.style.left="0px";
	divM.style.overflow="hidden";
	document.getElementById("linkEspandi").innerHTML="<a href=\"javascript:espandiMappa();\">"+label4+"</a>";
	map.checkResize();
	map.panTo(new GLatLng(lt, ln));
}

function setAndGo(cat, url){
	document.getElementById("contenutoColSXValue").value = document.getElementById("menurisorsa").innerHTML;
	var dMap = document.getElementById("datiMappa");
	dMap.action = url;
/*	
	alert('Action: ' + dMap.action + '\n'+
		   'Return: ' + dMap.returnURL.value +'\n'+
		   'fromMap: ' + dMap.fromMap.value +'\n' +
		   'hiddenTitle: ' + dMap.hiddenTitle.value +'\n' +
		   'lat: ' + dMap.lat.value +'\n' +
		   'lng: ' + dMap.lng.value +'\n' +
		   'zoom: ' + dMap.zoom.value +'\n' +
		   'statozoom: ' + dMap.statozoom.value +'\n' +
		   'id_categoriaSEL: ' + dMap.id_categoriaSEL.value +'\n' +
   		   'contenutoColSX: ' + dMap.contenutoColSX.value +'\n' +
		   'colSX_Function: ' + dMap.colSX_Function.value +'\n'  );		   
*/
	document.getElementById("datiMappa").submit();
}





