var imageDelay = 5000;

$(document).ready(function() {
	var numImages = $('#images img').length;
	if (numImages > 1) {
		$('#images img').not(':first-child').hide();
		window.setTimeout(nextPicture, imageDelay);
	}

	$('a.external').attr('target','_blank');
});

function nextPicture() {
	var currentImg = $('#images img:visible');
	var nextImg = currentImg.next();
	nextImg.css('z-index', '2');
	currentImg.css('z-index', '1');
	if (!nextImg.length) nextImg = $('#images img:first-child');
	nextImg.fadeIn(2000, function() { window.setTimeout(nextPicture, imageDelay); });
	currentImg.fadeOut(2000);
}

