$(function() {
    $("#photosItems a.item").click(function() {
        var imageSource = $(this).attr("href");
		
        $("#photosLargeImage").addClass("loading");
          showImage(imageSource);
          return false;
    });

});

function showImage(src) {
	$("#photosLargeImage img").fadeOut("normal").remove();
	var largeImage = new Image();
	$(largeImage).load(function() {
		$(this).hide();
		$("#photosLargeImage").append(this).removeClass("loading");
		
		$(this).fadeIn("slow");
	});
	$(largeImage).attr("src", src);
}

// Auto load the first image in the list to the large image.
$(document).ready(function() {
	var largeImage2 = document.getElementById('largeImage');
	$(largeImage2).attr("src", $('#photosItems div a.item:first').attr('href'));
});