﻿    if (GBrowserIsCompatible()) { 

      // A function to create the marker and set up the event window
      // Dont try to unroll this function. It has to be here for the function closure
      // Each instance of the function preserves the contends of a different instance
      // of the "marker" and "html" variables which will be needed later when the event triggers.    
      function createMarker(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }

      // Display the map, with some controls and set the initial location 
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(54.392339, -2.925110), 9);
    
      // Set up three markers with info windows
      
      //var point = new GLatLng(54.006502998949486,-2.7888885140419006);
      //var marker = createMarker(point,'Lancaster House Hotel')
      //map.addOverlay(marker);

      //var point = new GLatLng(54.072087, -2.875167);
      //var marker = createMarker(point, 'Midland Hotel')
      //map.addOverlay(marker);

      //world of beatrix potter
      var point = new GLatLng(54.365325, -2.919078);
      var marker = createMarker(point, '<div style="width:240px;"><img src="../../Images/attractions/thumbnails/mrs-tiddiewinkle.jpg" alt="Mrs Tiddiewinkle." class="right"  /><h3>World of Beatrix Potter</h3><p>Re-creations of the world famous stories of Beatrix Potter.<br /><a href="world-of-beatrix-potter.aspx">More...</a></p></div>')
     map.addOverlay(marker);

     //Windermere Lake Cruises
     var point = new GLatLng(54.362823, -2.922790);
     var marker = createMarker(point, '<div style="width:240px;"><img src="../../Images/attractions/thumbnails/lakes-cruises.jpg" alt="One of the Windermere Lakes Cruises boats on the lake." class="right" /><h3>Lake Cruises</h3><p>A fleet of steamers and launches sailing daily, all year.<br /><a href="windermere-lakes-cruises.aspx">More...</a></p></div>')
     map.addOverlay(marker);

     //Blackwell
     var point = new GLatLng(54.343067, -2.923602);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/blackwell.jpg" alt="Feature at Blackwell House" width="80" height="80" class="right" /><h3>Blackwell House</h3><p>Arts and Crafts house of international importance.<br /><a href="blackwell-house.aspx">More...</a></p></div>')
      map.addOverlay(marker);
    
    //Rydal Mount
      var point = new GLatLng(54.448726, -2.982445);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/rydal.jpg" alt="Slate garden steps covered in red maple leaves" class="right" /><h3>Rydal Mount</h3><p>Enjoy William Wordsworths 18th century home and gardens.<br /><a href="rydal-mount.aspx">More...</a></p></div>')
      map.addOverlay(marker);

      //Lakes Aquarium
      var point = new GLatLng(54.278323, -2.955950);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/lakes-aquarium.jpg" alt="Interactive feature at the Aquarium" class="right" /><h3>Lakes Aquarium</h3><p>Popular lake district attraction exploring the lakes of the world.<br /><a href="lakes-aquarium.aspx">More...</a></p></div>')
      map.addOverlay(marker);

    //Armitt
      var point = new GLatLng(54.434164, -2.963272);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/armit.jpg" alt="Kurt Schwitters portrait" class="right" /><h3>Armitt Museum</h3><p>Explore the history of Ambleside in this unique museum setting.<br /><a href="armitt-museum.aspx">More...</a></p></div>')
      map.addOverlay(marker);

      //dove cottage
      var point = new GLatLng(54.454518, -3.016680);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/daffodil.jpg" alt="Daffodil" class="right" /><h3>Dove Cottage</h3><p>William Wordsworths home from 1799-1808.<br /><a href="dove-cottage.aspx">More...</a></p></div>')
      map.addOverlay(marker);

      //levens hall
      var point = new GLatLng(54.258992, -2.776237);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/levens.jpg" alt="The topiary gardens at Levens" class="right" /><h3>Levens Hall</h3><p>Levens Hall and world famous topiary gardens.<br /><a href="levens-hall.aspx">More...</a></p></div>')
      map.addOverlay(marker);

      //holker hall
      var point = new GLatLng(54.187413, -2.982692);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/holker.jpg" alt="Gardens at Holker" class="right" /><h3>Holker Hall</h3><p>Award winning hall and gardens and Lakeland Motor Museum.<br /><a href="holker-hall.aspx">More...</a></p></div>')
      map.addOverlay(marker);

      //ullswater steamers
      var point = new GLatLng(54.541777, -2.947726);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/steamer.jpg" alt="Ullswater steamer on the lake." class="right" /><h3>Ullswater Steamers</h3><p>Award winning Lake District attraction on Englands most beautiful lake.<br /><a href="ullswater-steamers.aspx">More...</a></p></div>')
      map.addOverlay(marker);

      //hilltop
      var point = new GLatLng(54.352316, -2.970643);
      var marker = createMarker(point, '<div style="width:240px"><img src="../../Images/attractions/thumbnails/hilltop.jpg" alt="Garden bench and path in the Hilltop gardens" class="right" /><h3>Hill Top</h3><p>Beatrix Potters 17th century lakeland home.<br /><a href="hilltop.aspx">More...</a></p></div>')
      map.addOverlay(marker);
	  

      
       //  ======== Add a map overview ==========
      map.addControl(new GOverviewMapControl(new GSize(150,150)));

      //  ======== A function to adjust the positioning of the overview ========
      function positionOverview(x,y) {
        var omap=document.getElementById("map_overview");
        omap.style.left = x+"px";
        omap.style.top = y+"px";
        
        // == restyling ==
        omap.firstChild.style.border = "1px solid gray";

        omap.firstChild.firstChild.style.left="2px";
        omap.firstChild.firstChild.style.top="2px";
        omap.firstChild.firstChild.style.width="140px";
        omap.firstChild.firstChild.style.height="140px";
        }
        //  ======== Cause the overview to be positioned AFTER IE sets its initial position ======== 
//      setTimeout("positionOverview(558,254)",1);
    }
    
    // display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
