//window.onerror = new Function("return true;");
//
// Bookmark page
//

function bookmark() 
{                                   
    var title = "Ptarmigan Mountaineering Club";
    var url = 'http://www.ptarmiganmc.org.uk/index.htm';
    if (window.sidebar) 
    { 
         window.sidebar.addPanel(title, url, ""); 
    } 
    else if( document.all ) 
    {
        window.external.AddFavorite(url,title);
    } 
    else if( window.opera && window.print ) 
    {
        var mbm = document.createElement('a');
        mbm.setAttribute('rel', 'sidebar');
        mbm.setAttribute('href', url);
        mbm.setAttribute("title", title);
        mbm.click();                
    }
}


function ObscureMail(url1)
{
    var url2="ptarmiganmc.org.uk";
    document.location.href="mailto:"+url1+"@"+url2+"";
}

//
// Change test size       
//
function fontChanger(sz,lh,tp) {
    //All the text in the page is in entry type divs:
    var currElement = document.getElementById("entry");
    if (currElement != null)
    {
        currElement.style.fontSize=sz.toString() + tp;
        currElement.style.lineHeight=lh.toString() + tp;
    }
    var currElementGallery = document.getElementById("entrygallery");
    if (currElementGallery != null)
    {
        currElementGallery.style.fontSize=sz.toString() + tp;
        currElementGallery.style.lineHeight=lh.toString() + tp;
    }
    var currElement = document.getElementById("footer");
    if (currElement != null)
    {
        currElement.style.fontSize=sz.toString() + tp;
        currElement.style.lineHeight=lh.toString() + tp;
    }
}

function chageFontSize(theValue) {
    var valueArray = theValue.split(",");
    fontChanger(valueArray[0],valueArray[1],valueArray[2]);
}

//// Sunrise & Sunset
//// Based on http://www.geocities.com/g.foltz5/almanac.xml
      function InfoDates(latitude, longitude, date, toCity)
      {
        
         official = 90.8333333;
         civil = 96.0;

         var sunrise = calcSunriseSunset(latitude, longitude, date, official, true);
         var civilrise = calcSunriseSunset(latitude, longitude, date, civil, true);
         var sunset = calcSunriseSunset(latitude, longitude, date, official, false);
         var civilset = calcSunriseSunset(latitude, longitude, date, civil, false);

         var secondsSun = (sunset - sunrise) / 1000;
         var secondsLight = (civilset - civilrise) / 1000;
         
         var almanacElement = document.getElementById('almanac');
         if (almanacElement == null) { return; }
         
         var strAlmanac = "";         
         strAlmanac += "<p id='city' class='city'>" + toCity + "&nbsp;&nbsp;&nbsp;" + formatDate(date, "E NNN d, yyyy") + "</p>";         
         strAlmanac += "<div id='almanacinfo'>";
         
         strAlmanac += "<ul>";  
         strAlmanac += "<li class='title' ></li>";                
         strAlmanac += "<li class='headercolumn' >Sunrise</li>";
         strAlmanac += "<li class='headercolumn' >Sunset</li>";
         strAlmanac += "</ul>";
         
         strAlmanac += "<ul>";
         strAlmanac += "<li class='title'>Official Time</li>";
         strAlmanac += "<li class='column' id='offRise'>" + formatDate(sunrise, "hh:mm a") + "</li>";
         strAlmanac += "<li class='column' id='offSet'>" + formatDate(sunset, "hh:mm a") + "</li>";
         strAlmanac += "</ul>";                 
         
         strAlmanac += "<ul>";
         strAlmanac += "<li  class='title'>Civil Twilight</li>";
         strAlmanac += "<li class='column' id='civRise'>" + formatDate(civilrise, "hh:mm a") + "</li>";
         strAlmanac += "<li class='column' id='civSet'>" + formatDate(civilset, "hh:mm a") + "</li>";
         strAlmanac += "</ul>";
         
         strAlmanac += "<div style='padding-left:120px; width:145px'><hr></div>";
         
         strAlmanac += "<ul>";
         strAlmanac += "<li  class='titlelong'>Amount of sunlight</li>";
         strAlmanac += "<li class='colspan2' id='dayLength'>" + formatTimeSpan(secondsLight)  + "</li>";         
         strAlmanac += "</ul>";
         
         strAlmanac += "<ul>";
         strAlmanac += "<li  class='titlelong'>Amount of daylight</li>";
         strAlmanac += "<li class='colspan2' id='sunLength'>" + formatTimeSpan(secondsSun)  + "</li>";         
         strAlmanac += "</ul>";
         
         strAlmanac += "<ul>";
         strAlmanac += "<li  class='titlelong'>Moon Phase</li>";
         strAlmanac += "<li class='colspan2' id='phase'>" + formatTimeSpan(secondsSun)  + "</li>";                  
         strAlmanac += "</ul>";       
         
         strAlmanac += "</div>";
         
         almanacElement.innerHTML = strAlmanac;         
         
         moonPhase = calcMoonPhase(date); 
         var phase; 
         var phaseimg = "";
         var phasetooltip = ""
         if(moonPhase < 0.05 || moonPhase > 0.95)
         {
		      // New moon
		      phase = "New Moon";
		      phaseimg = "images/almanac/newmoon.jpg";
		      phasetooltip = Math.floor(moonPhase*100) + "%";
         }
         else if (moonPhase < 0.24)
         {
		      // Waxing crescent
		      phase = "Waxing crescent";		      
		      phaseimg = "images/almanac/waxingcrescent.jpg";
		      phasetooltip = Math.floor(moonPhase*100) + "%";

         }
         else if (moonPhase < 0.26)
         {
		      // First quarter
		      phase = "First quarter";
		      phaseimg = "images/almanac/firstquarter.jpg";		      
		      phasetooltip = Math.floor(moonPhase*100) + "%";
         }
         else if (moonPhase < 0.48)
         {
		      // Waxing gibbous
		      phase = "Waxing gibbous";
		      phaseimg = "images/almanac/waxinggibbous.jpg";		      
		      phasetooltip = Math.floor(moonPhase*100) + "%";
         }
         else if (moonPhase < 0.52)
         {
		      // Full moon
		      phase = "Full moon";
		      phaseimg = "images/almanac/fullmoon.jpg";
		      phasetooltip = Math.floor(moonPhase*100) + "%";
         }
         else if (moonPhase < 0.73)
         {
		      // Waning gibbous
		      phase = "Waning gibbous";
		      phaseimg = "images/almanac/waninggibbous.jpg";	
		      phasetooltip = Math.floor(moonPhase*100) + "%";	      
         }
         else if (moonPhase < 0.77)
         {
		      // Third quarter
		      phase = "Third quarter";
		      phaseimg = "images/almanac/thirdquarter.jpg";		      
		      phasetooltip  = Math.floor(moonPhase*100) + "%";
         }
         else
         {
		      // Waning crescent
		      phase = "Waning crescent";
		      phaseimg = "images/almanac/waningcrescent.jpg";		      
		      phasetooltip = Math.floor(moonPhase*100) + "%";
         }
         document.getElementById('phase').innerHTML = phase.toString();                  
         $('almanac').setStyle('background-image','url("' + phaseimg + '")');                          
      }

      //
      // Calculates the sunrise or sunset for the given date/location/zenith
      //
      // Source: http://williams.best.vwh.net/sunrise_sunset_example.htm
      //         (Almanac for Computers, 1990)
      function calcSunriseSunset(latitude, longitude, date, zenith, calculateRisingTime)
      {
         month = date.getMonth()+1;
         day = date.getDate();
         year = date.getYear();

         //1. Calculate day of year   
         N1 = Math.floor(275 * month / 9);
         N2 = Math.floor((month + 9) /12);
         N3 = (1 + Math.floor((year - 4 * Math.floor(year / 4) + 2) / 3));
         N = dayOfYear = N1 - (N2 * N3) + day - 30;
         
         //2. Convert longitude to hour and approximate time
         lngHour = longitude / 15;
         if (calculateRisingTime)
         {
             t = N + ((6 - lngHour) / 24);
         }
         else
         {
             t = N + ((18 - lngHour) / 24);
         }

         
         //3. Calculate Mean Anomaly
         M = (0.9856 * t) - 3.289;

         
         //4. Calculate sun's true longitude
         L = M + (1.916 * sin(M)) + (0.020 * sin(2 * M)) + 282.634;
         if (L < 0) L = L + 360;
         else if (L > 359) L = L - 360;
         

         
         // 5a. Calculate	the Sun's right ascension
         RA = atan(0.91764 * tan(L));
         
         // 5b. RA Value needs to be in the same quadrant as L
         Lquadrant  = (Math.floor( L/90)) * 90;
         RAquadrant = (Math.floor(RA/90)) * 90;
         RA = RA + (Lquadrant - RAquadrant);
         
         // 5c. Convert RA to hours
         RA = RA / 15;
         
         // 6. Calculate Sun's Declination
         sinDec = 0.39782 * sin(L);
         cosDec = cos(asin(sinDec));

         // 7a. Calculate sun's local hour angle
         cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec * cos(latitude));
         if (cosH > 1)
         { 
	       // the sun never rises on this location (on the specified date)
         }
         else if (cosH < -1)
         {
	      //  the sun never sets on this location (on the specified date)
         }
         
         // 7b. Finish calculating H and convert into hours
         if (calculateRisingTime)
         {
	        H = 360 - acos(cosH);
         }
         else
         {
	        H = acos(cosH);
         }
         
         H = H / 15;
         
         // 8. Calculate local mean time of rising / setting
         T = H + RA - (0.06571 * t) - 6.622;

         //9. Adjust back to UTC
         UT = T - lngHour;
         if (UT < 0) UT += 24;
         else if (UT > 23) UT -= 24;   
         localT = T;

         if (localT < 0) localT += 24;
         else if (localT > 23) localT -= 24;

         eventTime = new Date(date);
         // Check if summer time (apox dates: "Sunday, March 30"	"Sunday, October 26")
         if (month > 3 && month < 11)
         {
            localT = localT + 1;
         }
         eventTime.setHours(Math.floor(localT));
         eventTime.setMinutes(Math.floor((localT - Math.floor(localT)) * 60));
         eventTime.setSeconds(0);
         return eventTime;
      }	

      function sin(x)
      {
	      return Math.sin(toRadians(x));
      }

      function asin(x)
      {
          return toDegrees(Math.asin(x));
      }
      function cos(x)
      {
          return Math.cos(toRadians(x));
      }
      function acos(x)
      {
          return toDegrees(Math.acos(x));
      }
      function atan(x)
      {
	      return toDegrees(Math.atan(x));
      }

      function tan(x)
      {
	      return Math.tan(toRadians(x));
      }

      function toRadians(x)
      {
         return (2 * x * Math.PI) / 360;
      }

      function toDegrees(x)
      {
	      return (360 * x)/(2 * Math.PI)
      }

      function LZ(x) 
      {
              return(x<0||x>9?"":"0")+x;
      } 

      //based on a BASIC program MOON EFFECTS by Bradley E. Schaefer
      //   This program helps anyone who needs to know the Moon's 
      //   phase (age) on
      //   any date within several thousand years in the past or future.
      //   To illustrate its application, Bradley Schaefer applied it 
      //   to a number of famous events influenced by the Moon in 
      //   World War II.  His article appeared in Sky & Telescope for
      //   April 1994, page 86.
      //
      //   Returns the phase as a real value between 0 and 1
      //   0 and 1 are new moons
      //   0.5 is full moon

      function calcMoonPhase(date)
      {
	      var Y= date.getFullYear();
	      var M = date.getMonth() + 1;
	      var D = date.getDate();
	      var YY,MM,K1,K2,K3,J,V,IP,AG;

	      YY=Y- Math.floor((12-M)/10);
	      MM=M+9;
	      if (MM>=12) {MM=MM-12};
	      K1=Math.floor(365.25*(YY+4712));
	      K2=Math.floor(30.6*MM+.5);
	      K3=Math.floor(Math.floor((YY/100)+49)*.75)-38;
	      J=K1+K2+D+59;  // JD for dates in Julian calendar
	      if (J>2299160) {J=J-K3};  // For Gregorian calendar

	      //  J is the Julian date at 12h UT on day in question
      	
	      //  Calculate illumination (synodic) phase
	      V=(J-2451550.1)/29.530588853;
      	
	      //  Normalize values to range 0 to 1
	      V=V-Math.floor(V);
	      if (V<0) {V=V+1};
      	
	      return V;
      }
       function formatTimeSpan(seconds)
      {
         var hours = Math.floor(seconds / 3600);
         var minutes = Math.floor((seconds % 3600)/60);
         return hours + "h " + minutes + "m";
      }

      // ------------------------------------------------------------------
      // formatDate (date_object, format)
      // Returns a date in the output format specified.
      // The format string uses the same abbreviations as in getDateFromFormat()
      // SOURCE: http://www.mattkruse.com/javascript/date/source.html
      // ------------------------------------------------------------------
      function formatDate(date,format) 
      {
        var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
        var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
	      format=format+"";
	      var result="";
	      var i_format=0;
	      var c="";
	      var token="";
	      var y=date.getYear()+"";
	      var M=date.getMonth()+1;
	      var d=date.getDate();
	      var E=date.getDay();
	      var H=date.getHours();
	      var m=date.getMinutes();
	      var s=date.getSeconds();
	      var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	      // Convert real date parts into formatted versions
	      var value=new Object();
	      if (y.length < 4) {y=""+(y-0+1900);}
	      value["y"]=""+y;
	      value["yyyy"]=y;
	      value["yy"]=y.substring(2,4);
	      value["M"]=M;
	      value["MM"]=LZ(M);
	      value["MMM"]=MONTH_NAMES[M-1];
	      value["NNN"]=MONTH_NAMES[M+11];
	      value["d"]=d;
	      value["dd"]=LZ(d);
	      value["E"]=DAY_NAMES[E+7];
	      value["EE"]=DAY_NAMES[E];
	      value["H"]=H;
	      value["HH"]=LZ(H);
	      if (H==0){value["h"]=12;}
	      else if (H>12){value["h"]=H-12;}
	      else {value["h"]=H;}
	      value["hh"]=LZ(value["h"]);
	      if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	      value["k"]=H+1;
	      value["KK"]=LZ(value["K"]);
	      value["kk"]=LZ(value["k"]);
	      if (H > 11) { value["a"]="PM"; }
	      else { value["a"]="AM"; }
	      value["m"]=m;
	      value["mm"]=LZ(m);
	      value["s"]=s;
	      value["ss"]=LZ(s);
	      while (i_format < format.length) {
		      c=format.charAt(i_format);
		      token="";
		      while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			      token += format.charAt(i_format++);
			      }
		      if (value[token] != null) { result=result + value[token]; }
		      else { result=result + token; }
		      }
	      return result;
	      }




//////////////////////////
//
// Google maps
//
//////////////////////////

var map = null;
var gdir = null;
var munros = null;
var markerstart = null;
var markermid = null;
var markerend = null;
var loaded = 0;
this.cEvent = null;
var latlong = null;

/*
 * Set the map centered in Scotland with zoom 6
 */
function initialize() {
    if (GBrowserIsCompatible()) 
    {      
        map = new GMap2(document.getElementById("map_canvas"));
        gdir = new GDirections(map);
        GEvent.addListener(gdir, "error", handleErrors);  
	    map.setCenter(new GLatLng(0,0),0);	//Inital setCenter() added as a  life insurance.
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(56.80087831233043, -4.207763671875), 6);
        //map.enableScrollWheelZoom();
    }
}

/*
 * Load directions from fromAddress to toAddress via midAddress and include date of the meet and destiny city
 * (not neccessarily toAddress)
 */
function setDirections(fromAddress, midAddress, toAddress, toCity) 
{    
    if (this.cEvent != null) {   
        GEvent.removeListener(this.cEvent);
    }
    
    gdir.loadFromWaypoints([fromAddress,midAddress,toAddress],{getPolyline:true,getSteps:true});            
    setTimeout(markMunros,0);       
    this.cEvent = GEvent.addListener(gdir, "load", function() 
        { 
            document.getElementById("estimate").innerHTML=gdir.getSummaryHtml();
            latlong = gdir.getRoute(0).getEndLatLng();
            replaceMarkers(fromAddress, toCity);
        });           
}


function setInfoDates(fromAddress, midAddress, toAddress, date, toCity) 
{    
    var dateArray = date.split("-"); 
    if (latlong == null)
    {
        gdir = new GDirections();        
        if (this.cEvent != null) {   
            GEvent.removeListener(this.cEvent);
        }
    
        gdir.loadFromWaypoints([fromAddress,midAddress,toAddress]);            
          
        this.cEvent = GEvent.addListener(gdir, "load", function() 
            {                 
                latlong = gdir.getRoute(0).getEndLatLng();              
                    InfoDates(latlong.lat(), latlong.lng(), new Date(dateArray[2], dateArray[0]-1, dateArray[1]), toCity);                
            });                 
    }        
    else {
        InfoDates(latlong.lat(), latlong.lng(), new Date(dateArray[2], dateArray[0]-1, dateArray[1]), toCity);                
    }
}


/*
 * Replace starting and end markers and remove mid marker
 */
function replaceMarkers(fromAddress, toCity)
{
   // Send the icons in the center to the North Pole...
   var latlngstart = gdir.getMarker(0).getLatLng();
   var latlngmid = gdir.getMarker(1).getLatLng();
   var latlngend = gdir.getMarker(2).getLatLng();
   gdir.getMarker(0).setLatLng( new GLatLng(90, 0));
   gdir.getMarker(1).setLatLng( new GLatLng(90, 0));
   gdir.getMarker(2).setLatLng( new GLatLng(90, 0));
   if (markerstart != null)
   {
       markerstart.remove();
       markerend.remove();
   }
   var icon = new GIcon();
   icon.image = "images/bus.png";
   icon.shadow = "images/shadow-bus.png";
   icon.iconSize = new GSize(32.0, 32.0);
   icon.shadowSize = new GSize(48.0, 32.0);
   icon.iconAnchor = new GPoint(16.0, 16.0);
   icon.infoWindowAnchor = new GPoint(16.0, 16.0);
    
   /*icon.image = "images/bus.png";
   icon.iconSize = new GSize(24, 24);
   icon.iconAnchor = new GPoint(12,24);
   icon.infoWindowAnchor = new GPoint(12,12);*/
   
   markerstart = new GMarker(latlngstart, icon);
   GEvent.addListener(markerstart, "click", function() {
    //markerstart.openInfoWindowHtml("<div style='white-space:nowrap;background: url(images/logo_black.gif);background-repeat:no-repeat;background-position:right bottom;'><br/><br/><b>Starting point: " + fromAddress + "</b>");   
    markerstart.openInfoWindowHtml("<div style='font-weight:normal; text-align:left; font-size:12px; line-height:16px; margin:2px 15px 2px 12px; padding-right:5px; height:80px; width:95%'><div style='white-space:nowrap;background: url(images/logo_black.gif);background-repeat:no-repeat;background-position:right bottom;'><br/><br/><b>Starting point: </b><br/>" + fromAddress + "</div>");   
   });
   map.addOverlay(markerstart);
   markerend = new GMarker(latlngend, icon);
   GEvent.addListener(markerend, "click", function() {
    //markerend.openInfoWindowHtml("<div style='white-space:nowrap;background: url(images/logo_black.gif);background-repeat:no-repeat;background-position:right bottom;'><br/><br/><b>End point: " + toCity + "</b>");   
    
    markerend.openInfoWindowHtml("<div style='font-weight:normal; text-align:left; font-size:12px; line-height:16px; margin:2px 15px 2px 12px; padding-right:5px; height:80px; width:95%'><div style='white-space:nowrap;background: url(images/logo_black.gif);background-repeat:no-repeat;background-position:right bottom;'><br/><br/><b>End Point: </b><br/>" + toCity + "</div>");   
   });
   map.addOverlay(markerend);
}

/*
 * Handle Errors whilst looking for directions.
 */
function handleErrors()
{
    if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
        alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
    else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
        alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
    else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
        alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
    //   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
    //   alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
     else if (gdir.getStatus().code == G_GEO_BAD_KEY)
        alert("A geocoding or directions request could not be successfully processed. \n Error code: " + gdir.getStatus().code);
    else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
        alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
    else if (gdir.getStatus().code == G_GEO_UNKNOWN_DIRECTIONS)
        alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
    else alert("An unknown error occurred." + gdir.getStatus().code);           
	   
}

/*
 * Set the markers in the munros.
 */
function markMunros()
{
    if (loaded == 0) {        
        munros = getMarkers();                            
    }
    for (var i = 0; i < munros.length; ++i) {
        map.addOverlay(munros[i]);
    }
    loaded =1;
}

/*
 * Create a marker for a munro.
 */
function createMarker(icon, rank, point, name, height, mHeight, osMap, weather)
{
    var marker = new GMarker(point,icon);    
    var weatherLink = "http://www.mwis.org.uk/";
    if (weather != "H")
    {
        weatherLink = weatherLink + "mountain/" + weather+ ".PDF";
    }    
    else
    {
        weatherLink = weatherLink + "areas.php";
    }
    
    GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml("<div style='font-weight:normal; text-align:left; font-size:12px; line-height:16px; margin:2px 15px 2px 12px; padding-right:5px; height:80px; width:95%'><div style='white-space:nowrap;background: url(images/logo_black.gif);background-repeat:no-repeat;background-position:right bottom;'>Name: <b>" + name + "</b><br>Altitude: " + height + " (" + mHeight+ ")<br>Rank: " + rank + "<br>OS map: " + osMap + "</div>Weather: <a href='" + weatherLink +"' target='_blank'>Forecasts by MWIS</a></div>");   
    marker.visited = true;
  });
  GEvent.addListener(marker,'mouseover',function(){
            marker.setImage("images/mountain3.gif");
  });
    GEvent.addListener(marker,'mouseout',function(){
            if(marker.visited)
            {
                marker.setImage("images/mountain4.gif");
            } 
            else 
            {
                marker.setImage("images/mountain2.gif");
            }
    });

  return marker;
}

/*
 * Get the markers of the munros.
 * WGS 84 data obtained from http://www.peakbagging.com/waypoint/Munrowgs.txt.
 */
function getMarkers()
{
    /* WEATHER LINKS
    The Northwest Highlands of Scotland = "NH"
    The West Highlands of Scotland = "WH"
    Cairngorms National Park and Monadhliath = "EH"
    The Southeastern Highlands of Scotland = "SH" */
    
    
    /*var iconmunro = new GIcon();
    iconmunro.image = "images/mountain.gif";
    iconmunro.shadow = "images/shadow.png";
    iconmunro.iconSize = new GSize(34, 21);
    iconmunro.shadowSize = new GSize(54, 21);
    iconmunro.iconAnchor = new GPoint(17,21);
    iconmunro.infoWindowAnchor = new GPoint(21,21);*/
    var iconmunro = new GIcon();
    iconmunro.image = "images/mountain2.gif";
    iconmunro.shadow = "images/shadow-mountain2.png";
    iconmunro.iconSize = new GSize(24.0, 13.0);
    iconmunro.shadowSize = new GSize(31.0, 13.0);
    iconmunro.iconAnchor = new GPoint(12.0, 6.0);
    iconmunro.infoWindowAnchor = new GPoint(12.0, 6.0);
    
    var batch = [];
    batch.push(createMarker(iconmunro,1, new GLatLng(56.79676,-5.00328),"Ben Nevis","4409ft","1344m","41","H"));
    batch.push(createMarker(iconmunro,2, new GLatLng(57.07036,-3.66907),"Ben MacDui","4294ft","1309m","36 + 43","H"));
    batch.push(createMarker(iconmunro,3, new GLatLng(57.07836,-3.72816),"Braeriach","4251ft","1296m","36 + 43","H"));
    batch.push(createMarker(iconmunro,4, new GLatLng(57.05417,-3.71055),"Cairn Toul","4235ft","1291m","36 + 43","H"));
    batch.push(createMarker(iconmunro,5, new GLatLng(57.05827,-3.72558),"Sgor an Lochain Uaine","4127ft","1258m","33","H"));
    batch.push(createMarker(iconmunro,6, new GLatLng(57.11678,-3.64374),"Cairn Gorm","4081ft","1244m","36","H"));
    batch.push(createMarker(iconmunro,7, new GLatLng(56.79998,-4.95488),"Aonach Beag [Nevis region]","4048ft","1234m","41","H"));
    batch.push(createMarker(iconmunro,8, new GLatLng(56.81295,-4.96164),"Aonach Mor","4005ft","1221m","41","H"));
    batch.push(createMarker(iconmunro,9, new GLatLng(56.80525,-4.98659),"Carn Mor Dearg","4002ft","1220m","41","H"));
    batch.push(createMarker(iconmunro,10, new GLatLng(56.5449,-4.22089),"Ben Lawers","3982ft","1214m","51","H"));
    batch.push(createMarker(iconmunro,11, new GLatLng(57.08733,-3.49887),"Beinn a' Bhuird","3927ft","1197m","36 + 43","H"));
    batch.push(createMarker(iconmunro,12, new GLatLng(57.28767,-5.11506),"Carn Eighe","3881ft","1183m","25","H"));
    batch.push(createMarker(iconmunro,13, new GLatLng(57.09591,-3.61116),"Beinn Mheadhoin","3877ft","1182m","36","H"));
    batch.push(createMarker(iconmunro,14, new GLatLng(57.27963,-5.12019),"Mam Sodhail","3874ft","1181m","25","H"));
    batch.push(createMarker(iconmunro,15, new GLatLng(56.82374,-4.84938),"Stob Choire Claurigh","3861ft","1177m","41","H"));
    batch.push(createMarker(iconmunro,16, new GLatLng(56.38626,-4.54036),"Ben More [Crianlarich]","3851ft","1174m","51","H"));
    batch.push(createMarker(iconmunro,17, new GLatLng(57.09923,-3.43464),"Leabaidh an Daimh Bhuide (Ben Avon)","3841ft","1171m","36","H"));
    batch.push(createMarker(iconmunro,18, new GLatLng(56.37117,-4.53579),"Stob Binnein","3822ft","1165m","51","H"));
    batch.push(createMarker(iconmunro,19, new GLatLng(57.00987,-3.72383),"Beinn Bhrotain","3795ft","1157m","43","H"));
    batch.push(createMarker(iconmunro,20, new GLatLng(57.06289,-3.62222),"Derry Cairngorm","3789ft","1155m","36 + 43","H"));
    batch.push(createMarker(iconmunro,21, new GLatLng(56.96011,-3.24526),"Cac Carn Beag (Lochnagar)","3789ft","1155m","44","H"));
    batch.push(createMarker(iconmunro,22, new GLatLng(57.25493,-5.22275),"Sgurr nan Ceathreamhnan","3776ft","1151m","25 + 33","H"));
    batch.push(createMarker(iconmunro,23, new GLatLng(56.64279,-5.02887),"Bidean nam Bian","3772ft","1150m","41","H"));
    batch.push(createMarker(iconmunro,24, new GLatLng(57.36919,-5.06009),"Sgurr na Lapaich","3772ft","1150m","25","H"));
    batch.push(createMarker(iconmunro,25, new GLatLng(56.81369,-4.46485),"Ben Alder","3766ft","1148m","42","H"));
    batch.push(createMarker(iconmunro,26, new GLatLng(56.83788,-4.50924),"Geal-Charn [Alder region]","3713ft","1132m","42","H"));
    batch.push(createMarker(iconmunro,27, new GLatLng(56.75429,-4.92576),"Binnein Mor","3707ft","1130m","41","H"));
    batch.push(createMarker(iconmunro,28, new GLatLng(56.39688,-4.81075),"Ben Lui","3707ft","1130m","50","H"));
    batch.push(createMarker(iconmunro,29, new GLatLng(57.36253,-5.10461),"An Riabhachan","3704ft","1129m","25","H"));
    batch.push(createMarker(iconmunro,30, new GLatLng(56.95192,-4.6016),"Creag Meagaidh","3700ft","1128m","34 + 42","H"));
    batch.push(createMarker(iconmunro,31, new GLatLng(56.42684,-5.13187),"Ben Cruachan","3694ft","1126m","50","H"));
    batch.push(createMarker(iconmunro,32, new GLatLng(56.83973,-3.68813),"Carn nan Gabhar (Beinn a' Ghlo)","3677ft","1121m","43","H"));
    batch.push(createMarker(iconmunro,33, new GLatLng(57.18437,-5.15535),"A' Chralaig","3674ft","1120m","33 + 34","H"));
    batch.push(createMarker(iconmunro,34, new GLatLng(56.56045,-4.21611),"An Stuc","3667ft","1118m","41","H"));
    batch.push(createMarker(iconmunro,35, new GLatLng(56.56517,-4.20841),"Meall Garbh [Lawers region]","3667ft","1118m","51","H"));
    batch.push(createMarker(iconmunro,36, new GLatLng(57.06838,-3.81132),"Sgor Gaoith","3667ft","1118m","36 + 43","H"));
    batch.push(createMarker(iconmunro,37, new GLatLng(56.83344,-4.52878),"Aonach Beag [Alder region]","3661ft","1116m","41 + 42","H"));
    batch.push(createMarker(iconmunro,38, new GLatLng(56.81088,-4.88478),"Stob Coire an Laoigh","3661ft","1116m","41","H"));
    batch.push(createMarker(iconmunro,39, new GLatLng(56.81799,-4.77339),"Stob Coire Easain","3658ft","1115m","41","H"));
    batch.push(createMarker(iconmunro,40, new GLatLng(57.02675,-3.75015),"Monadh Mor","3651ft","1113m","43","H"));
    batch.push(createMarker(iconmunro,41, new GLatLng(57.29935,-5.04914),"Tom a' Choinich","3648ft","1112m","25","H"));
    batch.push(createMarker(iconmunro,42, new GLatLng(56.94582,-3.27257),"Carn a' Choire Bhoideach","3641ft","1110m","44","H"));
    batch.push(createMarker(iconmunro,43, new GLatLng(57.70009,-5.01662),"Sgurr Mor [Loch Fannaich]","3641ft","1110m","20","H"));
    batch.push(createMarker(iconmunro,44, new GLatLng(57.17751,-5.09519),"Sgurr nan Conbhairean","3638ft","1109m","34","H"));
    batch.push(createMarker(iconmunro,45, new GLatLng(56.61228,-4.85217),"Meall a' Bhuiridh","3635ft","1108m","41","H"));
    batch.push(createMarker(iconmunro,46, new GLatLng(56.8235,-4.76003),"Stob a' Choire Mheadhion","3625ft","1105m","41","H"));
    batch.push(createMarker(iconmunro,47, new GLatLng(56.53608,-4.2368),"Beinn Ghlas","3618ft","1103m","51","H"));
    batch.push(createMarker(iconmunro,48, new GLatLng(56.8262,-4.54451),"Beinn Eibhinn","3615ft","1102m","41 + 42","H"));
    batch.push(createMarker(iconmunro,49, new GLatLng(57.20568,-5.15535),"Mullach Fraoch-choire","3615ft","1102m","33 + 34","H"));
    batch.push(createMarker(iconmunro,50, new GLatLng(56.61433,-4.87221),"Creise","3608ft","1100m","41","H"));
    batch.push(createMarker(iconmunro,51, new GLatLng(56.75595,-5.00345),"Sgurr a' Mhaim","3605ft","1099m","41","H"));
    batch.push(createMarker(iconmunro,52, new GLatLng(56.80046,-4.90413),"Sgurr Choinnich Mor","3589ft","1094m","41","H"));
    batch.push(createMarker(iconmunro,53, new GLatLng(57.69629,-5.04786),"Sgurr nan Clach Geala","3585ft","1093m","20","H"));
    batch.push(createMarker(iconmunro,54, new GLatLng(57.13776,-3.58501),"Bynack More","3576ft","1090m","36","H"));
    batch.push(createMarker(iconmunro,55, new GLatLng(56.56808,-4.88222),"Stob Ghabhar","3576ft","1090m","50","H"));
    batch.push(createMarker(iconmunro,56, new GLatLng(56.8696,-4.50939),"Beinn a' Chlachair","3566ft","1087m","42","H"));
    batch.push(createMarker(iconmunro,57, new GLatLng(57.78644,-4.92943),"Beinn Dearg [Ullapool]","3556ft","1084m","20","H"));
    batch.push(createMarker(iconmunro,58, new GLatLng(57.0932,-3.57733),"Beinn a' Chaorainn [Glen Derry]","3553ft","1083m","36","H"));
    batch.push(createMarker(iconmunro,59, new GLatLng(56.66724,-4.10014),"Schiehallion","3553ft","1083m","51","H"));
    batch.push(createMarker(iconmunro,60, new GLatLng(57.44392,-4.90297),"Sgurr a' Choire Ghlais","3553ft","1083m","25","H"));
    batch.push(createMarker(iconmunro,61, new GLatLng(56.56009,-4.64755),"Beinn a' Chreachain","3546ft","1081m","50","H"));
    batch.push(createMarker(iconmunro,62, new GLatLng(56.51021,-4.57937),"Beinn Heasgarnich","3536ft","1078m","51","H"));
    batch.push(createMarker(iconmunro,63, new GLatLng(56.53891,-5.04985),"Ben Starav","3536ft","1078m","50","H"));
    batch.push(createMarker(iconmunro,64, new GLatLng(56.50294,-4.72189),"Beinn Dorain","3530ft","1076m","50","H"));
    batch.push(createMarker(iconmunro,65, new GLatLng(56.63812,-5.01022),"Stob Coire Sgreamhach","3517ft","1072m","41","H"));
    batch.push(createMarker(iconmunro,66, new GLatLng(56.83117,-3.72954),"Braigh Coire Chruinn-Bhalgain (Beinn a' Ghlo)","3510ft","1070m","43","H"));
    batch.push(createMarker(iconmunro,67, new GLatLng(57.35013,-5.1586),"An Socach [Loch Mullardoch]","3507ft","1069m","25","H"));
    batch.push(createMarker(iconmunro,68, new GLatLng(56.54097,-4.25362),"Meall Corranaich","3507ft","1069m","51","H"));
    batch.push(createMarker(iconmunro,69, new GLatLng(56.87303,-3.36821),"Glas Maol","3503ft","1068m","43","H"));
    batch.push(createMarker(iconmunro,70, new GLatLng(57.19629,-5.34763),"Sgurr Fhuaran","3500ft","1067m","33","H"));
    batch.push(createMarker(iconmunro,71, new GLatLng(56.89419,-3.33861),"Cairn of Claise","3490ft","1064m","43","H"));
    batch.push(createMarker(iconmunro,72, new GLatLng(57.80707,-5.25169),"Bidean a' Ghlas Thuill (An Teallach)","3484ft","1062m","19","H"));
    batch.push(createMarker(iconmunro,73, new GLatLng(57.80067,-5.25936),"Sgurr Fiona (An Teallach)","3477ft","1060m","19","H"));
    batch.push(createMarker(iconmunro,74, new GLatLng(56.74362,-4.93982),"Na Gruagaichean","3464ft","1056m","41","H"));
    batch.push(createMarker(iconmunro,75, new GLatLng(57.56424,-5.46333),"Spidean a' Choire Leith (Liathach)","3461ft","1055m","25","H"));
    batch.push(createMarker(iconmunro,76, new GLatLng(56.96412,-4.58501),"Stob Poite Coire Ardair","3458ft","1054m","34","H"));
    batch.push(createMarker(iconmunro,77, new GLatLng(57.30927,-4.9993),"Toll Creagach","3458ft","1054m","25","H"));
    batch.push(createMarker(iconmunro,78, new GLatLng(57.45237,-5.1891),"Sgurr a' Chaorachain [Monar]","3454ft","1053m","25","H"));
    batch.push(createMarker(iconmunro,79, new GLatLng(56.86568,-3.55823),"Glas Tulaichean","3448ft","1051m","43","H"));
    batch.push(createMarker(iconmunro,80, new GLatLng(56.92881,-4.65357),"Beinn a' Chaorainn [Loch Laggan]","3441ft","1049m","34 + 41","H"));
    batch.push(createMarker(iconmunro,81, new GLatLng(56.89769,-4.45692),"Geal Charn [Loch Laggan]","3441ft","1049m","42","H"));
    batch.push(createMarker(iconmunro,82, new GLatLng(57.44967,-4.94194),"Sgurr Fuar-Thuill","3441ft","1049m","25","H"));
    batch.push(createMarker(iconmunro,83, new GLatLng(56.94291,-3.30271),"Carn an t-Sagairt Mor","3435ft","1047m","44","H"));
    batch.push(createMarker(iconmunro,84, new GLatLng(56.48934,-4.61451),"Creag Mhor [Loch Lochay]","3435ft","1047m","50","H"));
    batch.push(createMarker(iconmunro,85, new GLatLng(57.67886,-4.57901),"Glas Leathad Mor (Ben Wyvis)","3431ft","1046m","20","H"));
    batch.push(createMarker(iconmunro,86, new GLatLng(56.82979,-4.66099),"Chno Dearg","3431ft","1046m","41","H"));
    batch.push(createMarker(iconmunro,87, new GLatLng(56.35658,-4.57627),"Cruach Ardrain","3431ft","1046m","50 + 51 +56","H"));
    batch.push(createMarker(iconmunro,88, new GLatLng(56.89484,-3.56831),"Beinn Iutharn Mhor","3428ft","1045m","43","H"));
    batch.push(createMarker(iconmunro,89, new GLatLng(56.52187,-4.30149),"Meall nan Tarmachan","3425ft","1044m","51","H"));
    batch.push(createMarker(iconmunro,90, new GLatLng(56.55463,-4.98015),"Stob Coir' an Albannaich","3425ft","1044m","50","H"));
    batch.push(createMarker(iconmunro,91, new GLatLng(56.63456,-4.14593),"Carn Mairg","3415ft","1041m","51","H"));
    batch.push(createMarker(iconmunro,92, new GLatLng(57.01354,-5.45658),"Sgurr na Ciche","3412ft","1040m","33 + 40","H"));
    batch.push(createMarker(iconmunro,93, new GLatLng(56.52579,-4.41668),"Meall Ghaordaidh","3408ft","1039m","51","H"));
    batch.push(createMarker(iconmunro,94, new GLatLng(56.55153,-4.69479),"Beinn Achaladair","3405ft","1038m","50","H"));
    batch.push(createMarker(iconmunro,95, new GLatLng(57.03672,-3.65849),"Carn a' Mhaim","3402ft","1037m","36 + 43","H"));
    batch.push(createMarker(iconmunro,96, new GLatLng(57.17767,-5.25243),"Sgurr a' Bhealaich Dheirg","3398ft","1036m","33","H"));
    batch.push(createMarker(iconmunro,97, new GLatLng(57.09723,-5.23827),"Gleouraich","3395ft","1035m","33","H"));
    batch.push(createMarker(iconmunro,98, new GLatLng(56.85514,-4.45462),"Carn Dearg [Alder region]","3392ft","1034m","42","H"));
    batch.push(createMarker(iconmunro,99, new GLatLng(56.74169,-4.98318),"Am Bodach","3385ft","1032m","41","H"));
    batch.push(createMarker(iconmunro,100, new GLatLng(57.22109,-5.28343),"Beinn Fhada","3385ft","1032m","33","H"));
    batch.push(createMarker(iconmunro,101, new GLatLng(56.38941,-4.7752),"Ben Oss","3375ft","1029m","50","H"));
    batch.push(createMarker(iconmunro,102, new GLatLng(56.87644,-3.59543),"Carn an Righ","3375ft","1029m","43","H"));
    batch.push(createMarker(iconmunro,103, new GLatLng(56.62307,-4.22695),"Carn Gorm","3375ft","1029m","51","H"));
    batch.push(createMarker(iconmunro,104, new GLatLng(57.10586,-5.33071),"Sgurr A' Mhaoraich","3369ft","1027m","33","H"));
    batch.push(createMarker(iconmunro,105, new GLatLng(57.18101,-5.33731),"Sgurr na Ciste Duibhe","3369ft","1027m","33","H"));
    batch.push(createMarker(iconmunro,106, new GLatLng(56.45417,-4.61988),"Ben Challum","3362ft","1025m","50","H"));
    batch.push(createMarker(iconmunro,107, new GLatLng(56.6538,-5.1714),"Sgorr Dhearg (Beinn a' Bheithir)","3359ft","1024m","41","H"));
    batch.push(createMarker(iconmunro,108, new GLatLng(57.56083,-5.49228),"Mullach an Rathain (Liathach)","3356ft","1023m","25","H"));
    batch.push(createMarker(iconmunro,109, new GLatLng(57.12454,-5.22132),"Aonach Air Chrith","3349ft","1021m","33","H"));
    batch.push(createMarker(iconmunro,110, new GLatLng(56.64604,-4.90024),"Stob Dearg (Buachaille Etive Mor)","3349ft","1021m","41","H"));
    batch.push(createMarker(iconmunro,111, new GLatLng(57.07519,-5.5914),"Ladhar Bheinn","3346ft","1020m","33","H"));
    batch.push(createMarker(iconmunro,112, new GLatLng(56.8131,-4.4309),"Beinn Bheoil","3343ft","1019m","42","H"));
    batch.push(createMarker(iconmunro,113, new GLatLng(56.90809,-3.3575),"Carn an Tuirc","3343ft","1019m","43","H"));
    batch.push(createMarker(iconmunro,114, new GLatLng(57.01171,-3.84085),"Mullach Clach a' Bhlair","3343ft","1019m","19","H"));
    batch.push(createMarker(iconmunro,115, new GLatLng(57.70887,-5.27108),"Mullach Coire Mhic Fhearchair","3339ft","1018m","35 + 43","H"));
    batch.push(createMarker(iconmunro,116, new GLatLng(57.00867,-5.44393),"Garbh Choich Mhor","3323ft","1013m","33 + 40","H"));
    batch.push(createMarker(iconmunro,117, new GLatLng(56.92761,-3.27852),"Cairn Bannoch","3320ft","1012m","44","H"));
    batch.push(createMarker(iconmunro,118, new GLatLng(56.23656,-4.81706),"Beinn Ime","3316ft","1011m","56","H"));
    batch.push(createMarker(iconmunro,119, new GLatLng(56.83534,-4.32971),"Beinn Udlamain","3316ft","1011m","42","H"));
    batch.push(createMarker(iconmunro,120, new GLatLng(57.59375,-5.42947),"Ruadh-stac Mor (Beinn Eighe)","3313ft","1010m","19","H"));
    batch.push(createMarker(iconmunro,121, new GLatLng(57.1618,-5.41664),"The Saddle","3313ft","1010m","33","H"));
    batch.push(createMarker(iconmunro,122, new GLatLng(57.13691,-5.28159),"Sgurr an Doire Leathain","3313ft","1010m","33","H"));
    batch.push(createMarker(iconmunro,123, new GLatLng(56.75005,-4.89549),"Sgurr Eilde Mor","3313ft","1010m","41","H"));
    batch.push(createMarker(iconmunro,124, new GLatLng(56.87719,-3.88379),"Beinn Dearg [Blair Atholl]","3307ft","1008m","43","H"));
    batch.push(createMarker(iconmunro,125, new GLatLng(57.46449,-5.11076),"Maoile Lunndaidh","3303ft","1007m","25","H"));
    batch.push(createMarker(iconmunro,126, new GLatLng(56.93191,-3.75425),"An Sgarsoch","3300ft","1006m","43","H"));
    batch.push(createMarker(iconmunro,127, new GLatLng(56.97902,-4.51544),"Carn Liath [Loch Laggan]","3300ft","1006m","34","H"));
    batch.push(createMarker(iconmunro,128, new GLatLng(57.306,-5.1299),"Beinn Fhionnlaidh [Glen Affric]","3297ft","1005m","25","H"));
    batch.push(createMarker(iconmunro,129, new GLatLng(56.5299,-4.71391),"Beinn an Dothaidh","3293ft","1004m","50","H"));
    batch.push(createMarker(iconmunro,130, new GLatLng(57.03568,-3.68877),"The Devils Point","3293ft","1004m","36 + 43","H"));
    batch.push(createMarker(iconmunro,131, new GLatLng(57.14135,-5.29752),"Sgurr an Lochain","3293ft","1004m","33","H"));
    batch.push(createMarker(iconmunro,132, new GLatLng(57.02855,-5.35428),"Sgurr Mor [Glen Kingie]","3290ft","1003m","33 + 40","H"));
    batch.push(createMarker(iconmunro,133, new GLatLng(57.19173,-5.09108),"Sail Chaorainn","3287ft","1002m","34","H"));
    batch.push(createMarker(iconmunro,134, new GLatLng(57.18897,-5.34912),"Sgurr na Carnach","3287ft","1002m","33","H"));
    batch.push(createMarker(iconmunro,135, new GLatLng(57.17316,-5.22887),"Aonach Meadhoin","3284ft","1001m","33","H"));
    batch.push(createMarker(iconmunro,136, new GLatLng(56.56755,-4.15955),"Meall Greigh","3284ft","1001m","51","H"));
    batch.push(createMarker(iconmunro,137, new GLatLng(56.6506,-5.19822),"Sgorr Dhonuill (Beinn a' Bheithir)","3284ft","1001m","41","H"));
    batch.push(createMarker(iconmunro,138, new GLatLng(57.692,-5.09148),"Sgurr Breac","3277ft","999m","20","H"));
    batch.push(createMarker(iconmunro,139, new GLatLng(57.45081,-5.20797),"Sgurr Choinnich","3277ft","999m","25","H"));
    batch.push(createMarker(iconmunro,140, new GLatLng(56.74361,-5.03027),"Stob Ban [Mamores]","3277ft","999m","41","H"));
    batch.push(createMarker(iconmunro,141, new GLatLng(58.13828,-4.85837),"Ben More Assynt","3274ft","998m","15","H"));
    batch.push(createMarker(iconmunro,142, new GLatLng(56.91911,-3.24915),"Broad Cairn","3274ft","998m","44","H"));
    batch.push(createMarker(iconmunro,143, new GLatLng(56.43127,-5.09151),"Stob Diamh (Ben Cruachan)","3274ft","998m","50","H"));
    batch.push(createMarker(iconmunro,144, new GLatLng(57.69377,-5.12906),"A' Chailleach [Fannaich region]","3270ft","997m","19","H"));
    batch.push(createMarker(iconmunro,145, new GLatLng(56.54206,-5.00536),"Glas Bheinn Mhor","3270ft","997m","50","H"));
    batch.push(createMarker(iconmunro,146, new GLatLng(57.08884,-5.19379),"Spidean Mialach","3267ft","996m","33","H"));
    batch.push(createMarker(iconmunro,147, new GLatLng(56.33849,-4.62472),"An Caisteal","3264ft","995m","50 + 56","H"));
    batch.push(createMarker(iconmunro,148, new GLatLng(56.93599,-3.80178),"Carn an Fhidhleir","3261ft","994m","43","H"));
    batch.push(createMarker(iconmunro,149, new GLatLng(56.61988,-5.08002),"Sgor na h-Ulaidh","3261ft","994m","41","H"));
    batch.push(createMarker(iconmunro,150, new GLatLng(57.58074,-5.40516),"Spidean Coire nan Clach (Beinn Eighe)","3257ft","993m","19","H"));
    batch.push(createMarker(iconmunro,151, new GLatLng(57.44148,-4.85244),"Sgurr na Ruaidhe","3257ft","993m","25","H"));
    batch.push(createMarker(iconmunro,152, new GLatLng(57.3635,-5.02435),"Carn nan Gobhar [Loch Mullardoch]","3254ft","992m","25","H"));
    batch.push(createMarker(iconmunro,153, new GLatLng(57.45209,-4.87961),"Carn nan Gobhar [Glen Strathfarrar]","3254ft","992m","25","H"));
    batch.push(createMarker(iconmunro,154, new GLatLng(57.20678,-6.2242),"Sgurr Alasdair","3254ft","992m","32","H"));
    batch.push(createMarker(iconmunro,155, new GLatLng(56.82847,-4.29765),"Sgairneach Mhor","3251ft","991m","42","H"));
    batch.push(createMarker(iconmunro,156, new GLatLng(56.45004,-5.02665),"Beinn Eunaich","3244ft","989m","50","H"));
    batch.push(createMarker(iconmunro,157, new GLatLng(57.71853,-5.26591),"Sgurr Ban","3244ft","989m","19","H"));
    batch.push(createMarker(iconmunro,158, new GLatLng(58.13564,-4.88365),"Conival","3238ft","987m","15","H"));
    batch.push(createMarker(iconmunro,159, new GLatLng(56.85457,-3.38787),"Creag Leacach","3238ft","987m","43","H"));
    batch.push(createMarker(iconmunro,160, new GLatLng(57.12695,-5.18319),"Druim Shionnach","3238ft","987m","33","H"));
    batch.push(createMarker(iconmunro,161, new GLatLng(56.9362,-5.28431),"Gulvain or Gaor Bheinn","3238ft","987m","40 + 41","H"));
    batch.push(createMarker(iconmunro,162, new GLatLng(57.59068,-5.57265),"Sgurr Mhor (Beinn Alligin)","3234ft","986m","19 + 24","H"));
    batch.push(createMarker(iconmunro,163, new GLatLng(57.41328,-5.22384),"Lurg Mhor","3234ft","986m","25","H"));
    batch.push(createMarker(iconmunro,164, new GLatLng(57.21352,-6.23508),"Sgurr Dearg (inaccessible pinnacle)","3234ft","986m","32","H"));
    batch.push(createMarker(iconmunro,165, new GLatLng(56.34273,-4.21948),"Ben Vorlich [Loch Earn]","3231ft","985m","51 + 57","H"));
    batch.push(createMarker(iconmunro,166, new GLatLng(56.75909,-4.96623),"An Gearanach","3221ft","982m","41","H"));
    batch.push(createMarker(iconmunro,167, new GLatLng(57.28365,-5.18576),"Mullach na Dheiragain","3221ft","982m","25 + 33","H"));
    batch.push(createMarker(iconmunro,168, new GLatLng(57.12769,-5.25234),"Maol Chinn-dearg","3218ft","981m","33","H"));
    batch.push(createMarker(iconmunro,169, new GLatLng(56.62074,-4.12885),"Meall nan Aighean","3218ft","981m","51","H"));
    batch.push(createMarker(iconmunro,170, new GLatLng(57.66537,-5.3465),"Slioch","3218ft","981m","19","H"));
    batch.push(createMarker(iconmunro,171, new GLatLng(56.75075,-4.96901),"Stob Coire a' Chairn","3218ft","981m","41","H"));
    batch.push(createMarker(iconmunro,172, new GLatLng(56.44982,-5.06851),"Beinn a' Chochuill","3215ft","980m","50","H"));
    batch.push(createMarker(iconmunro,173, new GLatLng(57.19954,-5.20964),"Ciste Dhubh","3211ft","979m","33","H"));
    batch.push(createMarker(iconmunro,174, new GLatLng(56.83149,-4.69488),"Stob Coire Sgriodain","3211ft","979m","41","H"));
    batch.push(createMarker(iconmunro,175, new GLatLng(56.39112,-4.74291),"Beinn Dubhchraig","3208ft","978m","50","H"));
    batch.push(createMarker(iconmunro,176, new GLatLng(57.79126,-4.9039),"Cona' Mheall","3208ft","978m","20","H"));
    batch.push(createMarker(iconmunro,177, new GLatLng(57.79874,-4.93396),"Meall nan Ceapraichean","3205ft","977m","20","H"));
    batch.push(createMarker(iconmunro,178, new GLatLng(56.81064,-4.84069),"Stob Ban [Grey Corries]","3205ft","977m","41","H"));
    batch.push(createMarker(iconmunro,179, new GLatLng(56.857,-4.29054),"A' Mharconaich","3198ft","975m","42","H"));
    batch.push(createMarker(iconmunro,180, new GLatLng(56.87299,-3.46632),"Carn a' Gheoidh","3198ft","975m","43","H"));
    batch.push(createMarker(iconmunro,181, new GLatLng(56.80814,-3.74404),"Carn Liath (Beinn a' Ghlo)","3198ft","975m","43","H"));
    batch.push(createMarker(iconmunro,182, new GLatLng(56.32928,-4.23763),"Stuc a' Chroin","3198ft","975m","51 + 57","H"));
    batch.push(createMarker(iconmunro,183, new GLatLng(57.15366,-5.57949),"Beinn Sgritheall","3195ft","974m","33","H"));
    batch.push(createMarker(iconmunro,184, new GLatLng(56.1901,-4.63312),"Ben Lomond","3195ft","974m","56","H"));
    batch.push(createMarker(iconmunro,185, new GLatLng(57.22846,-6.23464),"Sgurr a' Ghreadaidh","3192ft","973m","32","H"));
    batch.push(createMarker(iconmunro,186, new GLatLng(56.63734,-4.2079),"Meall Garbh [Glen Lyon]","3175ft","968m","51","H"));
    batch.push(createMarker(iconmunro,187, new GLatLng(57.71948,-5.34663),"A' Maighdean","3172ft","967m","19","H"));
    batch.push(createMarker(iconmunro,188, new GLatLng(56.67936,-5.03687),"Sgorr nam Fiannaidh","3172ft","967m","41","H"));
    batch.push(createMarker(iconmunro,189, new GLatLng(56.4244,-6.01489),"Ben More [Isle of Mull]","3169ft","966m","47 + 48","H"));
    batch.push(createMarker(iconmunro,190, new GLatLng(57.22103,-6.24158),"Sgurr na Banachdich","3166ft","965m","32","H"));
    batch.push(createMarker(iconmunro,191, new GLatLng(57.24838,-6.19313),"Sgurr nan Gillean","3162ft","964m","32","H"));
    batch.push(createMarker(iconmunro,192, new GLatLng(56.86101,-3.77963),"Carn a' Chlamain","3159ft","963m","43","H"));
    batch.push(createMarker(iconmunro,193, new GLatLng(56.93691,-5.38896),"Sgurr Thuilm","3159ft","963m","40","H"));
    batch.push(createMarker(iconmunro,194, new GLatLng(58.23504,-4.4111),"Meall nan Con (Ben Klibreck)","3156ft","962m","16","H"));
    batch.push(createMarker(iconmunro,195, new GLatLng(57.49844,-5.40716),"Sgorr Ruadh","3156ft","962m","25","H"));
    batch.push(createMarker(iconmunro,196, new GLatLng(56.51989,-5.01173),"Beinn nan Aighenan","3149ft","960m","50","H"));
    batch.push(createMarker(iconmunro,197, new GLatLng(56.57101,-4.47101),"Stuchd an Lochain","3149ft","960m","50","H"));
    batch.push(createMarker(iconmunro,198, new GLatLng(56.60101,-5.10488),"Beinn Fhionnlaidh [Glen Etive]","3146ft","959m","41 + 50","H"));
    batch.push(createMarker(iconmunro,199, new GLatLng(56.45596,-4.54729),"Meall Glas","3146ft","959m","51","H"));
    batch.push(createMarker(iconmunro,200, new GLatLng(57.24689,-6.21071),"Bruach na Frithe","3143ft","958m","32","H"));
    batch.push(createMarker(iconmunro,201, new GLatLng(56.63808,-4.97074),"Stob Dubh (Buachaille Etive Beag)","3143ft","958m","41","H"));
    batch.push(createMarker(iconmunro,202, new GLatLng(56.90513,-3.29795),"Tolmount","3143ft","958m","44","H"));
    batch.push(createMarker(iconmunro,203, new GLatLng(57.16578,-5.0679),"Carn Ghluasaid","3139ft","957m","34","H"));
    batch.push(createMarker(iconmunro,204, new GLatLng(56.8936,-3.29197),"Tom Buidhe","3139ft","957m","44","H"));
    batch.push(createMarker(iconmunro,205, new GLatLng(57.18115,-5.28121),"Saileag","3136ft","956m","33","H"));
    batch.push(createMarker(iconmunro,206, new GLatLng(56.93582,-5.44856),"Sgurr nan Coireachan [Glen Finnan]","3136ft","956m","40","H"));
    batch.push(createMarker(iconmunro,207, new GLatLng(56.62974,-4.95117),"Stob na Broige (Buachaille Etive Mor)","3136ft","956m","41","H"));
    batch.push(createMarker(iconmunro,208, new GLatLng(56.77233,-4.54627),"Sgor Gaibhre","3133ft","955m","41 + 42","H"));
    batch.push(createMarker(iconmunro,209, new GLatLng(57.70604,-4.98941),"Beinn Liath Mhor Fannaich","3129ft","954m","20","H"));
    batch.push(createMarker(iconmunro,210, new GLatLng(57.7719,-4.85391),"Am Faochagach","3126ft","953m","20","H"));
    batch.push(createMarker(iconmunro,211, new GLatLng(56.53415,-4.64622),"Beinn Mhanach","3126ft","953m","50","H"));
    batch.push(createMarker(iconmunro,212, new GLatLng(56.68063,-5.00316),"Meall Dearg","3126ft","953m","41","H"));
    batch.push(createMarker(iconmunro,213, new GLatLng(57.00738,-5.40575),"Sgurr nan Coireachan [Glen Dessary]","3126ft","953m","33 + 40","H"));
    batch.push(createMarker(iconmunro,214, new GLatLng(56.96401,-4.11254),"Meall Chuaich","3120ft","951m","42","H"));
    batch.push(createMarker(iconmunro,215, new GLatLng(57.681,-4.98433),"Meall Gorm","3113ft","949m","20","H"));
    batch.push(createMarker(iconmunro,216, new GLatLng(56.32662,-4.90685),"Beinn Bhuidhe [Glen Fyne]","3110ft","948m","50","H"));
    batch.push(createMarker(iconmunro,217, new GLatLng(57.20913,-6.2238),"Sgurr Mhic Choinnich","3110ft","948m","32","H"));
    batch.push(createMarker(iconmunro,218, new GLatLng(57.12107,-5.16004),"Creag a' Mhaim","3106ft","947m","33","H"));
    batch.push(createMarker(iconmunro,219, new GLatLng(56.84793,-3.19628),"Driesh","3106ft","947m","44","H"));
    batch.push(createMarker(iconmunro,220, new GLatLng(56.34221,-4.56284),"Beinn Tulaichean","3103ft","946m","51 + 56 + 57","H"));
    batch.push(createMarker(iconmunro,221, new GLatLng(56.93034,-3.56092),"Carn Bhac","3103ft","946m","43","H"));
    batch.push(createMarker(iconmunro,222, new GLatLng(57.03152,-5.54629),"Meall Buidhe [Knoydart]","3103ft","946m","33 + 40","H"));
    batch.push(createMarker(iconmunro,223, new GLatLng(57.14713,-5.39726),"Sgurr na Sgine","3103ft","946m","33","H"));
    batch.push(createMarker(iconmunro,224, new GLatLng(57.4198,-5.25023),"Bidein a' Choire Sheasgaich","3100ft","945m","25","H"));
    batch.push(createMarker(iconmunro,225, new GLatLng(57.09221,-4.25353),"Carn Dearg [Monadhliath]","3100ft","945m","35","H"));
    batch.push(createMarker(iconmunro,226, new GLatLng(56.57376,-4.83868),"Stob a' Choire Odhair","3100ft","945m","50","H"));
    batch.push(createMarker(iconmunro,227, new GLatLng(56.902,-3.51229),"An Socach [Glen Ey]","3097ft","944m","43","H"));
    batch.push(createMarker(iconmunro,228, new GLatLng(57.20503,-6.2119),"Sgurr Dubh Mor","3097ft","944m","32","H"));
    batch.push(createMarker(iconmunro,229, new GLatLng(56.27382,-4.75518),"Ben Vorlich [Loch Lomond]","3093ft","943m","50 + 56","H"));
    batch.push(createMarker(iconmunro,230, new GLatLng(56.76704,-4.91104),"Binnein Beag","3093ft","943m","41","H"));
    batch.push(createMarker(iconmunro,231, new GLatLng(56.76028,-4.58996),"Carn Dearg [Rannoch region]","3087ft","941m","41 + 42","H"));
    batch.push(createMarker(iconmunro,232, new GLatLng(56.91146,-4.17461),"Carn na Caim","3087ft","941m","42","H"));
    batch.push(createMarker(iconmunro,233, new GLatLng(56.33381,-4.59965),"Beinn a' Chroin","3083ft","940m","42","H"));
    batch.push(createMarker(iconmunro,234, new GLatLng(57.04904,-5.51497),"Luinne Bheinn","3080ft","939m","50 + 56","H"));
    batch.push(createMarker(iconmunro,235, new GLatLng(56.96971,-2.97352),"Mount Keen","3080ft","939m","44","H"));
    batch.push(createMarker(iconmunro,236, new GLatLng(56.74977,-5.07233),"Mullach nan Coirean","3080ft","939m","41","H"));
    batch.push(createMarker(iconmunro,237, new GLatLng(56.56627,-5.17042),"Beinn Sgulaird","3074ft","937m","50","H"));
    batch.push(createMarker(iconmunro,238, new GLatLng(57.70195,-5.29195),"Beinn Tarsuinn [Letterewe]","3074ft","937m","19","H"));
    batch.push(createMarker(iconmunro,239, new GLatLng(57.00769,-4.92868),"Sron a' Choire Ghairbh","3074ft","937m","34","H"));
    batch.push(createMarker(iconmunro,240, new GLatLng(56.87033,-4.19864),"A' Bhuidheanach Beag","3070ft","936m","42","H"));
    batch.push(createMarker(iconmunro,241, new GLatLng(56.78919,-4.65991),"Beinn na Lap","3067ft","935m","41","H"));
    batch.push(createMarker(iconmunro,242, new GLatLng(57.24796,-6.20287),"Am Basteir","3064ft","934m","32","H"));
    batch.push(createMarker(iconmunro,243, new GLatLng(57.71263,-5.0484),"Meall a' Chrasgaidh","3064ft","934m","20","H"));
    batch.push(createMarker(iconmunro,244, new GLatLng(56.32555,-4.64163),"Beinn Chabhair","3061ft","933m","50 + 56","H"));
    batch.push(createMarker(iconmunro,245, new GLatLng(56.87963,-3.4208),"The Cairnwell","3061ft","933m","43","H"));
    batch.push(createMarker(iconmunro,246, new GLatLng(57.61102,-5.10218),"Fionn Bheinn","3061ft","933m","20","H"));
    batch.push(createMarker(iconmunro,247, new GLatLng(57.49147,-5.46478),"Maol Chean-Dearg","3061ft","933m","25","H"));
    batch.push(createMarker(iconmunro,248, new GLatLng(56.61692,-4.44907),"Meall Buidhe [Glen Lyon North]","3057ft","932m","51","H"));
    batch.push(createMarker(iconmunro,249, new GLatLng(57.05523,-3.5533),"Beinn Bhreac [Glen Derry]","3054ft","931m","36 + 43","H"));
    batch.push(createMarker(iconmunro,250, new GLatLng(56.45389,-3.99211),"Ben Chonzie","3054ft","931m","51 + 52","H"));
    batch.push(createMarker(iconmunro,251, new GLatLng(57.10952,-4.17894),"A' Chailleach [Monadh Liath]","3051ft","930m","35","H"));
    batch.push(createMarker(iconmunro,252, new GLatLng(57.21958,-6.09321),"Bla Bheinn","3044ft","928m","32","H"));
    batch.push(createMarker(iconmunro,253, new GLatLng(56.84906,-3.246),"Mayar","3044ft","928m","44","H"));
    batch.push(createMarker(iconmunro,254, new GLatLng(56.56107,-4.94338),"Meall nan Eun","3044ft","928m","50","H"));
    batch.push(createMarker(iconmunro,255, new GLatLng(57.50014,-5.16972),"Moruisg","3044ft","928m","25","H"));
    batch.push(createMarker(iconmunro,256, new GLatLng(58.41331,-4.60768),"Ben Hope","3041ft","927m","9","H"));
    batch.push(createMarker(iconmunro,257, new GLatLng(57.81347,-4.93432),"Eididh nan Clach Geala","3041ft","927m","20","H"));
    batch.push(createMarker(iconmunro,258, new GLatLng(57.51202,-5.40025),"Beinn Liath Mhor","3038ft","926m","25","H"));
    batch.push(createMarker(iconmunro,259, new GLatLng(56.22075,-4.78896),"Beinn Narnain","3038ft","926m","56","H"));
    batch.push(createMarker(iconmunro,260, new GLatLng(57.05764,-4.37347),"Geal Charn [Monadh Liath]","3038ft","926m","35","H"));
    batch.push(createMarker(iconmunro,261, new GLatLng(56.56646,-4.25969),"Meall a' Choire Leith","3038ft","926m","51","H"));
    batch.push(createMarker(iconmunro,262, new GLatLng(57.84713,-4.89694),"Seana Bhraigh","3038ft","926m","20","H"));
    batch.push(createMarker(iconmunro,263, new GLatLng(56.64987,-4.9516),"Stob Coire Raineach (Buachaille Etive Beag)","3034ft","925m","41","H"));
    batch.push(createMarker(iconmunro,264, new GLatLng(56.89965,-4.48497),"Creag Pitridh","3031ft","924m","42","H"));
    batch.push(createMarker(iconmunro,265, new GLatLng(57.1958,-6.21118),"Sgurr nan Eag","3031ft","924m","32","H"));
    batch.push(createMarker(iconmunro,266, new GLatLng(57.66753,-4.94951),"An Coileachan","3028ft","923m","20","H"));
    batch.push(createMarker(iconmunro,267, new GLatLng(57.68105,-5.04625),"Sgurr nan Each","3028ft","923m","20","H"));
    batch.push(createMarker(iconmunro,268, new GLatLng(57.58044,-5.58185),"Tom na Gruagaich (Beinn Alligin)","3024ft","922m","19 + 24","H"));
    batch.push(createMarker(iconmunro,269, new GLatLng(57.25759,-5.1714),"An Socach [Glen Affric]","3021ft","921m","25 + 33","H"));
    batch.push(createMarker(iconmunro,270, new GLatLng(56.45341,-4.49567),"Sgiath Chuil","3021ft","921m","51","H"));
    batch.push(createMarker(iconmunro,271, new GLatLng(57.12476,-4.17571),"Carn Sgulain","3018ft","920m","35","H"));
    batch.push(createMarker(iconmunro,272, new GLatLng(57.04486,-5.25762),"Gairich","3015ft","919m","33","H"));
    batch.push(createMarker(iconmunro,273, new GLatLng(57.25481,-5.30368),"A' Ghlas-bheinn","3011ft","918m","33","H"));
    batch.push(createMarker(iconmunro,274, new GLatLng(57.14728,-5.33476),"Creag nan Damh","3011ft","918m","33","H"));
    batch.push(createMarker(iconmunro,275, new GLatLng(56.98895,-4.93033),"Meall na Teanga","3011ft","918m","34","H"));
    batch.push(createMarker(iconmunro,276, new GLatLng(57.72685,-5.3295),"Ruadh Stac Mor","3011ft","918m","19","H"));
    batch.push(createMarker(iconmunro,277, new GLatLng(57.23106,-6.23212),"Sgurr a' Mhadaidh","3011ft","918m","32","H"));
    batch.push(createMarker(iconmunro,278, new GLatLng(56.89587,-3.42289),"Carn Aosda","3008ft","917m","43","H"));
    batch.push(createMarker(iconmunro,279, new GLatLng(56.87445,-4.30441),"Geal Charn [Drumochter Pass]","3008ft","917m","42","H"));
    batch.push(createMarker(iconmunro,280, new GLatLng(57.74585,-5.2593),"Beinn a' Chlaidheimh","3005ft","916m","19","H"));
    batch.push(createMarker(iconmunro,281, new GLatLng(56.39011,-4.83569),"Beinn a' Chleibh","3005ft","916m","50","H"));
    batch.push(createMarker(iconmunro,282, new GLatLng(56.93584,-4.69451),"Beinn Teallach","3001ft","915m","34 + 41","H"));
    batch.push(createMarker(iconmunro,283, new GLatLng(56.24985,-4.78171),"Ben Vane","3001ft","915m","56","H"));
    batch.push(createMarker(iconmunro,284, new GLatLng(57.48222,-5.1922),"Sgurr nan Ceannaichean","3001ft","915m","25","H"));
    return batch;
}



function GLoad() 
{
    GAddMessages({10093: 'Conditions d\x27utilisation'});
}

function ShowSmokescreen() {
    Shadowbox.init({ skipSetup: true });
    if ((document.referrer == '' || document.referrer.indexOf('ptarmiganmc') < 0) && getCookie('ptarmigan') == null) {
        LoadWelcome();
        setCookie('ptarmigan', 'yes');
    }
}

function LoadWelcome() {
	
    Shadowbox.open({
        player: 'html',
        title: 'Welcome to the Ptarmigan Mountaineering Club',
        content: '<div id="welcome-msg"><img src="images/ptarmiganmc.jpg" alt=""></div>',
        height: 213,
        width: 398
    });
}

function LoadMeets(fromAddress, midAddress, toAddress, date, longdate , toCity) {
		
    Shadowbox.init({ overlayColor: "#ffffff", overlayOpacity: 0.3 }); 
    
    Shadowbox.open({
        player: 'html',        
        content: '<div id="mapcontainer">' + toCity + ' - ' + longdate + '<div id="map_canvas"></div><p id="estimate"></p></div>',
        height: 500,
        width: 650,        
        options: {
            onFinish: function() {GLoad(); initialize(); setDirections(fromAddress, midAddress, toAddress, toCity); }
        }
    });
}

function LoadAlmanac(fromAddress, midAddress, toAddress, date, longdate , toCity) {
		
    Shadowbox.init({ overlayColor: "#ffffff", overlayOpacity: 0.3 }); 
    
    Shadowbox.open({
        player: 'html',        
        content: '<div id="almanac"></div>',
        height: 250,
        width: 350,        
        options: {
            onFinish: function() { setInfoDates(fromAddress, midAddress, toAddress, date, toCity); }
        }
    });
}

//var strMeetsFile = "meets_" + new Date().getFullYear() + ".xml";
// CHANGE
//var strMeetsFile = "meets_" + new Date(2009,0,1).getFullYear() + ".xml";

function GetMeetsFile()
{
    var meetsFile = "meets_" + new Date().getFullYear() + ".xml";
    var meets = new Meets(meetsFile);  
    var lastMeetDate = meets.getLastMeetDate();
    var today = new Date();
    
    if (lastMeetDate.month == today.getMonth() + 1 && lastMeetDate.day < today.getDate() )
    {
        meetsFile = "meets_" + (today.getFullYear() + 1) + ".xml";       
        
    }    
    
    return meetsFile;
}

function InitializeMeets()
{   
    var meets = new Meets(GetMeetsFile());  
    AddCalendar(meets);     
    AddCalendarMeets(meets);    
}

function InitializeMeetsList()
{    
    var meets = new Meets(GetMeetsFile());
    
    var currentElement = document.getElementById("meets");
    if (currentElement == null) {        
        return;
    }
    
    var meetsText = "<ul>";    
    for (i = 0; i < meets.length; i++) {                
        
        var meetType = meets[i].type;
        // Build Details   
           
        // special event
        var strEvent = "";   
        if (meets[i].specialEvent.name != "") {            
            strEvent= "<a class='tooltip' href='#nogo'><img style='width:30px;height:30px;' src='images/" + meets[i].specialEvent.icon + "'" ;
            strEvent+= " alt='" + meets[i].specialEvent.name + "' /><span>";        
            strEvent+= meets[i].specialEvent.info;
            strEvent+= "</span></a>";
        }             
        
        var strRouteLink = "";
        var strRoute = "";
        var strAlmanacLink = "";
        var strBusStops = "";        
        var strDepart = "";  
        var strVia = "";        
        if (meets[i].directions.length == 0) {
            strRoute = "Destination TBA";
        }
        else { 
            // route
            strRoute = BuildRouteLink(meets[i].directions,meets[i].date.shortFormat,meets[i].date.longFormat,meets[i].destination, meets[i].destination);                                       
            
            // route icon
            strRouteLink = BuildRouteLink(meets[i].directions,meets[i].date.shortFormat,meets[i].date.longFormat,meets[i].destination, "<img src='images/globe-compass.png' alt='Show Route'/>");        
            
            // almanac icon
            strAlmanacLink = BuildAlmanacLink(meets[i].directions,meets[i].date.shortFormat,meets[i].date.longFormat,meets[i].destination);
                        
            // stops
            strBusStops = "<a class='tooltip' href='#nogo'><img src='images/busstop.png' alt='Bus Stops' /><span>Stops: ";                 
            for (j = 0; j < meets[i].stops.length; j++) {
                strBusStops += meets[i].stops[j];
                if (j != meets[i].stops.length - 1){
                    strBusStops += " / ";
                }
            }
            strBusStops += "</span></a>";     
            
            // depart hour != 07:30
            strDepart = "<span style='display:inline-block; vertical-align:top'>" + meets[i].date.longFormat;
            if (meets[i].time != "07:30") { strDepart += " at " + meets[i].time; }                
            strDepart += "</span>";
            if (strEvent != "") { strDepart += " " + strEvent;}  
            
            // via
            if (meets[i].via !="") { strVia += "via "  + meets[i].via; }
            
        }      
       
        meetsText += "<li";        
        if (meets[i].joint) {  meetsText += " class='joint' "; }
                       
        if (meetType != "Ptarmigan") {    
            meetsText +=  " style='text-align:right;'>";             
            meetsText += "<div class='highwaysMeetList'>"; 
            if (strEvent != "") { meetsText += "<span style='padding-right:35px;'>" + strEvent + "</span>"; }
            meetsText += meets[i].title + "</div>";    
            meetsText +="<ul";
            if (i < meets.length -1 && meets[i].date.month != meets[i+1].date.month ) { meetsText += " class='doubleborder' "; }
            meetsText += ">";                    
            meetsText +="<li class='destination' ><span style='padding-right:25px;'>" + strBusStops + "</span>" + strRoute + "&nbsp;&nbsp;" + strVia + "</li>";      
            meetsText +="<li class='route'>" + strRouteLink + "</li>";   
            meetsText +="<li class='almanac almanachighways' >" + strAlmanacLink + "</li>";                
        }
        else {                        
            meetsText += "><div class='ptarmiganMeetList'>" + meets[i].title + strEvent + "</div>";   
            meetsText +="<ul";
            if (i < meets.length -1 && meets[i].date.month != meets[i+1].date.month ) { meetsText += " class='doubleborder' "; }
            meetsText += ">";                        
            meetsText +="<li class='almanac almanacptarmigan'>" + strAlmanacLink + "</li>";
            meetsText +="<li class='route'>" + strRouteLink + "</li>";
            meetsText +="<li class='destination'>" + strRoute + "&nbsp;&nbsp;" + strVia + "&nbsp;&nbsp;" +  strBusStops + "</li>";            
        }
              
        meetsText +="</ul>";
        meetsText +="</li>"                    
    }    
    
    meetsText += "</ul>";
    currentElement.innerHTML = meetsText;   
}


function AddCalendar(meets)
{    
    var calendar = null;
      
    var dateon = [];
    var events = [];
    
    var meetsDates = [];
    
    // CHANGE
    var today = new Date();                                       
    //var today = new Date(2009,0,1);                                       
    var strToday = (today.getMonth() + 1) + "-" + today.getDate() + "-" + today.getFullYear();    
    
    var addedToday = false;
    
    var meetClass = "";
    var meetDate = "";
    var meetType = "";
    var meetDays = "";
                
    for (i = 0; i < meets.length; i++) {
                
        meetDate = meets[i].date.shortFormat;
        meetClass = meets[i].type.toLowerCase() + "meet";
        meetType = meets[i].type;
        meetDays = meets[i].date.days;
        
        if (meetDate == strToday) { addedToday = true; }         
             
        meetsDates[i] = meetDate;
                
        var dateArray = meetDate.split("-");         
        for (var j = 0; j< meetDays; j++) {                       
            var newMeet = new Date(dateArray[2], dateArray[0]-1, parseInt(dateArray[1])+j);            
            var strdate = (newMeet.getMonth() + 1) + "-" + newMeet.getDate() + "-" + newMeet.getFullYear();            
            dateon[strdate] = function (strdate,meetClass) {                                        
                    
                    document.getElementById('ng-date-' + strdate).className = meetClass;
                
            }.bind(this, [strdate,meetClass]);        
        }
        
        events[meetDate] = {click:function(meetDate, meetType){                                                       
			slideContent('section-' + meetDate);	
			document.getElementById('meettitle').className = "meettitle" + meetType;                 	    
        }.bind(this, [meetDate,meetType])};	                    
    }    
    
    if (!addedToday) {
        dateon[strToday] = function (td, strToday) { 
            td.setStyles({ 'background-color':'#efefef', 'font-weight':'bold', 'color':'#6978a1' });
        }; 
    }
                   
    calendar = new Calendar("calendar3", null, {inputType:'none', allowSelection:false, daysText:'short', startDate:new Date(today.getFullYear(),0,1), endDate:new Date(today.getFullYear(),11,31), visible:true, startDay:1});
    calendar.options.forceSelections = meetsDates;
    calendar.options.dateOnAvailable = dateon;
    calendar.options.tdEvents = events;        
    calendar.updateCalendar(meets.getNearestDate());         
    document.getElementById('calendar3').setStyle("background", "#ffffff url(images/calendar/bg_calendar_" + today.getMonth() + ".jpg) no-repeat");      
}


function AddCalendarMeets(meets) {

    var currentElement = document.getElementById("slider");
    if (currentElement == null) {        
        return;
    }
   
    var meetsText = "";        
    
    for (i = 0; i < meets.length; i++) {                
      
        // Build Details         
        
        // special event        
        var strEvent = "";                        
        if (meets[i].specialEvent.name != "") {  
            strEvent= "<a class='tooltipCalendar' href='#nogo'><img style='width:30px;height:30px;' src='images/" + meets[i].specialEvent.icon + "'" ;
            strEvent+= " alt='" + meets[i].specialEvent.name + "' /><span>";        
            strEvent+= meets[i].specialEvent.info;
            strEvent+= "</span></a>";
        }                           
            
        var strRouteLink = "";
        var strRoute = "";
        var strAlmanacLink = "";
        var strBusStops = "";
        var strDepart = "";
        if (meets[i].directions.length == 0) {
            strRoute = "Destination TBA";
        }
        else {
            // route icon
            strRouteLink = BuildRouteLink(meets[i].directions,meets[i].date.shortFormat,meets[i].date.longFormat,meets[i].destination, "<img src='images/globe-compass.png' alt='Show Route'/>");
            
            // route
            strRoute = BuildRouteLink(meets[i].directions,meets[i].date.shortFormat,meets[i].date.longFormat,meets[i].destination, meets[i].destination);                                       
            
            // almanac icon
            strAlmanacLink = BuildAlmanacLink(meets[i].directions,meets[i].date.shortFormat,meets[i].date.longFormat,meets[i].destination);              
               
            // stops
            for (j = 0; j < meets[i].stops.length; j++) {
                strBusStops += meets[i].stops[j];
                if (j != meets[i].stops.length - 1){
                    strBusStops += " / ";
                }
            }                        
            
            strDepart = "<span style='display:inline-block; vertical-align:top'>" + meets[i].date.longFormat;        
            if (meets[i].time != "07:30") { strDepart += " at " + meets[i].time; }                
            strDepart += "</span>";
            if (strEvent != "") { strDepart += " <div class='special'>" + strEvent + "</div>"; }            
        }        
        
                        
              
        meetsText +="<div id='section-" + meets[i].date.shortFormat + "' class='section" + meets[i].type + "'>";                                               
                
        meetsText +="<div class='meetDetails";
        if (meets[i].joint) {
            meetsText += " jointMeet";
        }
        meetsText +="'>";
        
        meetsText += "<dl>";
        
        
        meetsText += "<dt>Depart:</dt><dd>" + strDepart + "</dd>";        
        meetsText += "<dt>Meet: </dt><dd>" + "<span style='display:inline-block; vertical-align:top'>" + strRoute + "</span>&nbsp;&nbsp;" + strRouteLink + "&nbsp;&nbsp;" + strAlmanacLink +  "</dd>";        
        meetsText += "<dt>Via: </dt><dd>" + meets[i].via + "</dd>";
        meetsText += "<dt class='stops'>Stops: </dt><dd class='stops'>" + strBusStops + "</dd>";        
        if (meets[i].notes.length > 0) {
            meetsText += "<dt>Notes: </dt><dd>" + meets[i].notes[0];        
        }
        if (meets[i].notes.length > 1)
        {
            meetsText +="<p><a class='amore' href='#nogo'>more »<span class='bgmore'><div class='onemore'><div class='twomore'><div class='threemore'><div class='more'>";
            for (var j=1; j<meets[i].notes.length; j++)
            {
                meetsText += "<br/>" + meets[i].notes[j] + "<br/>";
            }
            meetsText +="</br></div></div></div></div></span></a></p>";
        }
        meetsText += "</dd>";
        meetsText += "<dt></dt><dd></dd>";   
        meetsText += "</dl>";
        meetsText +="</div>";
        
        meetsText +="<div class='arrows'><div class='arrowup'>";     
        if (i != 0) {
            meetsText +="<a href='#nogo' onclick=MoveToMeet('" + meets[i-1].date.shortFormat + "','" + meets[i-1].type + "')><img src='images/calendar/arrow-up.png' onmouseover=ChangeImage(this,'images/calendar/arrow-up-hover.png') onmouseout=ChangeImage(this,'images/calendar/arrow-up.png') alt='Up' /></a>";
        }
        meetsText +="</div><div class='arrowdown'>";
        if (i != meets.length - 1) {
            meetsText +="<a href='#nogo' onclick=MoveToMeet('" + meets[i+1].date.shortFormat + "','" + meets[i+1].type + "')><img src='images/calendar/arrow-down.png' onmouseover=ChangeImage(this,'images/calendar/arrow-down-hover.png') onmouseout=ChangeImage(this,'images/calendar/arrow-down.png') alt='Down' /></a>";
        }
        meetsText +="</div></div>";          
        
        meetsText +="</div>";
    }    
    currentElement.innerHTML = meetsText;        
                  
    try      
    {        
        MoveToMeet(meets.getNearestDate(), meets.getNearestMeetType());        
    }
    catch(err) {MoveToMeet(meets[0].date.shortFormat, meets[0].type);}
}


function BuildRouteLink(directions, date, longdate, name, elm) {   
        
    var link = "<a href='#nogo' title='Show Route' onclick=" + "\"" + "LoadMeets(";             
    for (k = 0; k < directions.length; k++) {                    
        link += "'" + directions[k] + "',";                        
    }
    link += "'" + date + "',";
    link += "'" + longdate + "',";
    link += "'" + name + "'";
    link += ");" + "\"" + ">";
    link +=  elm.replace("\\'","\'");        
    link += "</a>";    
    return link;
}

function BuildAlmanacLink(directions, date, longdate, name) {
    var link = "<a href='#nogo' title='Show Almanac' onclick=" + "\"" + "LoadAlmanac(";             
    for (k = 0; k < directions.length; k++) {                    
        link += "'" + directions[k] + "',";                        
    }
    link += "'" + date + "',";
    link += "'" + longdate + "',";
    link += "'" + name + "'";
    link += ");" + "\"" + ">";
    link +=  "<img src='images/moon-almanac.png' alt='Show Almanac'/>";        
    link += "</a>";    
    return link;
}

function MoveToMeet(date,meetType)
{    
    slideContent("section-" + date);
    document.getElementById('meettitle').className = "meettitle" + meetType;       
}

function ChangeImage(obj,path)
{
    obj.src = path;
}


var SLIDETIMER = 10;
var SLIDESPEED = 12;
var STARTINGOPACITY = 40;

// handles section to section scrolling of the content //
function slideContent(id,prefix,timer) {    
  document.getElementById('meettitle').style.visibility = 'hidden';   
  var div = document.getElementById(id);
  var slider = div.parentNode;
  clearInterval(slider.timer);
  slider.section = parseInt(id.replace(/\D/g,''));
  slider.target = div.offsetTop;
  slider.style.top = slider.style.top || '0px';
  slider.current = slider.style.top.replace('px','');
  slider.direction = (Math.abs(slider.current) > slider.target) ? 1 : -1;
  slider.style.opacity = STARTINGOPACITY * .01;
  slider.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
  slider.timer = setInterval( function() { slideAnimate(slider,prefix,timer) }, SLIDETIMER);    
}

function slideAnimate(slider,prefix,timer) {
  var curr = Math.abs(slider.current);
  var tar = Math.abs(slider.target);
  var dir = slider.direction;  
  if((tar - curr <= SLIDESPEED && dir == -1) || (curr - tar <= SLIDESPEED && dir == 1)) {
    slider.style.top = (slider.target * -1) + 'px';
	slider.style.opacity = 1;
	slider.style.filter = 'alpha(opacity=100)';
    clearInterval(slider.timer);    
	if(slider.autoscroll) {
	  setTimeout( function() { autoScroll(slider.id,prefix,timer) }, timer * 1000);	 
	}
	document.getElementById('meettitle').style.visibility = 'visible';     	
  } else {
	var pos = (dir == 1) ? parseInt(slider.current) + SLIDESPEED : slider.current - SLIDESPEED;
    slider.current = pos;
    slider.style.top = pos + 'px';
  }  
}