$(document).ready(function(){
  
 
  
  // Hides the photos for the start page, then shows them with a click
  $fotos = $('#start #background img')
  $fotos.hide().css({'opacity':'0.3'});
  $nav = $('#start ul#navigation');
  $sidebar = $('#start #sidebar');
  $sidebar.hide();
  
  $intro = $('#start #main');
  $intro.hide();
  
  $nav.hide();
  $('#content-wrapper p#logo img')
    .show().css({'opacity':'1'})
    .click(function(){
      $fotos.fadeIn(1400);
      $nav.fadeIn(1400);
      $sidebar.fadeIn(1400);
      $intro.fadeIn(1400);
      $(this).fadeOut(1400);
      // var link = $(this).parent('a').attr('href');
      // $fotos.wrap('<a href="/home"></a>');
      return false;
    });
  $gallery = $('#gallery');
  $gallery.css({'opacity':'1'})
  if($gallery.length > 0){
    $('#content').append('<div id="next_image"><div class="arrow" /></div><div id="prev_image"><div class="arrow" /></div>');
  }
  
  // The Cycle Plugin call for the gallery
  $gallery.cycle({ 
    fx:    'fade', 
    speed:  1000,
    timeout: 5000,
    next:   '#gallery img, #next_image',
    prev:   '#prev_image',
    pause: 1
  });
  // Adds a point to the cursor so it is apparent that a the photo is clickable
  // $('#gallery img').css({'cursor':'pointer'}); 
  // $('#background img').css({opacity:'0.3'});
  $('.arrow').css({'opacity':'0.2'}).hide();
  $('#next_image, #prev_image').hover(function(){
    $(this).find('.arrow').show();
  },function(){
    $(this).find('.arrow').hide();
  });
  
  var $scroller = $('#scroll');
  $(function(){
  	$scroller.jScrollPane({
  	  showArrows:false,
  	  scrollbarWidth:6,
  	  animateTo:true,
  	  animateInterval: 100
  	});
  }); 
  
  $('#calendar td a.trigger')  
    .css({'cursor':'pointer'})
    .click(function(){
      $('#listing tr').css({'fontWeight':'normal','color':'#f9efd3'}).find('a').css({'fontWeight':'normal','color':'#f9efd3'});       
      var date = this.id.split('_')[1]
      var listing = "#listing_" + date;   
      // $(this).css({'opacity':'0.7'});
      $(listing).css({'fontWeight':'bold','color':'black'}).find('a').css({'fontWeight':'bold','color':'black'}); 
      $scroller[0].scrollTo(listing);
      return false;
    });                               
    
});