//<![CDATA[
// div a scomparsa
function handle_div(id_div_to_handle){
    for(i=0;i<arguments.length;i++){
        ref = document.getElementById(arguments[i]);
        if (ref.style.display  == 'none' || ref.style.display=='') {
            ref.style.display = 'block';
        } else {
            ref.style.display = 'none';
        }
    }
}

// gestione google maps
var map;
    var gdir;
    var geocoder = null;
    var addressMarker;

    function initialize()
    {

	  if (GBrowserIsCompatible())
      {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setUIToDefault();
        map.setCenter(new GLatLng(40.460988909600616, 14.962584972381592), 16);
        var marker = new GMarker(new GLatLng(40.460988909600616, 14.962584972381592))
        var marker1 = new GMarker(new GLatLng(48.460988909600616, 14.962584972381592))
        map.addOverlay(marker);
		gdir = new GDirections(map, document.getElementById("directions"));
		GEvent.addListener(gdir, "error", handleErrors);
	  }
    }

    function setDirections(fromAddress) {
	  //locale="it";
      gdir.load("from: " + fromAddress + " to: 40.460988909600616, 14.962584972381592");
    }

    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");

	}
//]]>
