$(document).ready(function(){
	//gives the image a drop shadow
	$('<div></div>').appendTo('#photos').css({
		position: 'absolute',
		width: $('#photos').width() + 'px',
		height: $('#photos').height() + 'px',
		backgroundColor: '#7c92a6',
		opacity: 0.6,
		top: ($('#photos').offset().top + 5) + 'px',
		left: ($('#photos').offset().left + 5) + 'px'
	  });
	
	rotatePics(1);
});

function rotatePics(currentPhoto) {
  var numberOfPhotos = $('#photos img').length;
  currentPhoto = currentPhoto % numberOfPhotos;
	
  $('#photos img').eq(currentPhoto).fadeOut(function() {
		// re-order the z-index
    $('#photos img').each(function(i) {
      $(this).css(
        'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
      );
    });
    $(this).show();
	setTimeout(function() {rotatePics(++currentPhoto);}, 2000);
  });
}

