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(45.151845, 7.731775), 10);
		
		map.setZoom(10); 
		map.setMapType(G_NORMAL_MAP);
		
		icona = new GIcon();
		icona.image = "img/icona_mappa.png";
		icona.iconSize = new GSize(48, 46);
		icona.iconAnchor = new GPoint(10, 35);
		icona.infoWindowAnchor = new GPoint(0, 0);
		
		showAddress("Lein&igrave;, Strada del Fornacino 154/3");
    }
}
   


function createMarker(point, label) 
{
	var marker = new GMarker(point, icona);
  	
	GEvent.addListener(marker, "click", function() 
	{
    	marker.openInfoWindowHtml("<img src='img/logo_mappa.gif' width='100' height='47' style='margin-bottom: 10px;'><p style='color: #603b1a'><div style='color: #000;'><b>CoffeeArt s.n.c.</b></div>Strada del Fornacino, 154\3 - 10040<br />Lein&igrave; (TO)</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';
	}

}
