$(function () {
  // Display tab information
  $('ul#TabNavigation li').click(
    function () {
      $('div#TabInfo > div').stop(true,false).hide();
      $('div.' + this.className).fadeIn(500);
      $('#TabNavigation li').removeClass('selected');
      $(this).addClass('selected');
    }
  ).filter(':first').click();

  // Display show notes
  $('.Shows li').add('#LatestShows li').click(
    function() {
      // Load show notes
      var ShowInfo = $(this).text();
      var ID = ShowInfo.substring(6, ShowInfo.indexOf(":"));
      $('#ShowNotes').load('ShowNotes.asp?ID=' + ID);
      // Load player
      if (ID < 100) { ID = '0' + ID; }
      $('embed').attr({
        flashvars: 'file=http://archive.org/download/SoundsOfAmbience' + ID + '/SOA' + ID + '.mp3'
      });
      // Instructions
      $('#ClickToPlay').fadeIn().delay(750).animate(
        { left: '0px' },
        1250,
        function() {
          $('#ClickToPlay').hide().css({ left: '-60px' });
        }
      );
    }
  );
  // Load the show notes of the most recent show
  ($('#LatestShows li').eq(0).click());
  
  // As URL masking is being used, some links need to open in a new tab
  $('.AMP a').add('.Artists a').add('.Labels a').attr('target', '_blank');

});

