var map = null;
	var geocoder = null;
	var icona = null;

function load() 
{
  	if (GBrowserIsCompatible()) 
 	{
      	map = new GMap2(document.getElementById("map"));
      	
		geocoder = new GClientGeocoder();
	
		map.setCenter(new GLatLng(37.4419, -122.1419), 12);
		
		map.setZoom(12); 
		map.setMapType(G_NORMAL_MAP);
		
		
		icona = new GIcon();
		icona.image = "http://www.meno18.com/sito/sites/all/themes/bonsaistudio/img/icona_mappa.png";
		icona.iconSize = new GSize(73, 60);
		icona.iconAnchor = new GPoint(14, 57);
		icona.infoWindowAnchor = new GPoint(10, 10);
		/**/
		
		showAddress("torino, via santagata 50");
    }
}
   


function createMarker(point, label) 
{
	var marker = new GMarker(point, icona);
  	
	GEvent.addListener(marker, "click", function() 
	{
    	marker.openInfoWindowHtml("<p style='color: #000000;'><img src='http://www.meno18.com/sito/sites/all/themes/bonsaistudio/img/logo_mappa.gif' style='float: left; margin-right: 15px;'><b>MENODICIOTTO s.n.c.</b><br />Via Santagata, 50<br />10156 Torino (TO)<br />Italia</p>");
  	});
  
  	return marker;
}
   


function showAddress(address) 
{
	geocoder.getLatLng(address,
    function(point) 
	{
    	if (!point) 
		{
        	alert(address + " non trovato!");
      	} 
		else 
		{
        	map.setCenter(point);
			map.addOverlay(createMarker(point, address));
      	}
    });
}

function cambiaMappa(tipomappa){

	if (tipomappa == "ibrida"){
	
		map.setMapType(G_HYBRID_MAP);
		document.getElementById('mappaOn').id = 'mappa';
		document.getElementById('ibrida').id = 'ibridaOn'; 
		
	} 
	
	if (tipomappa == "normale"){	
	
		map.setMapType(G_NORMAL_MAP);
		document.getElementById('mappa').id = 'mappaOn';
		document.getElementById('ibridaOn').id = 'ibrida';
	}

}
