window.onload = onPageLoad;
window.onunload = "GUnload()";
function onPageLoad() {
	if (GBrowserIsCompatible()) { 

      // A function to create the marker and set up the event window
      // Dont try to unroll this function. It has to be here for the function closure
      // Each instance of the function preserves the contends of a different instance
      // of the "marker" and "html" variables which will be needed later when the event triggers.    
      function createMarker(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }

      // Display the map, with some controls and set the initial location 
      var map = new GMap2(document.getElementById("google-map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(46.47649, 11.74178), 15);
	  map.setMapType(G_HYBRID_MAP);
    
      // Set up markers with info windows 
    
      var point = new GLatLng(46.47710, 11.74432);
      var marker = createMarker(point,'<div style="width:220px;height:195px;"><p>Hotel Le Rocce</p><p><img src="../../wp-content/themes/hotellerocce.it/google-map-1.jpg" /></p></div>')
      map.addOverlay(marker);

      var point = new GLatLng(46.47487, 11.74571);
      var marker = createMarker(point,'<div style="width:220px;height:195px;"><p>Funivia Rodella (Cablecar)</p><p><img src="../../wp-content/themes/hotellerocce.it/google-map-2.jpg" /></p></div>')
      map.addOverlay(marker);

    }
    
    // display a warning if the browser was not compatible
    else {
      alert("Attenzione, le Google Maps non sono compatibili con questo browser");
    }
}