    if (GBrowserIsCompatible()) {
    	
      // this variable will collect the html which will eventualkly be placed in the side_bar
      var side_bar_html = "";
      side_bar_html += "<h3>Areas</h3>";
      side_bar_html += "<ul>";
   
      // 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;
      // arrays to hold variants of the info window html with get direction forms open
      var to_htmls = [];
      var from_htmls = [];

      // Create custom image
      var Icon = new GIcon();
      Icon.image = "oflag.PNG";
      Icon.iconSize = new GSize(16, 16);
      Icon.iconAnchor = new GPoint(5, 15);
      Icon.infoWindowAnchor = new GPoint(5, 2);

      // A function to read the header
      function qs() {
      var query = window.location.search.substring(1);
      var parms = query.split('&');
      for (var i=0; i<parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
          var key = parms[i].substring(0,pos);
          key = key.toLowerCase();
          var val = parms[i].substring(pos+1);
          qsParm[key] = val;
          }
        }
      }
 

      // A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point,Icon);

        // The info window version with the "to here" form open
        to_htmls[i] = html + '<br>Directions: <b>To here</b> - <a href="javascript:fromhere(' + i + ')">From here</a>' +
           '<br>Start address:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + 
                  // "(" + name + ")" + 
           '"/>';
        // The info window version with the "to here" form open
        from_htmls[i] = html + '<br>Directions: <a href="javascript:tohere(' + i + ')">To here</a> - <b>From here</b>' +
           '<br>End address:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
                  // "(" + name + ")" + 
           '"/>';
        // The inactive version of the direction info
        html = html + '<br>Directions: <a href="javascript:tohere('+i+')">To here</a> - <a href="javascript:fromhere('+i+')">From here</a>';

        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        gmarkers[i] = marker;
        htmls[i] = html;
        // add a line to the side_bar html
        side_bar_html += '<li><a href="javascript:myclick(' + i + ')">' + name + '</a></li>';
        i++;
        return marker;
      }

      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }

      // functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
      }

     // Get data from command line
     var qsParm = new Array();
     qsParm['xml'] = null;
     qs();
 
      // create the map
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(56.05823595559604, -3.85894775390625), 10);


      // Read the data from example.xml
      var request = GXmlHttp.create();
      request.open("GET", qsParm['xml'], true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          var xmlDoc = request.responseXML;
          // 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 attribues of each marker
            var os6  = markers[i].getAttribute("htmlx");       
	    var label = markers[i].getAttribute("label");
	    if (os6) {
              var os6x = getOSRefFromSixFigureReference(os6);
              var ll1w = os6x.toLatLng(os6x);
              ll1w.OSGB36ToWGS84();
              lat = ll1w.lat;
              lng = ll1w.lng;
              var point = new GLatLng(lat,lng);
              var html = markers[i].getAttribute("html1")+markers[i].getAttribute("htmlx")+markers[i].getAttribute("html2");

              var east  = os6x.easting;
              var north = os6x.northing;
              os6Streetmap = "X=" + east.toString() + "&amp;Y=" + north.toString();
              html = html +'<br>'+ '<a href="http://www.streetmap.co.uk/streetmap.dll?G2M?'+ os6Streetmap + '&A=Y&Z=4" target="_blank"> Click here for OS map</a></br>';
              // create the marker
              var marker = createMarker(point,label,html);
              map.addOverlay(marker);
	    }
	    else {
		side_bar_html = side_bar_html + "<li><a>" + label + "</a></li>";
	    }
          }
          // put the assembled side_bar_html contents into the side_bar div
          document.getElementById("leftnavigation").innerHTML = side_bar_html;
        }
      }
      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://www.econym.demon.co.uk/googlemaps/

