;(function($){
  function open_overlay(i) {
    $('body').prepend('<div id="lightbox_overlay"></div>');
    $('#lightbox_overlay').width($('body').width());
    $('#lightbox_overlay').height($('body').height());
    var open_callout = $('#overlay-content-' + i);
    $('#lightbox_overlay').fadeIn();
    open_callout.fadeIn();
    $('body').bind('click', function() {
      open_callout.fadeOut();
      $('#lightbox_overlay').fadeOut(400, function() {
        $('#lightbox_overlay').remove();
      });
    });
    return false;
  }
  $(function() {
    $('#preview .photo-info-content').html($('#preview .slide:first .info').html());
    api = $("#preview .slideshow").scrollable({
      circular: true,
      items: ".photos",
      onSeek: function() {
        $('#preview .photo-info-content').html(this.getItems().eq(this.getIndex()).find('.info').html());
        $('#preview .photo-info').fadeIn();
      }
    }).data('scrollable');
    $("#next-slide").click(function() {
      $('#preview .photo-info').fadeOut('fast', function() {
        api.next();
      });
    });
    $("#prev-slide").click(function() {
      $('#preview .photo-info').fadeOut('fast', function() {
        api.prev();
      });
    });
    $('ul#menu-main ul.sub-menu li:last').addClass('bottom');
    $('#newsletter-signup .email').focus(function() {
        if ($(this).val() == 'email address') $(this).val('');
    });
    $('#newsletter-signup .email').blur(function() {
        if ($(this).val() == '') $(this).val('email address');
    });
    $('.page-template-sample-php .callout').click(function() {
      return open_overlay($(this).attr('id').replace('callout-',''));
    });
    $('.page-template-sample-php .left-column p.desc-0, .page-template-sample-php .left-column p.desc-1, .page-template-sample-php .left-column p.desc-2').each(function() {
      $(this).prepend('<span id="clickable-' + $(this).attr('class').replace('desc-','') + '" class="clickable"></span>');
      $(this).find('span.clickable').click(function() {
        return open_overlay($(this).attr('id').replace('clickable-',''));
      });
    });
    $('#front-tabs .tab-headers a').click(function() {
      id = $(this).attr('id').replace('tab-header','');
      theaders = $('#front-tabs .tab-headers');
      theaders.removeClass('selected-0');
      theaders.removeClass('selected-1');
      theaders.removeClass('selected-2');
      $('#front-tabs .tab-headers').addClass('selected'+id);
      $('#front-tabs').find('.active').removeClass('active');
      $('#front-tabs #tab-header'+id).addClass('active');
      $('#front-tabs #tab'+id).addClass('active');
      return false;
    });
  });
})(jQuery);

