function loadMap() {
    if (GBrowserIsCompatible()) {
      var side_bar_html = "";
      var gmarkers = [];
      var htmls = [];
      var i = 0;
			var cluster;

      // === Create an associative array of GIcons() ===
     var iconBlue = new GIcon(); 
    iconBlue.image = 'http://pghbridges.com/assets/images/mm_20_blue.png';
    iconBlue.shadow = null;
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = null;
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

    var iconGrey = new GIcon(); 
    iconGrey.image = 'http://pghbridges.com/assets/images/mm_20_gray.png';
    iconGrey.shadow = null;
    iconGrey.iconSize = new GSize(12, 20);
    iconGrey.shadowSize = null;
    iconGrey.iconAnchor = new GPoint(6, 20);
    iconGrey.infoWindowAnchor = new GPoint(5, 1);

    var iconGreen = new GIcon(); 
    iconGreen.image = 'http://pghbridges.com/assets/images/mm_20_green.png';
    iconGreen.shadow = null;
    iconGreen.iconSize = new GSize(12, 20);
    iconGreen.shadowSize = null;
    iconGreen.iconAnchor = new GPoint(6, 20);
    iconGreen.infoWindowAnchor = new GPoint(5, 1);

    var iconBrown = new GIcon(); 
    iconBrown.image = 'http://pghbridges.com/assets/images/mm_20_brown.png';
    iconBrown.shadow = null;
    iconBrown.iconSize = new GSize(12, 20);
    iconBrown.shadowSize = null;
    iconBrown.iconAnchor = new GPoint(6, 20);
    iconBrown.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["auto"] = iconBlue;
    customIcons["rail"] = iconGrey;
    customIcons["ped"] = iconGreen;
    customIcons["tunnel"] = iconBrown;

 
      // A function to create the marker and set up the event window
      function createMarker(point,name,html,icontype) {
        var marker = new GMarker(point, customIcons[icontype]);
        // === store the name so that the tooltip function can use it ===
        marker.tooltip = '<div class="tooltip"><nobr>'+name+'</nobr></div>';
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        gmarkers[i] = marker;
        htmls[i] = html;
        side_bar_html += '<a href="javascript:myclick(' + i + ')" onmouseover="mymouseover('+i+')" onmouseout="mymouseout()">' + name + '</a><br>';
        i++;
				
        //	map.addOverlay(marker);

        //  ======  The new marker "mouseover" and "mouseout" listeners  ======
        GEvent.addListener(marker,"mouseover", function() {
          showTooltip(marker);
        });        
        GEvent.addListener(marker,"mouseout", function() {
		tooltip.style.visibility="hidden"
        });        
      }

      // ====== This function displays the tooltip ======
      // it can be called from an icon mouseover or a side_bar mouseover
      function showTooltip(marker) {
      	tooltip.innerHTML = marker.tooltip;
	var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());
	var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
	var anchor=marker.getIcon().iconAnchor;
	var width=marker.getIcon().iconSize.width;
	var height=tooltip.clientHeight;
	var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - point.x - anchor.x + width, offset.y - point.y -anchor.y -height)); 
	pos.apply(tooltip);
	tooltip.style.visibility="visible";
      }

      // ===== This function is invoked when the mouse goes over an entry in the side_bar =====
      // It launches the tooltip on the icon      
      function mymouseover(i) {
        showTooltip(gmarkers[i])
      }
      // ===== This function is invoked when the mouse leaves an entry in the side_bar =====
      // It hides the tooltip      
      function mymouseout() {
	tooltip.style.visibility="hidden";
      }

      // This function picks up the side_bar click and opens the corresponding info window
      function myclick(i) {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }


      // create the map
      var map = new GMap2(document.getElementById("map"));

      //  create a ClusterMarker
      cluster=new ClusterMarker(map);

      document.getElementById("map").style.backgroundImage = "url(http://pghbridges.com/assets/images/loading_data.gif)";

      map.addControl(new GSmallMapControl());
      map.addControl(new GHierarchicalMapTypeControl());


		map.addMapType(G_PHYSICAL_MAP);
      map.setCenter(new GLatLng(40.452515,-80.023985), 10);

      // ====== set up marker mouseover tooltip div ======
      var tooltip = document.createElement("div");
      map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
      tooltip.style.visibility="hidden";


      // Read the data from .xml
      var request = GXmlHttp.create();
      request.open("GET", "http://pghbridges.com/assets/alleghenycountyA_tpk.xml", true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          var xmlDoc = GXml.parse(request.responseText);
          // obtain the array of markers and loop through it
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
          
          for (var i = 0; i < markers.length; i++) {
            // obtain the attributes 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");
             // === read the icontype attribute ===
            var icontype = markers[i].getAttribute("icontype");
           // create the marker
            var marker = createMarker(point,label,html,icontype);
          }
					// global array gmarkers should now contain all markers so we'll add them to the ClusterMarker
					cluster.addMarkers(gmarkers);

					// initial view option 1: map automatically zooms to fit all markers within viewport
					cluster.fitMapToMarkers();
				/*
					// initial view option 2: map drawn as set in setCenter with specified zoom
					cluster.refresh();
				*/


          // ========= Now process the polylines ===========
          var lines = xmlDoc.documentElement.getElementsByTagName("line");
          // read each line
          for (var a = 0; a < lines.length; a++) {
            // get any line attributes
            var colour = lines[a].getAttribute("colour");
            var width  = parseFloat(lines[a].getAttribute("width"));
            // read each point on that line
            var points = lines[a].getElementsByTagName("point");
            var pts = [];
            for (var i = 0; i < points.length; i++) {
               pts[i] = new GLatLng(parseFloat(points[i].getAttribute("lat")),
                                   parseFloat(points[i].getAttribute("lng")));
            }
            map.addOverlay(new GPolyline(pts,colour,width));
          }
          // ================================================           
        }
      }
      request.send(null);
    }

    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://econym.googlepages.com/index.htm

	// ClusterMarker js: Martin Pearman
	// http://googlemapsapi.martinpearman.co.uk/clustermarker

	// Additional coding: Bruce S. Cridlebaugh, pghbridges.com


