Ischiaprenotazioni.gmap = Ischiaprenotazioni.gmap || {};

Ischiaprenotazioni.gmap.map = Ischiaprenotazioni.gmap.map || {};
Ischiaprenotazioni.gmap.geocoder = Ischiaprenotazioni.gmap.geocoder || {};


Ischiaprenotazioni.gmap.gmapLoader = function(){
    if (GBrowserIsCompatible()) {
	var map = null;
	var geocoder = null;

	map = new GMap2(document.getElementById("map"));

	/*mappa - satellite - ibrida */
	map.addControl(new GMapTypeControl());

	/*controller con barra vert*/
	map.addControl(new GLargeMapControl());

	/*zoom box, in basso a dx*/
	map.addControl(new GOverviewMapControl(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(9, 9)));
	/*COORDINATE DI PARTENZA DELLA MAPPA*/
	map.setCenter(new GLatLng(40.732273488389914, 13.86474609375), 12);
	geocoder = new GClientGeocoder();

	// see http://jqueryui.com/demos/tabs/#...my_slider.2C_Google_Map.2C_sIFR_etc._not_work_when_placed_in_a_hidden_.28inactive.29_tab.3F
	$('#tabs').bind('tabsshow', function(event, ui) {
	    if (ui.panel.id == "maptab") {
		map.checkResize()
	    }
	});


	Ischiaprenotazioni.gmap.map = map;
	Ischiaprenotazioni.gmap.geocoder = geocoder;

	$('body').unload(GUnload());
    }
}

Ischiaprenotazioni.gmap.showAddress = function(address){
    var geocoder = Ischiaprenotazioni.gmap.geocoder;
    var map = Ischiaprenotazioni.gmap.map;

    if (geocoder) {
	geocoder.getLatLng(address, function(point){
	    if (!point) {
		alert(address + " non trovato");
	    }
	    else {
		/*zoom*/
		map.setCenter(point, 14);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		marker.openInfoWindowHtml(address);
	    }
	});
    }
}
