$(document).ready(function() {
  var $nav = $('#navset a');
  var $sets = $('.tab-item');
  var $shows = $('.show-item');
  $nav.bind('click', function(e) {
    e.preventDefault();
    toggleSet.call(this);
  });
  function toggleSet() {
    var $this = $(this);
    var rel = $this.attr('rel');
    $nav.removeClass('current');
    $this.addClass('current');

    $sets.removeClass('active');
    $('#item-' + rel).addClass('active');

    if (location.pathname.match(/weddings/)) {
      return;
    }
    /* slideshows */
    $shows.removeClass('active');

    var show = $('#show-' + rel);
    show.addClass('active').show(1000);
  }
  var hash = location.hash.replace('#', '');
  if (hash.length > 0) {
    toggleSet.call($('#navset a[rel="' + hash + '"]').get(0));
  }
});