

    if (GBrowserIsCompatible()) {
      // this variable will collect the html which will eventually be placed in the map_links
      var map_links_html = "";
    
      // arrays to hold copies of the markers used by the map_links
      // because the function closure trick doesnt work there
      var gmarkers = [];

      // A function to create the marker and set up the event window
      function createMarker(point,name) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          map.panTo(point);;
        });
        // save the info we need to use later for the map_links
        gmarkers.push(marker);
        // add a line to the map_links html
        map_links_html += '<a href="javascript:myclick(' + (gmarkers.length-1) + ')">' + name + '<\/a><br>';
        return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        GEvent.trigger(gmarkers[i], "click");
      }


      // create the map
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng( 42.5502056,-70.8779378), 15);


      // Read the data from xml file
      GDownloadUrl("xml/locations.xml", function(doc) {
        var xmlDoc = GXml.parse(doc);
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");
          
        for (var i = 0; i < markers.length; i++) {
          // obtain the attribues of each marker
          var lat = parseFloat(markers[i].getAttribute("lat"));
          var lng = parseFloat(markers[i].getAttribute("lng"));
          var point = new GLatLng(lat,lng);
          var html = markers[i].getAttribute("html");
          var label = markers[i].getAttribute("label");
          // create the marker
          var marker = createMarker(point,label,html);
          map.addOverlay(marker);
        }
        // put the assembled map_links_html contents into the map_links div
        document.getElementById("map_links").innerHTML = map_links_html;
      });
    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

    // This Javascript is based on code provided by the
    // Community Church Javascript Team
    // http://www.bisphamchurch.org.uk/   
    // http://econym.org.uk/gmap/

    //]]>
   
