    // Create our "type" marker icons 
    var bushwalkIcon = new GIcon(); 
    bushwalkIcon.image = "http://www.toptrails.com.au/siteimages/pins/bush-walk.png";
    bushwalkIcon.shadow = "http://www.toptrails.com.au/siteimages/pins/shadow50.png";
    bushwalkIcon.iconSize = new GSize(20, 34);
    bushwalkIcon.shadowSize = new GSize(37, 34);
    bushwalkIcon.iconAnchor = new GPoint(9, 34);
    bushwalkIcon.infoWindowAnchor = new GPoint(9, 2);
    
    var urbanwalkIcon = new GIcon(); 
    urbanwalkIcon.image = "http://www.toptrails.com.au/siteimages/pins/urban-walk.png";
    urbanwalkIcon.shadow = "http://www.toptrails.com.au/siteimages/pins/shadow50.png";
    urbanwalkIcon.iconSize = new GSize(20, 34);
    urbanwalkIcon.shadowSize = new GSize(37, 34);
    urbanwalkIcon.iconAnchor = new GPoint(9, 34);
    urbanwalkIcon.infoWindowAnchor = new GPoint(9, 2);
    
    var cycleIcon = new GIcon(); 
    cycleIcon.image = "http://www.toptrails.com.au/siteimages/pins/cycle.png";
    cycleIcon.shadow = "http://www.toptrails.com.au/siteimages/pins/shadow50.png";
    cycleIcon.iconSize = new GSize(20, 34);
    cycleIcon.shadowSize = new GSize(37, 34);
    cycleIcon.iconAnchor = new GPoint(9, 34);
    cycleIcon.infoWindowAnchor = new GPoint(9, 2);
    
    var mountainbikeIcon = new GIcon(); 
    mountainbikeIcon.image = "http://www.toptrails.com.au/siteimages/pins/mountain-bike.png";
    mountainbikeIcon.shadow = "http://www.toptrails.com.au/siteimages/pins/shadow50.png";
    mountainbikeIcon.iconSize = new GSize(20, 34);
    mountainbikeIcon.shadowSize = new GSize(37, 34);
    mountainbikeIcon.iconAnchor = new GPoint(9, 34);
    mountainbikeIcon.infoWindowAnchor = new GPoint(9, 2);
    
    var paddleIcon = new GIcon(); 
    paddleIcon.image = "http://www.toptrails.com.au/siteimages/pins/paddle.png";
    paddleIcon.shadow = "http://www.toptrails.com.au/siteimages/pins/shadow50.png";
    paddleIcon.iconSize = new GSize(20, 34);
    paddleIcon.shadowSize = new GSize(37, 34);
    paddleIcon.iconAnchor = new GPoint(9, 34);
    paddleIcon.infoWindowAnchor = new GPoint(9, 2);
    
    var snorkelIcon = new GIcon(); 
    snorkelIcon.image = "http://www.toptrails.com.au/siteimages/pins/snorkel.png";
    snorkelIcon.shadow = "http://www.toptrails.com.au/siteimages/pins/shadow50.png";
    snorkelIcon.iconSize = new GSize(20, 34);
    snorkelIcon.shadowSize = new GSize(37, 34);
    snorkelIcon.iconAnchor = new GPoint(9, 34);
    snorkelIcon.infoWindowAnchor = new GPoint(9, 2);
    
    var equestrianIcon = new GIcon(); 
    equestrianIcon.image = "http://www.toptrails.com.au/siteimages/pins/equestrian.png";
    equestrianIcon.shadow = "http://www.toptrails.com.au/siteimages/pins/shadow50.png";
    equestrianIcon.iconSize = new GSize(20, 34);
    equestrianIcon.shadowSize = new GSize(37, 34);
    equestrianIcon.iconAnchor = new GPoint(9, 34);
    equestrianIcon.infoWindowAnchor = new GPoint(9, 2);
    
    var driveIcon = new GIcon(); 
    driveIcon.image = "http://www.toptrails.com.au/siteimages/pins/drive.png";
    driveIcon.shadow = "http://www.toptrails.com.au/siteimages/pins/shadow50.png";
    driveIcon.iconSize = new GSize(20, 34);
    driveIcon.shadowSize = new GSize(37, 34);
    driveIcon.iconAnchor = new GPoint(9, 34);
    driveIcon.infoWindowAnchor = new GPoint(9, 2);
    

    var customIcons = [];
    customIcons["bushwalk"] = bushwalkIcon;
    customIcons["urbanwalk"] = urbanwalkIcon;
    customIcons["cycle"] = cycleIcon;
    customIcons["mountainbike"] = mountainbikeIcon;
    customIcons["paddle"] = paddleIcon;
    customIcons["snorkel"] = snorkelIcon;
    customIcons["equestrian"] = equestrianIcon;
    customIcons["drive"] = driveIcon;
    

    // Create marker groups
    var markerGroups = { "bushwalk": [], "urbanwalk": [], "cycle": [], "mountainbike": [], "paddle": [], "snorkel": [], "equestrian": [], "drive": []};

    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("browsemap"));
        map.setCenter(new GLatLng(-25.363882,120.27832), 5);
        map.setUIToDefault();

        GDownloadUrl("trail_markers.xml", function(data, responseCode) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var type = markers[i].getAttribute("type");
            var description = markers[i].getAttribute("description");
            var href = markers[i].getAttribute("href");
            var dimage = markers[i].getAttribute("dimage");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, name, type, description, href, dimage);
            map.addOverlay(marker);
          }
        });

      }
    }

    function createMarker(point, name, type, description, href, dimage) {
      var marker = new GMarker(point, customIcons[type]);
      markerGroups[type].push(marker);
      var html = "<h4 class='gpoptitle type-" + type + "'>" + name + "</h4><p><img src='" + dimage + "' class='gpopimg' width='80' height='60' />" + description + "</p><p><a href='" + href + "' class='gpopmore'>More about this trail&hellip;</a></p>";
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html, {maxWidth:320});
      });
      return marker;
    }

    function toggleGroup(type) {
      for (var i = 0; i < markerGroups[type].length; i++) {
        var marker = markerGroups[type][i];
        if (marker.isHidden()) {marker.show();} else {marker.hide();}
      } 
    }

    function zoomToRegion(lat,lng,zoom) {
        var geo = new GLatLng(parseFloat(lat),
                                    parseFloat(lng));
        var zoom = parseFloat(zoom);
        map.setCenter(new GLatLng(lat,lng), zoom);
    }