var Slideshow = function(oArgs) {
  this.slideContainerId = oArgs.id;
  $(this.setup);
}

Slideshow.prototype.setup = function() {
  setInterval("Slideshow.switch()", 5000);
}

Slideshow.prototype.switch = function() {
  var $active = $('#' + this.slideContainerId + ' img.active');

  if ($active.length == 0)
    $active = $('#' + this.slideContainerId + ' img:last');

  var $next = $active.next('img').length ? $active.next('img')
    : $('#' + this.slideContainerId + ' img:first');

  $active.addClass('last-active');

  $next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1000, function() {
      $active.removeClass('active last-active');
    });
}

var Slideshow = new Slideshow({id: "distinction"});

$(function() {
  $.localScroll({duration: 500});
  $(".pic-grid a").lightBox();
});
