if (GBrowserIsCompatible()) {

	// ==== first part of the select box ===
	var select_html = '<select onChange="handleSelected(this)">' +
				'<option> - Headway Location - <\/option>';
	// =====================================

	// arrays to hold copies of the markers and html used by the side_bar
	// because the function closure trick doesnt work there
	var gmarkers = [];
	var htmls = [];
	var i = 0;

	// A function to create the marker and set up the event window
	function createMarker(point,name,html) {
	  var marker = new GMarker(point, {title:name});
	  GEvent.addListener(marker, "click", function() {
	    map.setZoom(14);
	    marker.openInfoWindowHtml(html);
	  });
	  // save the info we need to use later for the side_bar
	  gmarkers[i] = marker;
	  htmls[i] = html;

	  // ======= Add the entry to the select box =====
	  select_html += '<option> ' + name + '<\/option>';
	  // ==========================================================

	  i++;
	  return marker;
	}


	// ======= This function handles selections from the select box ====
	// === If the dummy entry is selected, the info window is closed ==
	function handleSelected(opt) {
	  var i = opt.selectedIndex - 1; 
	  if (i > -1) {
	  map.setZoom(7);
	    GEvent.trigger(gmarkers[i],"click");
	  }
	  else {
	    map.closeInfoWindow();
	  }
	}

			// create the map
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallZoomControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(newLat, newLng), newZmm);

			//enable smooth zooming
			map.enableContinuousZoom();
			map.enableDoubleClickZoom();


	// Read the data from 100.xml
	GDownloadUrl("/xml/gmap_headwaylocations.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);
	  }

	 // ===== final part of the select box =====
	  select_html += '</select>';
	  document.getElementById("selection").innerHTML = select_html;

	});


}

else {
	alert("Sorry, the Google Maps API is not compatible with this browser");
}

// This Javascript is based on code provided by the
// Blackpool Community Church Javascript Team
// http://www.commchurch.freeserve.co.uk/   
// http://www.econym.demon.co.uk/googlemaps/