$(function() {
  $('nav.account li:not(:last-child)').after('<li>|</li>');
  
  $('table.calendar tr td:first-child').addClass('first');
  $('table.calendar tr td:last-child').addClass('last');
  $('table.calendar tr:first-child th:first-child').addClass('tl');
  $('table.calendar tr:first-child th:last-child').addClass('tr');
  $('table.calendar tr:last-child td:first-child').addClass('bl');
  $('table.calendar tr:last-child td:last-child').addClass('br');
  
  $('.slideshow').cycle();
  
  $('a.event').facebox();  
  
  $('#my-account').each(function() {
    var myAccount  = $(this)
    var details    = myAccount.find('.account-details')
    var changeLink = myAccount.find('.account-details a')
    var cancelLink = myAccount.find('a.cancel')
    var fieldset   = myAccount.find('fieldset')
    
    myAccount.bind('toggleDetails', function() {
      fieldset.toggle()
      details.toggle()
    })
    
    changeLink.click(function() { myAccount.trigger('toggleDetails') })
    cancelLink.click(function() { myAccount.trigger('toggleDetails') })
  });
  
  $('.print-details').click(function() {
    window.print();
    return false
  })
  
  $('a.button-loader, button.button-loader').live('show.loader', function() {
    $(this).find('img.loader').show();
  }).live('hide.loader', function() {
    $(this).find('img.loader').hide();
  }).click(function() { $(this).trigger('show.loader'); return true; });
  
  $('a[href^="http"]').live('click', function() {
    var href = $(this).attr('href')
    
    if ((!href.match(/teamlola/)) || href.match(/\.pdf/)) {
      $(this).attr('target', '_blank')
    }
    
    return true
  })
  
  $('#photos a').facebox()
  $('a.videos').click(function() {
    jQuery.facebox({ div: $(this).attr('href') }, 'video-popup');
    return false
  })
});
