var map;    
var gdir;    
var geocoder = null;    
var addressMarker;    

function initialize() {      	  
	if (GBrowserIsCompatible()) {		
		map = new GMap2(document.getElementById("map_canvas"));		
		map.addControl(new GSmallMapControl());		
		map.addControl(new GMapTypeControl());		
		map.setCenter(new GLatLng(45.5782881,10.7052955), 13);				
		var marker = new GMarker(new GLatLng(45.5782881,10.7052955));		
		map.addOverlay(marker);		
		
		marker.openInfoWindowHtml("<strong>Hotel Garden</strong><br>Via della Madrina, 2<br>37016 Garda (VR) Italy");				
		gdir = new GDirections(map, document.getElementById("directions"));		
		GEvent.addListener(gdir, "error", handleErrors);	  
	}    
}        

function setDirections(fromAddress) {	  
	locale="it";      
	gdir.load("from: " + fromAddress + " to: Via della Madrina, 2, 37016 Verona");    
}    

function handleErrors(){	   
	if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)	alert("Indirizzo non trovato");	   
	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) alert("Si è verificato un errore nella geocodifica degli indirizzi");	   	   
	else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) alert("Manca un parametro");	     	   
	else if (gdir.getStatus().code == G_GEO_BAD_KEY) alert("Errore nella Key Api.");	   
	else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("La richiesta non puo' essere correttamente risolta.");	    	   
	else alert("Si è verificato un errore");	   	
}