
$(document).ready(function() {
  //  These need to be set for component scrolling to work
  $('html').height('100%');
  $('body').height('100%');
  var h = (window.innerHeight ? window.innerHeight : document.body.clientHeight) - 
           $('#title').height() - 30;
  $('#body').height(h);
  //  Insert the standard links
  $('#links').append(links);
  //  If in a lower directory, remove the directory name from the relative links
  $('#links > a').each(function() {
    if ($(this).attr('href').indexOf('/') >= 0)
      $(this).attr('href',$(this).attr('href').replace(/backpacking\/(.*)\//,'backpacking/'));
    else if (document.location.href.match(/backpacking\/.*\//) != null)
      $(this).attr('href','../'+$(this).attr('href'));
  });
  //  Restore the link to the Leaders Resources that we just zapped
  $('#links > a:eq(8)').attr('href','Leader_Forms/default.htm');
  //  If we can figure out which link is displayed, highlight it
  $('#links > a').each(function() {
    var here = document.location.href;
    if (here.match(/\/$/))   // '.../backpacking/' is really index.htm
      here = 'index.htm';
    if (here.replace(/.*\//,'') == $(this).attr('href').replace(/.*\//,''))
      $(this).addClass('selected');
  });  
});

var links = 
  '<a href="http://www.sierraclub.org/"><img src="weblogo_fall2002.gif" style="border:0; margin: 6px"/></a>'+
  '<a class="linkbutton" href="index.htm">Home</a>'+
  '<a class="linkbutton" href="about.htm">About the Section</a>'+
  '<a class="linkbutton" href="trips.htm">Trip Listing</a>'+
  '<a class="linkbutton" href="ratings.htm">Trip Ratings</a>'+
  '<a class="linkbutton" href="trailtips.htm">Trail Tips</a>'+
  '<a class="linkbutton" href="Links.htm">Useful Links</a>'+
  '<a class="linkbutton" href="committee.htm">Steering Committee</a>'+
  '<a class="linkbutton" href="Leader_Forms/default.htm">Leaders Resources</a>'+
  '<br/>'+
  '<a class="linkbutton" href="http://www.sierraclub.org/">Sierra Club</a>'+
  '<a class="linkbutton" href="http://www.sanfranciscobay.sierraclub.org/">SF Bay Chapter</a>';
  