function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(43.951394, 10.229119), 17);
map.addControl(new GScaleControl());
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
		
		gdir = new GDirections(map, document.getElementById("directions"));
		GEvent.addListener(gdir, "error", handleErrors);

// Crea un nuovo marker nel punto specificato con una descrizione HTML associata
function createMarker(point, description) {
var marker = new GMarker(point);
GEvent.addListener(marker, "mouseover", function() {
 marker.openInfoWindowHtml(description);
});
return marker;
}
// Aggiungi il marker alla mappa
map.addOverlay(
createMarker(new GLatLng(43.951394, 10.229119), "<table width=\"380px\"><tr><td><img src=\"img/100_map.jpg\" width=\"250\" height=\"90\" /></td><td width=\"5px\"></td><td><b>Paiotti</b><br />Via Aurelia sud, 13/15<br />55045 Pietrasanta (Lucca)<br \>Tel +39.0584.791222<br \>Fax +39.0584.799164</td></tr></table>"));
}
}

    function setDirections(fromAddress) {
	  locale="it";
      gdir.load("from: " + fromAddress + " to: Via Aurelia sud , 15, 55045 Pietrasanta");
    }

    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");
	   
	}
