    var map = "";
    var mgr = "";
    var tack = "";
    var markers = [];
    var markers1=new Array();
    var markers2=new Array();


    //the main setup arrays
    var mainURL="http://googlemaps.sagient.com/boyne/"
    var IMAGES = [ "bohi", "bomo", "baha", "baha", "baha" ];
    var TITLES = [ "Boyne Highlands", "Boyne Mountain", "Bay Harbor", "Bay Harbor Golf Club", "Crooked Tree Golf Club" ];
    var LINKS = [ "/BoyneHighlands", "/BoyneMountain", "/BayHarbor", "/", "/" ];
    var boyneLat = [ "45.464701", "45.166892", "45.368058", "45.363365", "45.358121"];
    var boyneLng = [ "-84.926291","-84.929856","-85.014716","-85.056643","-85.021893" ];
    var ICONS = [];
    var ADDRESS = ["600 Highlands Drive", "Harbor Springs, MI 49740",
        "1 Boyne Mountain Rd", "Boyne Falls, MI 49713",
        "3600 Village Harbor Drive", "Petoskey, MI 49770",
        "5800 Coastal Drive", "Petoskey, MI 49770",
        "600 Crooked Tree Dr", "Petoskey, MI 49770"];
    var PHONES = ["(231) 526-3000",
        "(231) 549-6000",
        "(231) 439-4000",
        "(231) 439-4085",
        "(231) 439-4030"];

    // arrays to hold variants of the info window html with get direction forms open

    var htmls = [];
    var to_htmls = [];
    var from_htmls = [];
    // functions that open the directions forms
    function tohere1(i) {
      markers1[i].openInfoWindowHtml(to_htmls[i]);
    }
    function fromhere1(i) {
      markers1[i].openInfoWindowHtml(from_htmls[i]);
    }

    function tohere2(i) {
      markers2[(i-3)].openInfoWindowHtml(to_htmls[i]);
    }
    function fromhere2(i) {
      markers2[(i-3)].openInfoWindowHtml(from_htmls[i]);
    }

    function getQueryVariable(variable) {
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
          return pair[1];
        }
      }
    }
    function getTack (qvariable) {
      var openTack = getQueryVariable(qvariable);
      if (openTack != undefined) {
        outerClick(openTack);
      }
    }

    function getIcon(i) {
      if (!ICONS[i]) {
        var icon = new GIcon();
        icon.image = mainURL+"/icons/"+IMAGES[i]+".png";
        icon.iconAnchor = new GPoint(10, 34);
        icon.infoWindowAnchor = new GPoint(10, 0);
        icon.iconSize = new GSize(20, 34);
        icon.shadow = mainURL+"/icons/marker_shadow.png";
        icon.shadowSize = new GSize(30, 30);
      }
      return ICONS[i] = icon;
    }

    function createMarker(i,x,loopstart) {
	var marker="";
        var lat = boyneLat[i];
        var lng = boyneLng[i];
        marker = new GMarker(new GLatLng(lat,lng), { icon: getIcon(i) });
        //The Info Window Builder
	var html = '<div class="infoWindow '+IMAGES[i]+'"><a href="'+LINKS[i]+'">'+TITLES[i]+'</a><br/>'+ADDRESS[i*2]+', '+ADDRESS[(i*2)+1]+'<br/>'+PHONES[i]+'<br>'
        // The info window version with the "to here" form open (The Directions Form part.)
        to_htmls[i] = html + '<div class="toFrom">Directions: <b>To here</b> - <a href="javascript:fromhere'+x+'(' + i + ')">From here</a>' +
           '<br />Start address:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" style="width:288px;" maxlength="40" name="saddr" id="saddr" value="" />' +
           '<input value="Get Directions" type="submit" />' +
           '<input type="hidden" name="daddr" value="' + ADDRESS[i*2]+', '+ADDRESS[(i*2)+1]+'" /></form></div></div>';
        // The info window version with the "to here" form open
        from_htmls[i] = html + '<div class="toFrom">Directions: <a href="javascript:tohere'+x+'(' + 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" style="width:288px;" maxlength="40" name="daddr" id="daddr" value="" />' +
           '<input value="Get Directions" type="submit">' +
           '<input type="hidden" name="saddr" value="' + ADDRESS[i*2]+', '+ADDRESS[(i*2)+1]+'" /></form></div></div>';
        // The inactive version of the direction info

        html = html + '<div class="toFrom">Directions: <a href="javascript:tohere'+x+'('+i+')">To here</a> - <a href="javascript:fromhere'+x+'('+i+')">From here</a></div></div>';
        htmls[i] = html;

        GEvent.addListener(marker, "click", function() {
           map.setZoom(12); 
           marker.openInfoWindowHtml(html);
        //   map.setCenter(new GLatLng(lat, lng), 12);
        });
        return marker;
    }

    function getMarkers1(n,loopstart) {
      for (var i = loopstart; i < n; i++) {
	var marker = createMarker(i,1,loopstart);
	markers1.push(marker);
      }
      return (markers1);
    }

    function getMarkers2(n,loopstart) {
      for (var i = loopstart; i < n; i++) {
	var marker = createMarker(i,2,loopstart);
	markers2.push(marker);
      }
      return (markers2);
    }
    function outerClick(i) {
      map.setCenter(markers1[i].getPoint(),12);
	  markers1[i].initialize(map);
	  GEvent.trigger(markers1[i],"click");
    }

    function setupMap() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(45.373000, -84.886000), 9);
        map.addControl(new GLargeMapControl());
        map.enableDoubleClickZoom();
        setupMarkers();
        getTack("tack");
      }
    }

    function setupMarkers() {
      mgr = new GMarkerManager(map);
      mgr2 = new GMarkerManager(map);
      mgr.addMarkers(getMarkers1(3,0),0,17);
      mgr2.addMarkers(getMarkers2(5,3),11,17);
      mgr.refresh();
      mgr2.refresh();
    }


