// GoogleMap JavaScript Code
// Rapid City Rinks And Arenas
// <![CDATA[
//  Start MAP creation
    var timeoutID = 0;
    var map;
    var zoom = 12;                           // 1 WORLD - 15 STREET
    var center_lat = 44.06144;
    var center_lon = -103.207283;
    var iWidthOV = 150;                      // Changes the Width and Height of the OverView map in the LR corner,
    var iHeightOV = 120;                     // (cont'd) should be smaller and proportional
    var iRightLogo = iWidthOV + 20;          // This changes the absolute right position of the Ridgerider Logo, based on iWidth
    var iRightGSC = iRightLogo + iWidthOV;   //   " " of the ScaleControl, based on iRightLogo, and the width of the logo (150)
    var ICO                                  // Just a holder for a variable when no color is entered for a Header

    // --------------------------------------------------------------

    map = new GMap2(document.getElementById("map"));
    map.enableDoubleClickZoom();
    map.enableScrollWheelZoom();
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(center_lat, center_lon), zoom, G_HYBRID_MAP);
    map.addControl(new GOverviewMapControl(new GSize(iWidthOV,iHeightOV)));
    map.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(iRightGSC, 20)));

    ICOred  =  new GIcon();
    ICOred.image  =  "http://labs.google.com/ridefinder/images/mm_20_red.png";
    ICOred.shadow  =  "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    ICOred.iconSize  =  new GSize(12, 20);
    ICOred.shadowSize  =  new GSize(22, 20);
    ICOred.iconAnchor  =  new GPoint(6, 20);
    ICOred.infoWindowAnchor  =  new GPoint(5, 1);

//Start of Marker Delimination

// this variable will collect the html which will eventually be placed in the side_bar
    var vzMapList = "";
// arrays to hold copies of the markers and html used by the side_bar
// because the function closure trick doesnt work there
    var gzMarkers = [];
    var i = 0;
// A function to create the marker and set up the event window
    function createMarker(szPtTitle, iType, bTab, sgLat, sgLong, szPtOL, szPtInfoHTML, szColor, szIcon) {
        var gzMarker = new GMarker(new GLatLng(sgLat, sgLong), szIcon);
        GEvent.addListener(gzMarker, "click", function() {
// If no image is available, then create balloon without TAB structure
    if (bTab)
        {gzMarker.openInfoWindowTabsHtml(szPtInfoHTML);}
    else
        {gzMarker.openInfoWindowHtml(szPtInfoHTML);}
    });
// save the info we need to use later for the side_bar
    gzMarkers[i] = gzMarker;
//  0: nothing, 1: header, 2: link, 3: ICO
    if (iType == 1)             // 1: a Header for RideList
    {
        vzMapList += '<p class="rl_hdr">&nbsp;' + szPtTitle + '</p>';
        i++;
    }
    else if (iType == 2)        // 2: an actual list item
    {
        var szMouseOver = "onMouseOver=\"return overlib('" + szPtOL + "');\" onMouseOut=\"return nd();\" "
        vzMapList += "<a class='rl' href='javascript:fxMyClick(" + i + ");' " + szMouseOver + "/>&nbsp;&nbsp;&nbsp;&nbsp;&bull;&nbsp;&nbsp;" + szPtTitle + "</a>";
        i++;
    }
    else if (iType == 3)        //  Create the Legend Info
    {
        var szMouseOver = "onMouseOver=\"return overlib('" + szPtOL + "');\" onMouseOut=\"return nd();\" "
        var szImg = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://labs.google.com/ridefinder/images/mm_20_' + szColor + '.png"' + szMouseOver + 'border="0">&nbsp;&ndash;&nbsp;'
        szImg = '<a class="rl" href="javascript:fxMyClick(' + i + ')"' + szMouseOver + '>' + szImg + szPtTitle + '</a>'
        vzMapList += szImg
        i++;
    }
    else                        // else 0
    {
// do nothing
    }
    return gzMarker;
    }
// This function picks up the click and opens the corresponding info window
    function fxMyClick(i) {
        GEvent.trigger(gzMarkers[i], "click");
    }
//  ---------------------- Add Locations ---------------------- //

    // ------------------------------  Marker Number 1:    Rinks and Arenas ------------------------------  //
    var gzMarker = createMarker('Rinks and Arenas', 1, '', '', '', '', '', '', '');
    map.addOverlay(gzMarker);

    // ------------------------------  Marker Number 2:    ThunderDome ------------------------------  //
    var szMarkerTitle = "ThunderDome";
    var szMarkerInfo = "Home to the Rushmore Thunder";
    var szMarkerHTML = "<p class='gm_hdr'>Home to the Rushmore Thunder</p><br /><div><span class='addHdr'>Address:</span><span class='addInfo'>Old Folsom Road</span></div><br /><div><span class='addHdr'>Directions:</span><span class='addInfo'>South of town on Hwy 79</span></div><br /><div><p class='gm_txt_just'>South of town off Hwy 79.  Turn left 1 mile past Catron Blvd./Elk Vale Rd. onto Old Folsom Road.  One mile, large building on right.</p></div><p class=\"gm_txt_just\">&nbsp;<br /><a class=\"gm\" href=\"/schedules/sched_rha.html\" target=\"_self\">Home Schedule</a><br />&nbsp;<br /><a class=\"gm\" href=\"http://www.rushmorehockey.com\" target=\"_blank\">RHA Website</a></p>";
    var vzTextTab = new GInfoWindowTab(szMarkerTitle,szMarkerHTML);
    var szImageInfo = '<p class="gm_hdr">Home to the Rushmore Thunder</p><img src="/images/thunderdome.jpg" alt="Home to the Rushmore Thunder"></a>';
    var vzImgTab = new GInfoWindowTab("Photo", szImageInfo);
    var vzTabInfo = [vzTextTab,vzImgTab];
    var gzMarker = createMarker(szMarkerTitle, 2, true, 44.02824779, -103.17707062, 'Home to the Rushmore Thunder', vzTabInfo, 'red', ICOred);
    map.addOverlay(gzMarker);

    // ------------------------------  Marker Number 3:    Roosevelt ------------------------------  //
    var szMarkerTitle = "Roosevelt";
    var szMarkerInfo = "General Purpose City Ice Arena";
    var szMarkerHTML = "<p class='gm_hdr'>General Purpose City Ice Arena</p><p class='gm_txt'><div><span class='addHdr'>Phone:</span><span class='addInfo'>605.394.6161</span></div><br /><div><span class='addHdr'>Address:</span><span class='addInfo'>235 Waterloo Street</span></div><br /><div><span class='addHdr'>Directions:</span><span class='addInfo'>East of Downtown</span></div><br /><div><p class='gm_txt_just'>Take Omaha east from downtown to Waterloo. Left one block, Swim Center and Arena Stand side by side.</p></div>";
    var vzTextTab = new GInfoWindowTab(szMarkerTitle,szMarkerHTML);
    var szImageInfo = '';
    var vzImgTab = new GInfoWindowTab("Photo", szImageInfo);
    var vzTabInfo = "<p class='gm_hdr'>General Purpose City Ice Arena</p><p class='gm_txt'><div><span class='addHdr'>Phone:</span><span class='addInfo'>605.394.6161</span></div><br /><div><span class='addHdr'>Address:</span><span class='addInfo'>235 Waterloo Street</span></div><br /><div><span class='addHdr'>Directions:</span><span class='addInfo'>East of Downtown</span></div><br /><div><p class='gm_txt_just'>Take Omaha east from downtown to Waterloo. Left one block, Swim Center and Arena Stand side by side.</p></div><p class=\"gm_txt_just\">&nbsp;<br /><a class=\"gm\" href=\"http://www.rcgov.org/parks_recreation/recreation/ice_arena/ice_arena_home.htm\" target=\"_blank\">Website</a></p>";
    var gzMarker = createMarker(szMarkerTitle, 2, false, 44.08428665, -103.20706844, 'General Purpose City Ice Arena', vzTabInfo, 'red', ICOred);
    map.addOverlay(gzMarker);

    // ------------------------------  Marker Number 4:    Civic Arena ------------------------------  //
    var szMarkerTitle = "Civic Arena";
    var szMarkerInfo = "Home to Rapid City RUSH";
    var szMarkerHTML = "<p class='gm_hdr'>Home to Rapid City RUSH</p><p class='gm_txt'><div><span class='addHdr'>Phone:</span><span class='addInfo'>605.716.PUCK</span></div><br /><div><span class='addHdr'>Address:</span><span class='addInfo'>444 Mt. Rushmore Road</span></div><br /><div><span class='addHdr'>Directions:</span><span class='addInfo'>Near Downtown</span></div><br /><div><p class='gm_txt_just'>At the end of Mt. Rushmore Road, downtown.</p></div><p class=\"gm_txt_just\">&nbsp;<br /><a class=\"gm\" href=\"http://rapidcityrush.com\" target=\"_blank\">Website</a></p>";
    var vzTextTab = new GInfoWindowTab(szMarkerTitle,szMarkerHTML);
    var szImageInfo = '<p class="gm_hdr">Home to Rapid City RUSH</p><a href="http://rapidcityrush.com" target="_blank"><img src="/images/rcc.jpg" alt="Home to Rapid City RUSH - Website"></a>';
    var vzImgTab = new GInfoWindowTab("Photo", szImageInfo);
    var vzTabInfo = [vzTextTab,vzImgTab];
    var gzMarker = createMarker(szMarkerTitle, 2, true, 44.08699935, -103.2251358, 'Home to Rapid City RUSH', vzTabInfo, 'red', ICOred);
    map.addOverlay(gzMarker);


//  --------------------- Add points to vzMapList ---------------------- //
// put the assembled List contents into the side_bar div
    document.getElementById("MapList").innerHTML = vzMapList;
// Add Logo To The Map
function ctrlLogo() {}
    ctrlLogo.prototype = new GControl();
    ctrlLogo.prototype.initialize = function() {
    var contents = document.createElement("div");
    contents.style.width="125px";         // Fixed Width of the Logo, do not change
    contents.style.height="100px";         // Fixed Height of the Logo, do not change
    contents.innerHTML="<a href='/' target='_self'><img src='/images/map_logo.png' alt='MooseCup!! Hockey' title='MooseCup!! Hockey' border='0'></a>";
    document.getElementById('map').appendChild(contents);
    return contents;
      }
    ctrlLogo.prototype.printable=function(){return true};
    ctrlLogo.prototype.selectable=function(){return true};
    ctrlLogo.prototype.getDefaultPosition=function(){
    return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(iRightLogo,18))
      }
  map.addControl(new ctrlLogo());
   //]]>
