// JavaScript Document
$(document).ready(function(){
	function rotatePics(currentPhoto) {
		var numberOfPhotos = $('#slideshow div').length;
		currentPhoto = currentPhoto % numberOfPhotos;
		
		$('#slideshow div').eq(currentPhoto).fadeOut("slow", function() {
			// re-order the z-index
			$('#slideshow div').each(function(i) {
				$(this).css(
					'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
				);
			});
			$(this).show();
			setTimeout(function() {rotatePics(++currentPhoto);}, 4000);
		});
	}
	$('#slideshow div').eq(1).hide(); //Forhindrer crossfade ved indlęsning af siden
	rotatePics(1);
});
