	
   var iconFree = new GIcon(); 
    iconFree.image = 'immagini/p_conv.gif';
    iconFree.iconSize = new GSize(15, 15);
    iconFree.iconAnchor = new GPoint(15, 15);
    iconFree.infoWindowAnchor = new GPoint(5, 1);
	
	var iconConv = new GIcon(); 
    iconConv.image = 'immagini/p2_conv.gif';
    iconConv.iconSize = new GSize(18, 22);
    iconConv.iconAnchor = new GPoint(9, 11);
    iconConv.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons[0] = iconFree;
    customIcons[1] = iconConv;

 var point;
    function load(f) {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
       var customUI = map.getDefaultUI(); customUI.maptypes.hybrid = false;map.setUI(customUI);
		map.enableScrollWheelZoom();		
		var gdir=new GDirections(map, document.getElementById("path"));  
        GEvent.addListener(gdir, "error", handleErrors);

        GDownloadUrl("xml_re_v2.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var nome = markers[i].getAttribute("nome");
			var IDParcheggio = markers[i].getAttribute("id");
			var tipo= markers[i].getAttribute("tipo");
            point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
			map.setCenter(new GLatLng(markers[i].getAttribute("lat"), markers[i].getAttribute("lng")),14);									
            var marker = createMarker(point, nome, IDParcheggio, tipo);

			l = location.href;
			if (l.substr(l.lastIndexOf("/")+1).split(/[?#]/)[0]=='zoom_map.php') {			
         if (lng=="eu") { var html = "<div><form name='form_map' onSubmit='return false;'><table border='0' cellpadding='0' cellspacing='0' class='testonero' align='center' ><tr><td ><strong>" + nome + "</strong></td></tr><tr><td>Coordinate <br>Lat: "+point.lat()+" <br>Long:"+point.lng()+" <strong><br>Get directions from: </strong></td></tr><tr><td ><input name='da_indi' type='text' id='da_indi' /><br> <em>(ex: address,city)</em><br></td></tr><tr><td ><strong>untill this car park</strong></td></tr><tr><td><input name='button' type='button' onClick='load(document.form_map.da_indi.value);' value='Get direction'></td></tr></table></form></div>";} else {
			 var html = "<div><form name='form_map' onSubmit='return false;'><table border='0' cellpadding='0' cellspacing='0' class='testonero' align='center' ><tr><td ><strong>" + nome + "</strong></td></tr><tr><td>Coordinate <br>Lat: "+point.lat()+" <br>Long:"+point.lng()+" <strong><br>Calcola il percorsa da: </strong></td></tr><tr><td ><input name='da_indi' type='text' id='da_indi' /><br> <em>(nella forma: indirizzo,cittą)</em><br></td></tr><tr><td ><strong>fino a questo parcheggio</strong></td></tr><tr><td><input name='button' type='button' onClick='load(document.form_map.da_indi.value);' value='Calcola'></td></tr></table></form></div>"; }
			}
		 	 else {
			   var html = "<span class='titoloverde'>" + nome + "</span>";
			  
			  }
		  
            map.addOverlay(marker);
			 marker.openInfoWindowHtml(html);
          }
        });
      }	
	  if (f) {  			
	  			document.getElementById('map').style.height="50%";
				document.getElementById('stampa').style.display="block";
				
	  			da_indi=f;
	  			ini="from: "+da_indi+", italia to: "+ point.lat() +" " + point.lng(); 				
			 gdir.load(ini,{locale:"it_IT"});			
			 }
    }
 function handleErrors(gdir){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("Impossibile trovare l'indirizzo .\nError code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("Impossibile trovare l'indirizzo.\n Error code: " + gdir.getStatus().code);
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("Manca un parametro indispansabile.\n Error code: " + gdir.getStatus().code);

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("Impossibile leggere l'indirizzo\n Error code: " + gdir.getStatus().code);
	    
	   else alert("An unknown error occurred.");
	   
	}

    function createMarker(point, nome, IDParcheggio,tipo) {
	
      var marker = new GMarker(point, {icon:customIcons[tipo]});
	  l = location.href;
			if (l.substr(l.lastIndexOf("/")+1).split(/[?#]/)[0]=='zoom_map.php') {
      if (lng=="eu") { var html = "<div><form name='form_map' onSubmit='return false;'><table border='0' cellpadding='0' cellspacing='0' class='testonero' align='center' ><tr><td ><strong>" + nome + "</strong></td></tr><tr><td>Coordinate <br>Lat: "+point.lat()+" <br>Long:"+point.lng()+" <strong><br>Get directions from: </strong></td></tr><tr><td ><input name='da_indi' type='text' id='da_indi' /><br> <em>(ex: address,city)</em><br></td></tr><tr><td ><strong>untill this car park</strong></td></tr><tr><td><input name='button' type='button' onClick='load(document.form_map.da_indi.value);' value='Get direction'></td></tr></table></form></div>";} else {
			 var html = "<div><form name='form_map' onSubmit='return false;'><table border='0' cellpadding='0' cellspacing='0' class='testonero' align='center' ><tr><td ><strong>" + nome + "</strong></td></tr><tr><td>Coordinate <br>Lat: "+point.lat()+" <br>Long:"+point.lng()+" <strong><br>Calcola il percorsa da: </strong></td></tr><tr><td ><input name='da_indi' type='text' id='da_indi' /><br> <em>(nella forma: indirizzo,cittą)</em><br></td></tr><tr><td ><strong>fino a questo parcheggio</strong></td></tr><tr><td><input name='button' type='button' onClick='load(document.form_map.da_indi.value);' value='Calcola'></td></tr></table></form></div>"; }}
	  else {
		    var html = "<span class='titoloverde'>" + nome + "</span>";
		  }
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
    //]]> 