﻿/* Used in site map table */

function stripeTable(t, headers) 
{
   var i, odd = true;
   for (i=0; i<t.rows.length; i++) 
    {
      if (headers == 'TRUE' && i==0)
        {
          t.rows[0].className += ' table_header';
        } else 
        {
         t.rows[i].className += odd ? ' odd' : ' even';
         odd = !odd;
         }
     }
 }


/*****************************************************************************
Purpose: Loads Google maps
*****************************************************************************/
 // class for holding map co-ordinates & map details
    function myMapObject(longitude,latitude, balloonText, mapId, zoom, markerLng, markerLat, markerText) 
    {
    this.longitude = longitude;
    this.latitude = latitude;
    this.balloonText = balloonText;
    this.mapId = mapId;
    this.zoom = zoom;
    this.markerLng = markerLng;
    this.markerLat = markerLat;
    this.markerText = markerText;
    }
    
    var objectArrayIndex = 0;
    var myObjectArray = new Array();
    
   //adds map values to map array for one marker on a map only
    function setMapObject(longitude,latitude, balloonText,mapId, zoom) 
    {
       myObjectArray[objectArrayIndex++] = new myMapObject(longitude,latitude, balloonText, mapId, zoom, null, null, '');
    }
 
    //used to add more than one marker to a map array
    function setMarkerObject(longitude,latitude, balloonText,mapId, zoom, markerLng, markerLat, markerText) 
    {
       myObjectArray[objectArrayIndex++] = new myMapObject(longitude,latitude, balloonText,mapId, zoom, markerLng, markerLat, markerText);
    }
    
    //calls display map function
    function load()
    {
        showObjectArray(myObjectArray,objectArrayIndex);
    }
    //loops through array using values to display Google maps
    function showObjectArray(object, length) 
    {
        for (var i=0; i<length; i++) 
        {
        displayMap(object[i].mapId, object[i].longitude, object[i].latitude, object[i].balloonText, object[i].zoom, object[i].markerLng, object[i].markerLat, object[i].markerText);
        }
    }
   
     
    // function provided by Google to display maps 
    function displayMap(sMap, iLongitude, iLatitude, sText, iZoom, iMarkerLng, iMarkerLat, sMarkerText) 
    {
      if (GBrowserIsCompatible()) 
      {
        var map = new GMap2(document.getElementById(sMap));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        
        map.setCenter(new GLatLng(iLatitude, iLongitude, false), iZoom);
        map.addOverlay(createMarker(new GLatLng(iLatitude, iLongitude, false),"<strong>" + sText + "</strong>"));
        if(iMarkerLng != null)
        {
        map.addOverlay(createMarker(new GLatLng(iMarkerLat, iMarkerLng, false), "<strong>" + sMarkerText + "</strong>"));
       }
      }
    }
    
    function createMarker(point, blurb) 
    {
          var marker = new GMarker(point);
          GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(blurb);
      });
      return marker;
}