    var map;
    var geocoder;
	var Nome = "";
    function initialize(divname,smallcontrols) {
      map = new GMap2(document.getElementById(divname));
      //map.setCenter(new GLatLng(34, 0), 1);
      geocoder = new GClientGeocoder();
	  //map.enableScrollWheelZoom();
	  map.disableScrollWheelZoom();
	  if (smallcontrols)
	  {
	  	  var mapTypeControl = new GMapTypeControl();
		  var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
		  var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
		  map.addControl(mapTypeControl, topRight);
		  map.addControl(new GLargeMapControl());
	  } else {
		 map.addControl(new GSmallMapControl());
	  }
       
    }
	
	function localizzaposizioneconMarker(divname,smallcontrols,callBackPointX,callBackPointY)
	{
		initialize(divname,smallcontrols);
		var pvtMarker = null;
		GEvent.addListener(map, "click",function(marker, point) 
										{ 
											if (pvtMarker!=null)
											{
												map.removeOverlay(pvtMarker);
											}
											if (point != undefined)
											{
												callBackPointX.value = point.x 
												callBackPointY.value = point.y
												marker = new GMarker(point);
												pvtMarker = marker
												map.addOverlay(marker);
											}
											//marker.openInfoWindowHtml("Posizione" + point );
										}
						  )

		
	}
	
	

    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Sorry, we were unable to geocode that address");
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
		map.setCenter(point, 15);
		map.addOverlay(new GTrafficOverlay());
		 
        map.addOverlay(marker);
		if (Nome!="")
		{
			GEvent.addListener(marker, "click",function (){marker.openInfoWindowHtml("<b>" + Nome + '</b><br>' + place.address);})
			marker.openInfoWindowHtml("<b>" + Nome + '</b><br>' + place.address);
		}
      }
    }
	
	
	function showLocationByPoint(x,y,nome)
	{
		Nome = nome
		point = new GLatLng(y,x);
		marker = new GMarker(point);
		map.setCenter(point, 15);
        map.addOverlay(marker);

		GEvent.addListener(marker, "click",function (){marker.openInfoWindowHtml("<b>" + Nome + '</b>');})
        //marker.openInfoWindowHtml("<b>" + Nome + '</b>');
	}

    // showLocation() is called when you click on the Search button
    // in the form.  It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation(adress,nome) {
	  Nome =  nome
      geocoder.getLocations(adress, addAddressToMap);
    }


