$(document).ready(function(){
  var stack = [];
  // preload images into an array
        
  $("#photos").cycle({
    timeout: 4000,
    speed: 750,
    pager: '#photos-nav-pager',
    before: onBefore
  });     
  
  // add images to slideshow
  function onBefore(curr, next, opts) {
    if (opts.addSlide) // <-- important!
    while(stack.length)
    opts.addSlide(stack.shift());
  }; 
  
  $('#pause-button a').click(function() { 
    $('#photos').cycle('pause'); 
  });
  
  $('#play-button a').click(function() { 
      $('#photos').cycle('resume'); 
  });
  
  
  
  $("#fullwidth-photos").cycle({
    timeout: 4000,
    speed: 750,
    pager: '#fullwidth-photos-nav-pager',
    before: onBefore
  }); 
  
  $('#fullwidth-pause-button a').click(function() { 
    $('#fullwidth-photos').cycle('pause'); 
  });
  
  $('#fullwidth-play-button a').click(function() { 
      $('#fullwidth-photos').cycle('resume'); 
  });

  $("#home-sail").addClass("preselect");
    
 $("#home-sail").hover(
    function () { 
      $('#home-sail ul').fadeIn(200);
      $("#home-sail").removeClass("preselect");
    },
    function () {       
      $("#home-sail ul").fadeOut(200);
    }
  );
  
  $("#home-power").hover(
    function () { 
      $('#home-power ul').fadeIn(200);
      $("#home-sail").removeClass("preselect");
    },
    function () {       
      $("#home-power ul").fadeOut(200);
    }
  );
  
  $("#home-interior").hover(
    function () {
      $('#home-interior ul').fadeIn(200);
      $("#home-sail").removeClass("preselect");
    },
    function () {
      $("#home-interior ul").fadeOut(200);
    }
  );
  
  $("#home-archive").hover(
    function () {
      $('#home-archive ul').fadeIn(200);
      $("#home-sail").removeClass("preselect");
    },
    function () {
      $("#home-archive ul").fadeOut(200);
      
    }
  );
  
  $(".design-photo-content").hover(
    function () {
      $('.design-photo-content ul').fadeIn(200);
      $("#home-sail").removeClass("preselect");
    },
    function () {
      $(".design-photo-content ul").fadeOut(200);
    }
  );
  
 
  
  $(".post-thumb").each(function(i) {                             
        $(this).mouseover(function(){ 
            $('.photo-image img').attr('src', $(this).find('.post-thumb-image-large img').attr('src'));
            //$('.photo-image img').fadeIn(500);
        });
        $('.photo-image img').attr('src', $('.post-thumb:first').find('.post-thumb-image-large img').attr('src'));        
  }); 
  
});
