function loadMap(days) {
  if (!GBrowserIsCompatible()) { // Show friendly msg if user's browser is not compatible
    var message = '<h2>Your browser is not supported by our Google Maps event viewer.</h2><p>We currently support the following browsers:</p><ul><li><a href="http://www.microsoft.com/windows/ie/downloads/default.asp">IE</a> 5.5+ (Windows)</li><li><a href="http://www.mozilla.com/firefox/">Firefox</a> 0.8+ (Windows, Mac, Linux)</li><li><a href="http://browser.netscape.com/">Netscape</a> 7.1+ (Windows, Mac, Linux)</li><li><a href="http://www.mozilla.org/products/mozilla1.x/">Mozilla</a> 1.4+ (Windows, Mac, Linux)</li><li><a href="http://www.apple.com/safari/">Safari</a> 1.2+ (Mac)</li><li><a href="http://www.opera.com/">Opera</a> 7+ (Windows, Mac, Linux)</li></ul>';
    document.writeln (message);
    exit;
  }

  // Create marker icons
  var baseIcon = new GIcon();
  baseIcon.shadow = "icon_shadow.png";
  baseIcon.iconSize = new GSize(12, 20);
  baseIcon.shadowSize = new GSize(22, 20);
  baseIcon.iconAnchor = new GPoint(6, 20);
  baseIcon.infoWindowAnchor = new GPoint(5, 1);
  
  var icon_color = new Array();
  icon_color["Dedications, Ceremonies & Memorials"] = "blue";
  icon_color["Exhibits & Shows"] = "red";
  icon_color["Live Performances"] = "purple";
  icon_color["Outdoor Activities"] = "green";
  icon_color["Public Lectures, Open Houses & Tours"] = "brown";
  icon_color["Publications & Books"] = "yellow";
  icon_color["TV Shows, Films, Music & Radio"] = "black";
  icon_color["Web Resources"] = "grey";
  icon_color["Workshops & Conferences"] = "orange";
  
  // Create Map and controls; set map extent
  var map = new GMap(document.getElementById("map"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());    
  map.centerAndZoom(new GPoint(-122.1753, 37.6797), 8);
  map.setMapType(G_MAP_TYPE);
  
  // Add mouse wheel zoom functionality
  GEvent.addListener(map, "wheelup", function(p) {
    if (map.getZoomLevel() > 0 ) {
      map.centerAndZoom(p.scaleRelative(map.getCenterLatLng() ), map.getZoomLevel() - 1);
    }
  });
  GEvent.addListener(map, "wheeldown", function(p) {
    if (map.getZoomLevel() <= 16 ) {
      map.centerAndZoom(p.scaleRelative(map.getCenterLatLng(), -1 ), map.getZoomLevel() + 1);
    }
  });

  // Add "click zoom" functionality
  GEvent.addListener(map, "click", function(o,p) {
    if (o != null) return;
    if (map.getZoomLevel() > 1) {
      map.centerAndZoom( p, map.getZoomLevel() - 1);
    } else if (map.getZoomLevel() == 1) {
      map.centerAndZoom( p, 0 );
    }
  });

  // Creates markers at given point
  function createMarker(point, html, icon_type) {
    var marker = new GMarker(point, icon_type);
    map.addOverlay(marker);
    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(html);
    });
  }
  
  // Use AJAX to download events XML file and display it
  var request = GXmlHttp.create();
  request.open("GET", "points.php?days=" + days, true);
  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      var xmlDoc = request.responseXML;
      var markers = xmlDoc.documentElement.getElementsByTagName("marker");
      for (var i = 0; i < markers.length; i++) {
  
        lon = parseFloat(markers[i].getAttribute("lon"));
        lat = parseFloat(markers[i].getAttribute("lat"));
        title = markers[i].getAttribute("title");
        date = markers[i].getAttribute("date");
        description = markers[i].getAttribute("description");
        type = markers[i].getAttribute("type").replace('&#38;', '&'); type = type.replace('&amp;', '&');
        link = markers[i].getAttribute("link");
        
        info = '<div style=\"width:300px;\"><p><strong>' + title + '</strong><br />' + date + '</p><p><a href="' + link + '">Event details</a> &raquo;</p></div>';            
        var icon = new GIcon(baseIcon);
        color = icon_color[type];
        icon.image = "icon_" + color + ".png";
        
        createMarker(new GPoint(lon, lat), info, icon);
      }
    }
  }
  request.send(null);  
}