function initialize() {
	var map;
	var geocoder;
}

function addAddressToMap(response) {
	var map = new GMap2($("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GHierarchicalMapTypeControl());
	map.setCenter(new GLatLng(45.130227, 11.648769), 13);

	map.clearOverlays();
	if (!response || response.Status.code != 200) {
		alert("Ci spiace, ma non riusciamo a visualizzare questo indirizzo sulla mappa");
	} else {
		var place = response.Placemark[0];
		var point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);

		var marker = new GMarker(point);
		map.addOverlay(marker);
		map.setCenter(point, 14);
		marker.openInfoWindowHtml(place.address);
	}
}

function showLocation(address) {
	if (address) {
		geocoder = new GClientGeocoder();
		geocoder.getLocations(address, addAddressToMap);
	} else {
		alert("Errore indirizzo");
	}
}

function apriFinestra(link) {
	window.open(link.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no');
}

function showDiv(padre, mostra) {
	// pesco i div di 'padre' e li nascondo tutti tranne 'mostra'
	$A($(padre).getElementsByTagName('div')).each(Element.hide);
	$(mostra).show();

	// cambio la classe nel menu
	var link = "l" + mostra.substr(1);
	$A($('secondomenu').getElementsByTagName('a')).each(function(s) {
		s.removeClassName('attivo');
	});

	if ($(link))
		$(link).addClassName("attivo");
}

function checkHash() {
	if (document.location.hash) {
		var hash = document.location.hash.replace("#", "d");

		if ($(hash))
			showDiv($(hash).parentNode.id, hash);
	}
}

onload = checkHash;