     //<![CDATA[

    // Check to see if this browser can run the Google API

    if (GBrowserIsCompatible()) {

	// variabili cliente ================= 43.48529813 - Lon: 13.63329076
      var cliente = "Residence Dama Blu";
	   var lat = 43.48529813; // point
	   var lan = 13.63329076; // point
	    //var lat1 = 43.336504; // point
	   //var lan1 = 12.909093; // point
	   var latmap = lan // mappa
	   var lanmap = lat; //mappa
	   // fine variabili cliente
	
	
	
      var gmarkers = [];
      var htmls = [];
      var to_htmls = [];
      var from_htmls = [];
      var i=0;
	  var into;

      // A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point);

        // The info window version with the "to here" form open
        to_htmls[i] = html + '<br \/>Direzione: <b>Verso '+name+'</b><br \/>--------<br \/>oppure <a href="javascript:fromhere(' + i + ')">Inverti</a>' +
           '<br \/><br \/>Digita Indirizzo:<form action="javascript:getDirections()">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Ottieni Direzione" TYPE="SUBMIT">' +
           '<input type="hidden" id="daddr" value="'+name+"@"+ point.lat() + ',' + point.lng() + 
           '"/>';
          
        // The info window version with the "to here" form open
       
		   from_htmls[i] = html + '<br \/>Direzione: <b>Da '+name+'</b><br \/>--------<br \/>oppure <a href="javascript:tohere(' + i + ')">Inverti</a>' +
           '<br \/><br \/>Digita Indirizzo:<form action="javascript:getDirections()">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Ottieni Direzione" TYPE="SUBMIT">' +
           '<input type="hidden" id="daddr" value="'+name+"@"+ point.lat() + ',' + point.lng() + 
           '"/>';
		   
		   
		   
       //  The inactive version of the direction info
       html=html+'Ottieni maggiori informazioni<br />per raggiungerci, scegli la direzione: <br /><br /><a href="javascript:tohere('+i+')"> Verso '+name+'</a><br \/> -----------<br \/>'+
		 '<a href="javascript:fromhere('+i+')">Da '+name+'</a></div><br \/>';
    
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
		into= html;
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
       	
        return marker;
      }
	  
	  function getDirections() {
        var saddr = document.getElementById("saddr").value
        var daddr = document.getElementById("daddr").value
		var direction_div = document.getElementById("directions").style;
		var direction_map = document.getElementById("map").style;
		var direction_reset = document.getElementById("reset").style;        
		direction_div.display = "block";
	    direction_reset.display = "block";
		direction_map.width = "420px";
	    gdir.load("from: "+saddr+" to: "+daddr);
      }
	  
	  

      // functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
      }
	  
	   function up(i) {
       gmarkers[i].openInfoWindowHtml(htmls[i]);
	     }
		 
		  // ===== request the directions =====
      

      var map = new GMap(document.getElementById("map"));
          map.addControl(new GSmallMapControl());
         // map.addControl(new GOverviewMapControl());
	      map.addControl(new GMapTypeControl());
	      map.addMapType(G_PHYSICAL_MAP);
        // map.setMapType(G_SATELLITE_TYPE);
	      map.centerAndZoom(new GPoint(latmap,lanmap), 7);
          map.setMapType(G_PHYSICAL_MAP ); 
         
      
 // === create a GDirections Object ===
      var gdir=new GDirections(map, document.getElementById("directions"));
	  
	  // === Array for decoding the failure codes ===
      var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Successo";
      reasons[G_GEO_MISSING_ADDRESS]    = "Indirizzo mancante modificare la ricerca.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Indirizzo Sconosciuto non è possibile una geolocalizzazione.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Indirizzo non consentito per ragioni legali.";
      reasons[G_GEO_BAD_KEY]            = "Errore nella chiave di google.";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Troppe richieste ricevute dal server";
      reasons[G_GEO_SERVER_ERROR]       = "Errore del Server.";
      reasons[G_GEO_BAD_REQUEST]        = "La direzione non può essere correttamente visualizzata.";
      reasons[G_GEO_MISSING_QUERY]      = "Nessun richiesta ammmissibile.";
      reasons[G_GEO_UNKNOWN_DIRECTIONS] = "Non è possibile mostrare la direzione tra i due punti.";

      // === catch Directions errors ===
      GEvent.addListener(gdir, "error", function() {
        var code = gdir.getStatus().code;
        var reason="Code "+code;
        if (reasons[code]) {
          reason = reasons[code]
        } 
	    reset();
        alert("Errore nella ricerca dell'indirizzo: "+reason);
	
      });
	  
	  
    
      // qui ci sono i punti da far apparire sulla mappa
    
      var point = new GLatLng(lat,lan);
      var marker = createMarker(point,''+cliente+'','<div align="center">'+cliente+'<br />')
      map.addOverlay(marker);
	
	  
	function reset(){map.setCenter(new GLatLng(lat,lan), 9);
	 up(0);
	  map.addOverlay(marker);
	    var direction_div = document.getElementById("directions").style;
		var direction_map = document.getElementById("map").style;
		var direction_reset = document.getElementById("reset").style;
        
		direction_div.display = "none";
	    direction_reset.display = "none";
		direction_map.width = "620px";
	
	   }
    }

    
    // display a warning if the browser was not compatible
    else {
      alert("Attenzione Google Map non è compatibile con questo sito.");
    }

    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://econym.googlepages.com/index.htm

    //]]>
