if (GBrowserIsCompatible()) {
      // this variable will collect the html which will eventually be placed in the sidebar
      var sidebar_html = "";
      // arrays to hold copies of the markers and html used by the sidebar
      // because the function closure trick doesnt work there
          var htmls = [];
          var gmarkers = [];
          var points = [];
          var i = 0;


      // A function to create the marker and set up the event window
          // IF statements assign icons to the markers based on the "color" variable
      function createMarker(point,name,imgurl,color,address,html) {
        if (color == "kitty1")
                var marker = new GMarker(point, icon0);
        if (color == "kitty")
                var marker = new GMarker(point, icon1);
        if (color == "photo")
                var marker = new GMarker(point, icon2);
        if (color == "note")
                var marker = new GMarker(point, icon3);
        if (color == "vw")
                var marker = new GMarker(point, icon4);
        if (color == "home")
                var marker = new GMarker(point, icon5);
        if (color == "drink")
                var marker = new GMarker(point, icon6);
        if (color == "eat")
                var marker = new GMarker(point, icon7);
        if (color == "sleep")
                var marker = new GMarker(point, icon8);
        if (color == "tree")
                var marker = new GMarker(point, icon9);
        if (color == "see")
                var marker = new GMarker(point, icon10);
        if (color == "star")
                var marker = new GMarker(point, icon11);
        if (color == "peep")
                var marker = new GMarker(point, icon12);

                htmls[i] = html;
        GEvent.addListener(marker, "click", function() {
                  map.closeInfoWindow();
          marker.openInfoWindowHtml(html);
                  loadDetailMap2(point);

        });
        // save the info we need to use later for the sidebar
        gmarkers[i] = marker;
        points[i] = point;
        // add a line to the sidebar html

        sidebar_html += '<td width="15" bgcolor="#FFFFFF"><img src="img/' + color + '1.gif"></td><td width="100"><a href="javascript:myclick(' + i   + ')">' + name + '</a></td></tr>';
        i++;
        return marker;
      }

      // This function picks up the click and opens the corresponding info window
      function myclick(i, point) {
                  map.closeInfoWindow();
        gmarkers[i].openInfoWindowHtml(htmls[i])
                loadDetailMap(i);
      }


// Create our custom marker icons
var icon0 = new GIcon();
icon0.image = "img/kitty1.gif";
icon0.shadow = "img/k1shadow.png";
icon0.iconSize = new GSize(18, 16);
icon0.shadowSize = new GSize(26, 20);
icon0.iconAnchor = new GPoint(8, 8);
icon0.infoWindowAnchor = new GPoint(9, 2);
icon0.infoShadowAnchor = new GPoint(48, 45);

var icon1 = new GIcon();
icon1.image = "img/kitty.gif";
icon1.shadow = "img/kshadow.png";
icon1.iconSize = new GSize(18, 16);
icon1.shadowSize = new GSize(26, 20);
icon1.iconAnchor = new GPoint(8, 8);
icon1.infoWindowAnchor = new GPoint(9, 2);
icon1.infoShadowAnchor = new GPoint(48, 45);


var icon2 = new GIcon();
icon2.image = "img/photo.png";
icon2.shadow = "img/photos.png";
icon2.iconSize = new GSize(18, 16);
icon2.shadowSize = new GSize(26, 24);
icon2.iconAnchor = new GPoint(8, 18);
icon2.infoWindowAnchor = new GPoint(9, 2);
icon2.infoShadowAnchor = new GPoint(18, 25);

var icon3 = new GIcon();
icon3.image = "img/note.png";
icon3.shadow = "img/notes.png";
icon3.iconSize = new GSize(18, 18);
icon3.shadowSize = new GSize(26, 25);
icon3.iconAnchor = new GPoint(8, 18);
icon3.infoWindowAnchor = new GPoint(9, 2);
icon3.infoShadowAnchor = new GPoint(18, 25);

var icon4 = new GIcon();
icon4.image = "img/vw.png";
icon4.shadow = "img/vws.png";
icon4.iconSize = new GSize(24, 24);
icon4.shadowSize = new GSize(30, 30);
icon4.iconAnchor = new GPoint(8, 8);
icon4.infoWindowAnchor = new GPoint(9, 2);
icon4.infoShadowAnchor = new GPoint(38, 38);

var icon5 = new GIcon();
icon5.image = "img/home.png";
icon5.shadow = "img/homes.png";
icon5.iconSize = new GSize(18, 17);
icon5.shadowSize = new GSize(24, 25);
icon5.iconAnchor = new GPoint(8, 8);
icon5.infoWindowAnchor = new GPoint(9, 2);
icon5.infoShadowAnchor = new GPoint(28, 25);

var icon6 = new GIcon();
icon6.image = "img/drink.png";
icon6.shadow = "img/drinks.png";
icon6.iconSize = new GSize(21, 22);
icon6.shadowSize = new GSize(29, 29);
icon6.iconAnchor = new GPoint(8, 8);
icon6.infoWindowAnchor = new GPoint(9, 2);
icon6.infoShadowAnchor = new GPoint(28, 25);

var icon7 = new GIcon();
icon7.image = "img/eat.png";
icon7.shadow = "img/eats.png";
icon7.iconSize = new GSize(14, 17);
icon7.shadowSize = new GSize(22, 25);
icon7.iconAnchor = new GPoint(8, 8);
icon7.infoWindowAnchor = new GPoint(9, 2);
icon7.infoShadowAnchor = new GPoint(28, 25);

var icon8 = new GIcon();
icon8.image = "img/sleep.png";
icon8.shadow = "img/sleeps.png";
icon8.iconSize = new GSize(20, 14);
icon8.shadowSize = new GSize(25, 20);
icon8.iconAnchor = new GPoint(8, 8);
icon8.infoWindowAnchor = new GPoint(9, 2);
icon8.infoShadowAnchor = new GPoint(28, 25);


var icon9 = new GIcon();
icon9.image = "img/tree.png";
icon9.shadow = "img/trees.png";
icon9.iconSize = new GSize(17, 26);
icon9.shadowSize = new GSize(23, 32);
icon9.iconAnchor = new GPoint(8, 8);
icon9.infoWindowAnchor = new GPoint(9, 2);
icon9.infoShadowAnchor = new GPoint(28, 25);

var icon10 = new GIcon();
icon10.image = "img/see.png";
icon10.shadow = "img/sees.png";
icon10.iconSize = new GSize(19, 24);
icon10.shadowSize = new GSize(23, 31);
icon10.iconAnchor = new GPoint(8, 8);
icon10.infoWindowAnchor = new GPoint(9, 2);
icon10.infoShadowAnchor = new GPoint(28, 25);

var icon11 = new GIcon();
icon11.image = "img/star.png";
icon11.shadow = "img/stars.png";
icon11.iconSize = new GSize(16, 17);
icon11.shadowSize = new GSize(22, 23);
icon11.iconAnchor = new GPoint(8, 8);
icon11.infoWindowAnchor = new GPoint(9, 2);
icon11.infoShadowAnchor = new GPoint(28, 25);


var icon12 = new GIcon();
icon12.image = "img/lju.png";
icon12.shadow = "img/ljus.png";
icon12.iconSize = new GSize(17, 17);
icon12.shadowSize = new GSize(25, 25);
icon12.iconAnchor = new GPoint(8, 8);
icon12.infoWindowAnchor = new GPoint(9, 2);
icon12.infoShadowAnchor = new GPoint(28, 25);



var iconSmall = new GIcon();
iconSmall.image="img/pin_blue.png";
iconSmall.shadow = "img/xshadow.png";
iconSmall.iconSize = new GSize(16,16);
iconSmall.shadowSize = new GSize(30, 28);
iconSmall.iconAnchor = new GPoint(8, 8);
iconSmall.infoWindowAnchor = new GPoint(9, 2);
iconSmall.infoShadowAnchor = new GPoint(22, 25);


      // create the map
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(42.380025, -93.940625), 4, G_NORMAL_MAP);
       ovcontrol = new GOverviewMapControl(new GSize(100,100));
        map.addControl(ovcontrol);
        setOverviewPos();

          function loadDetailMap(i){
          var point = points[i];
          var detailmap = new GMap2(document.getElementById("map2"));
         //  detailmap.addControl(new GSmallMapControl());
         // detailmap.addControl(new GMapTypeControl());
          detailmap.addControl(new GSmallZoomControl());
          detailmap.setCenter(point, 15);
          detailmap.setMapType(G_SATELLITE_TYPE);
          detailmap.addOverlay(new GMarker(point, iconSmall));
          }

          function loadDetailMap2(point){
          var detailmap = new GMap2(document.getElementById("map2"));
          //detailmap.addControl(new GSmallMapControl());
         // detailmap.addControl(new GMapTypeControl());
          detailmap.addControl(new GSmallZoomControl());
          detailmap.setCenter(point, 15);
          detailmap.setMapType(G_SATELLITE_TYPE);
          detailmap.addOverlay(new GMarker(point,iconSmall));
          }


     // Track the mouse and update the cordinates in a "window"
             GEvent.addListener(map, "mousemove",
                    function(point) {
                    var latLngStr6 = point.y.toFixed(6) + ', ' + point.x.toFixed(6);
                                 var intro = 'Lat / Lng : ';
                                         document.getElementById( "mymouseposition" ).innerHTML = intro+latLngStr6;
                });


      // used to display lat/lng in diag field - use for copying to locations file
        GEvent.addListener(map, "click", function(mark, point){
        //    document.getElementById("message").innerHTML = '<center><b>Longitude</b>: ' + point.x + ' | ' + ' <b>Latitude</b>: ' + point.y + '</center>';
       document.getElementById("message").innerHTML = '<center>lat="' + point.y + '" lng="' + '' + point.x + '"</center>';

        });


      // Read the data from markers.xml
     function loadMarkers() {
         map.clearOverlays();
         sidebar_html = "";
          var request = GXmlHttp.create();
      request.open("GET", "markers.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 lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GLatLng(lat,lng);
            var label = markers[i].getAttribute("name");
                        var address = markers[i].getAttribute("address");
                        var imgurl = markers[i].getAttribute("imgurl");
                        var color = markers[i].getAttribute("color");
                        var link = markers[i].getAttribute("link");
                        var plink = markers[i].getAttribute("plink");
                        var linktext = markers[i].getAttribute("linktext");

                        if (color == "kitty1")
                        var markerimg = '<img src="img/kitty1.gif">';
                        if (color == "kitty")
                        var markerimg = '<img src="img/kitty.gif">';
                        if (color == "photo")
                        var markerimg = '<img src="img/photo1.png">';
                        if (color == "note")
                        var markerimg = '<img src="img/kitty.gif">';
                        if (color == "vw")
                        var markerimg = '<img src="img/vw1.gif">';
                        if (color == "home")
                        var markerimg = '<img src="img/home1.gif">';
                        if (color == "drink")
                        var markerimg = '<img src="img/drink1.gif">';
                        if (color == "eat")
                        var markerimg = '<img src="img/eat1.gif">';
                        if (color == "sleep")
                        var markerimg = '<img src="img/sleep1.gif">';
                        if (color == "tree")
                        var markerimg = '<img src="img/tree1.gif">';
                        if (color == "see")
                        var markerimg = '<img src="img/see1.gif">';
                        if (color == "star")
                        var markerimg = '<img src="img/star1.gif">';
                        if (color == "peep")
                        var markerimg = '<img src="img/lju1.gif">';


                        var html = '<div id="winCont">' + markerimg + ' <h2> ' + label + '</h2><br><hr></hr><div class="title">' + address + '<a href="' + plink + '" target="_new"><img src="' + imgurl + '" border="0"></a><br><a href="' + link + '" target="_new"><b>' + linktext + '</b></a></div></div>';

                        // create the marker
            var marker = createMarker(point,label,imgurl,color,address,html);


                 map.addOverlay(marker);

                  }

         // put the assembled sidebar_html contents into the sidebar div
          document.getElementById("sidebar").innerHTML = '<table width="120px" cellspacing="2" cellpadding="0" class="side">' + sidebar_html + '</table>';
        }
      }
      request.send(null);
      }
        loadMarkers();

     map.addOverlay(new GPolyline( [
  new GPoint( -114.229266, 48.044285) ,                        //Lakeside, Mt
  new GPoint( -114.19464111328125, 47.942106827553026) ,
  new GPoint( -114.21661376953125, 47.918182807791965) ,
  new GPoint( -114.28253173828125, 47.84634433782511) ,
  new GPoint( -114.356689453125, 47.83159592699296) ,
  new GPoint( -114.30999755859375, 47.79839667295524) ,
  new GPoint( -114.24407958984375, 47.816843323520764) ,
  new GPoint( -114.246826171875, 47.818687628247105) ,
  new GPoint( -114.2413330078125, 47.77256035513371) ,
  new GPoint( -114.23858642578125, 47.76332998647307) ,
  new GPoint( -114.17266845703125, 47.69497434186282) ,
  new GPoint( -114.1259765625, 47.68942806015855) ,
  new GPoint( -114.09576416015625, 47.33510005753562) ,
  new GPoint( -114.17816162109375, 47.279229002570816) ,
  new GPoint( -114.0435791015625, 47.131819327544115) ,
  new GPoint( -114.136962890625, 46.95963595861955) ,
  new GPoint( -113.97216796875, 46.87145819560722) ,
  new GPoint( -113.697509765625, 46.73044845188482) ,
  new GPoint( -113.302001953125, 46.71915170604123) ,
  new GPoint( -112.7252197265625, 46.492719928122746) ,
  new GPoint( -112.8021240234375, 46.10561307998295) ,
  new GPoint( -112.48626708984375, 45.98360371953021) ,
  new GPoint( -112.4395751953125, 45.92631906688105) ,
  new GPoint( -111.95068359375, 45.882360730184025) ,
  new GPoint( -111.55792236328125, 45.91103315853962) ,
  new GPoint( -110.928955078125, 45.63900747494936) ,
  new GPoint( -110.5609130859375, 45.64668833372338) ,
  new GPoint( -109.91546630859375, 45.83454044932633) ,
  new GPoint( -109.09698486328125, 45.598665689820656) ,
  new GPoint( -108.77288818359375, 45.663966415824056) ,
  new GPoint( -108.39111328125, 45.83071305019327) ,


 new GPoint( -106.314697265625, 46.263442671779885) ,
 new GPoint( -104.754638671875, 47.11499982620772) ,
 new GPoint( -104.029541015625, 46.92025531537451) ,   //Bismarck, ND
 new GPoint( -96.822509765625, 46.89023157359399) ,    //Fargo, ND

 new GPoint( -91.2744140625, 43.94537239244209 ) ,

  new GPoint( -91.3787841796875, 43.93350594453702 ) ,
  new GPoint( -91.2908935546875, 43.87017822557581 ) ,
  new GPoint( -90.4559326171875, 43.99676629896825 ) ,
  new GPoint( -89.791259765625, 43.60028402353632 ) ,
  new GPoint( -89.505615234375, 43.504736854976954 ) ,
  new GPoint( -89.2144775390625, 43.028745251348795 ) ,
  new GPoint( -88.9947509765625, 42.54903361222514 ) ,
  new GPoint( -89.01123046875, 42.24478535602799 ) ,
  new GPoint( -87.7752685546875, 41.98807738309159 ) ,     //Chicago, IL
  new GPoint( -87.6324462890625, 41.84501267270689 ) ,
  new GPoint( -87.3797607421875, 41.59490508367679 ) ,
  new GPoint( -87.0172119140625, 41.57847058443442 ) ,
  new GPoint( -86.3525390625, 41.759019938155404 ) ,
  new GPoint( -85.001220703125, 41.759019938155404 ) ,
  new GPoint( -84.7869873046875, 41.65239288426814 ) ,
  new GPoint( -83.6224365234375, 41.59490508367679 ) ,
  new GPoint( -83.0401611328125, 41.38917324986403 ) ,
  new GPoint( -82.4139404296875, 41.347948493443546 ) ,
  new GPoint( -82.0843505859375, 41.40565583808169 ) ,
  new GPoint( -80.958251953125, 41.23651120124621 ) ,

  new GPoint( -79.8321533203125, 40.56806745430726 ) ,
  new GPoint( -79.683837890625, 40.384212768155045 ) ,


  new GPoint( -78.5247802734375, 40.04864272291728 ) ,
  new GPoint( -78.255615234375, 39.998163944585805 ) ,
  new GPoint( -78.1787109375, 39.715638134796336 ) ,
  new GPoint( -77.7227783203125, 39.63953756436671 ) ,
  new GPoint( -77.442626953125, 39.436192999314066 ) ,
  new GPoint( -77.135009765625, 39.02345139405935 ) ,

 new GPoint( -77.080078125, 38.84826438869913 ) ,     //Washington, DC


  new GPoint( -76.8548583984375, 38.95940879245423 ) ,
  new GPoint( -76.4593505859375, 39.036252959636606 ) ,
  new GPoint( -76.09130859375, 38.96795115401593 ) ,
  new GPoint( -76.0638427734375, 38.56534784488546 ) ,

  new GPoint( -75.5859375, 38.38903340675905 ) ,

  new GPoint( -75.06511688232422, 38.395491532971896 ) ,     // Ocean City, MD
  new GPoint( -75.54473876953125, 38.067554724225275 ) ,
  new GPoint( -75.56259155273438, 37.84666368454913 ) ,
  new GPoint( -76.13525390625, 36.88840804313823 ) ,
  new GPoint( -76.66259765625, 36.77409249464195 ) ,
  new GPoint( -77.54150390625, 35.94243575255426 ) ,
  new GPoint( -77.8271484375, 36.04021586880111 ) ,
  new GPoint( -78.519287109375, 35.42486791930558 ) ,
  new GPoint( -79.046630859375, 34.67839374011646 ) ,
  new GPoint( -79.87060546875, 34.21634468843465 ) ,
  new GPoint( -80.57373046875, 34.27083595165 ) ,
  new GPoint( -82.0458984375, 33.51391942394942 ) ,
  new GPoint( -84.375, 33.77914733128647 ) ,          //Atlanta, GA
  new GPoint( -86.85791015625, 33.54139466898275 ) ,    //Birmingham, AL
  new GPoint( -90.0439453125, 35.18278813800229 ) ,      //memphis, TN
  new GPoint( -92.30712890625, 34.795761534730325 ) ,   //Little Rock, AR
  new GPoint( -92.5048828125, 35.191766965947394 ) ,
  new GPoint( -94.185791015625, 35.55010533588551 ) ,
  new GPoint( -94.163818359375, 36.32397712011264 ) ,
  new GPoint( -94.449462890625, 37.08147564886052 ) ,    //Joplin, MO
 new GPoint( -94.625244140625, 39.104488809440475 ) ,  //Kansas City, MO
 new GPoint( -96.74560546875, 43.620170616189895) ,   //Sioux Falls

  new GPoint( -97.0257568359375, 43.60426186809618) ,
  new GPoint( -97.12738037109375, 43.66588482492509) ,
  new GPoint( -97.811279296875, 43.667871610117494) ,
  new GPoint( -97.8826904296875, 43.69766549666677) ,
  new GPoint( -99.261474609375, 43.75522505306928) ,
  new GPoint( -99.62127685546875, 43.87017822557581) ,
  new GPoint( -100.118408203125, 43.90185050527358) ,
  new GPoint( -100.6402587890625, 43.91372326852401) ,
  new GPoint( -100.69793701171875, 43.878097874251736) ,
  new GPoint( -101.1016845703125, 43.89591323557617) ,
  new GPoint( -101.2335205078125, 43.84641296470239) ,
  new GPoint( -101.8927001953125, 43.83452678223684) ,
  new GPoint( -102.3870849609375, 44.07377376789347) ,
  new GPoint( -102.51617431640625, 44.10533762552548) ,
  new GPoint( -103.260498046875, 44.11322595798781) ,
  new GPoint( -103.53240966796875, 44.41808794374849) ,
  new GPoint( -103.71368408203125, 44.48866833139464) ,
  new GPoint( -103.84002685546875, 44.49258696288604) ,   //Rapid City, SD
  new GPoint( -104.0350341796875, 44.545462718849755) ,
  new GPoint( -104.1998291015625, 44.53175879707938) ,
  new GPoint( -104.1998291015625, 44.53175879707938) ,
  new GPoint( -104.63653564453125, 44.29043508918884) ,
  new GPoint( -105.54840087890625, 44.29043508918884) ,
  new GPoint( -105.9136962890625, 44.180234276372886) ,
  new GPoint( -106.2652587890625, 44.19402066387343) ,
  new GPoint( -106.67724609375, 44.35920579433503) ,


































  new GPoint( -106.67724609375, 44.35920579433503 ) ,
  new GPoint( -107.0150756835937, 44.90063253713748 ) ,
  new GPoint( -107.1771240234375, 44.92591837128866 ) ,
  new GPoint( -107.303466796875, 44.999767019181284 ) ,
  new GPoint( -107.30621337890625, 45.00559312697019 ) ,
  new GPoint( -107.38037109375, 45.47554027158593 ) ,
  new GPoint( -107.57537841796875, 45.740693395533086 ) ,
  new GPoint( -108.39111328125, 45.83071305019327 ) ,
  new GPoint( -108.77288818359375, 45.663966415824056 ) ,
  new GPoint( -109.09698486328125, 45.598665689820656 ) ,
  new GPoint( -109.91546630859375, 45.83454044932633 ) ,
  new GPoint( -110.5609130859375, 45.64668833372338 ) ,
  new GPoint( -110.928955078125, 45.63900747494936 ) ,
  new GPoint( -111.55792236328125, 45.91103315853962 ) ,
  new GPoint( -111.95068359375, 45.882360730184025) ,
  new GPoint( -112.4395751953125, 45.92631906688105) ,
  new GPoint( -112.48626708984375, 45.98360371953021) ,
  new GPoint( -112.8021240234375, 46.10561307998295 ) ,
  new GPoint( -112.7252197265625, 46.492719928122746 ) ,
  new GPoint( -113.302001953125, 46.71915170604123 ) ,
  new GPoint( -113.697509765625, 46.73044845188482 ) ,
  new GPoint( -113.97216796875, 46.87145819560722 ) ,
  new GPoint( -114.136962890625, 46.95963595861955 ) ,
  new GPoint( -114.0435791015625, 47.131819327544115 ) ,
  new GPoint( -114.17816162109375, 47.279229002570816 ) ,
  new GPoint( -114.09576416015625, 47.33510005753562 ) ,
  new GPoint( -114.1259765625, 47.68942806015855 ) ,
  new GPoint( -114.17266845703125, 47.69497434186282 ) ,
  new GPoint( -114.23858642578125, 47.76332998647307 ) ,
  new GPoint( -114.2413330078125, 47.77256035513371 ) ,
  new GPoint( -114.246826171875, 47.818687628247105 ) ,
  new GPoint( -114.24407958984375, 47.816843323520764 ) ,
  new GPoint( -114.30999755859375, 47.79839667295524 ) ,
  new GPoint( -114.356689453125, 47.83159592699296 ) ,
  new GPoint( -114.28253173828125, 47.84634433782511 ) ,
  new GPoint( -114.21661376953125, 47.918182807791965 ) ,
  new GPoint( -114.19464111328125, 47.942106827553026 ) ,
  new GPoint( -114.229266, 48.044285)
   ] ,
 '#666666', 4,0.5));

        }
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }