$(document).ready(function(){
  // Auto Rotate our home page slideshow
  var slideShowInterval = 7000;
  var slideIntervalId = setInterval("slideSwitch()", slideShowInterval);

  // Lightbox images
  $("a.lightbox").fancybox();
});

function slideSwitch(next_id) {
  var $active = $('#slideshow img.active');
  if ( $active.length == 0 ) $active = $('#slideshow img:last');
  if (next_id) {
    var $next = $("#" + next_id);
    var speed = 0;
  } else {
    var $next =  $active.next().length ? $active.next() : $('#slideshow img:first');
    var speed = 800;
  }
  $active.addClass('last-active');
  $next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, speed * 2, function() {
    $active.removeClass('active last-active');
  });
}


