 var map;
 var gdir;
 var geocoder = null;
 var addressMarker;
 function initialize() {
	 if (GBrowserIsCompatible()) {
		 map = new GMap2(document.getElementById("map"));
		 map.addControl(new GSmallMapControl());
		 map.addControl(new GMapTypeControl());
		 map.setCenter(new GLatLng(41.9495565, 12.5435045 ), 16);
		 var marker = new GMarker(new GLatLng(41.9495565, 12.5435045))
		 map.addOverlay(marker);
		 marker.openInfoWindowHtml("<b>Polinet Srl</b><br>Via Adolfo Albertazzi 25<br>00137 Roma");				         gdir = new GDirections(map, document.getElementById("directions"));
		 GEvent.addListener(gdir, "error", handleErrors);
		 }
		 }        
		 function setDirections(fromAddress) {
			 locale="it";
			 gdir.load("from: " + fromAddress + " to: Via Adolfo Albertazzi, 25, 00137 Roma");
			 }    
			 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");
}



