function showPhoto(photoId) {
	$('#banner img:not(#photo-'+photoId+')').fadeOut(1200); $('#photo-'+photoId).fadeIn(1200);
}

function rotate(i) {
	showPhoto(i);
	i=i%4+1;
	setTimeout('rotate('+i+')', 7000);
}

$(document).ready(function() {	
	(function($) {
		  var cache = [];
		  $.preLoadImages = function() {
		    var args_len = arguments.length;
		    for (var i = args_len; i--;) {
		      var cacheImage = document.createElement('img');
		      cacheImage.src = arguments[i];
		      cache.push(cacheImage);
		    }
		  }
		})(jQuery);
		
	jQuery.preLoadImages("./img/1.jpg", "./img/2.jpg", "./img/3.jpg", "./img/4.jpg", "./img/5.jpg", "./img/6.jpg");	
	$('<img id="photo-2" src="./img/photo-2.jpg" class="hidden" />').insertAfter('#banner img:last-child');
	$('<img id="photo-3" src="./img/photo-3.jpg" class="hidden" />').insertAfter('#banner img:last-child');
	$('<img id="photo-4" src="./img/photo-4.jpg" class="hidden" />').insertAfter('#banner img:last-child');
	$('<img id="photo-5" src="./img/photo-5.jpg" class="hidden" />').insertAfter('#banner img:last-child');
	$('<img id="photo-6" src="./img/photo-6.jpg" class="hidden" />').insertAfter('#banner img:last-child');
	$('a[title="Show first photo"]').click(function() { showPhoto(1); });
	$('a[title="Show second photo"]').click(function() { showPhoto(2); });
	$('a[title="Show third photo"]').click(function() { showPhoto(3); });
	$('a[title="Show fourth photo"]').click(function() { showPhoto(4); });
	$('a[title="Show fifth photo"]').click(function() { showPhoto(5); });
	$('a[title="Show sixth photo"]').click(function() { showPhoto(6); });
	rotate(1);
});
