function initializeMap(lat, lon, name)
{
  if (GBrowserIsCompatible())
  {
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(42.212245162885800, 12.590332031250000), 10, G_HYBRID_MAP);

    var customUI = map.getDefaultUI();
    customUI.controls.scalecontrol = false;
    map.setUI(customUI);

    if(lat == 0.0 && lon == 0.0)
      return;

    var point = new GLatLng(lat, lon);
    var content = "<p><b>" + name + "</b></p>";
    var marker = createMarker(point, content);
    map.setCenter(point, 15);
    map.addOverlay(marker);
    marker.openInfoWindowHtml(content);
  }
}

var geocoder;
function showAddress(address, name, map)
{
  geocoder.getLatLng(address,
    function(point){
      if (!point)
        alert("Indirizzo non trovato!");
      else
      {
        var content = "Nome:" + "<p><b>" + name + "</b></p><br/>Indirizzo: <p><b>" + address + "</b></p>";
        map.setCenter(point, 15);
        var marker = createMarker(point, content);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(content);
      }
    });
}

function createMarker(point, content)
{
  var marker = new GMarker(point);
  GEvent.addListener(marker, "click",
    function(){
      marker.openInfoWindowHtml('<div>' + content + '</div>');
  });
  return marker;
}

function getIcon()
{
  var icon = new GIcon();
  icon.image = SITE_CONTEXT + "images/pushpin.png";
  icon.shadow = SITE_CONTEXT + "images/shadow-pushpin.png";
  icon.iconSize = new GSize(20.0, 64.0);
  icon.shadowSize = new GSize(53.0, 64.0);
  icon.iconAnchor = new GPoint(10.0, 32.0);
  icon.infoWindowAnchor = new GPoint(10.0, 32.0);
  return icon;
}

function getMiniMarkerIcon()
{
  var icon = new GIcon();
  icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
  icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  icon.iconSize = new GSize(12, 20);
  icon.shadowSize = new GSize(22, 20);
  icon.iconAnchor = new GPoint(6, 20);
  return icon;
}
