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 toggleCommenti() {
	if ($('nuovocommento')) {
		if ($('commento').style.display == "none") {
			$('togglecommenti').setStyle({ backgroundImage: 'url(img/bkg_open.png)' });
			$('commento').show();
		} else {
			$('togglecommenti').setStyle({ backgroundImage: 'url(img/bkg_close.png)' });
			$('commento').hide();
		}
	}
}
function giaFatte() {
	if ($('giafatte')) {
		if ($('giafatte').style.height == "50px") {
			$('h3giafatte').setStyle({ backgroundImage: 'url(img/bkg_open.png)' });
			$('giafatte').style.height = "auto";
		} else {
			$('h3giafatte').setStyle({ backgroundImage: 'url(img/bkg_close.png)' });
			$('giafatte').style.height = "50px";
		}
	}
}
function loadVideo(id) {
	var url = "xml_load_video.php";
	var pars = "id="+id;
	var MyAjax = new Ajax.Updater(
		{success: 'pdplayer'},
		url,
		{
			method: 'post',
			parameters: pars
		}
	);
}
function aggCountMateriale(id) {
	var url = "xml_aggiorna_count_materiale.php";
	var pars = "id=" + escape(id)
	var myAjax = new Ajax.Request(
		url,
		{
			method: 'post',
			parameters: pars
		}
	);
}