$(document).ready(function(){ 

$("#gallery_thumbnails img").click(function() {
		//read the new values for the image and the title
		$newTitle = $(this).attr("alt");									
		$newImage = $(this).attr("src").replace("/thumbnails","");
		
		if ($newImage != $("#largeimg").attr("src")){//don't fade in and out if it's the same image - webkit gets upset
		
			//fade the image out, replace and fade the new one in
			$("#largeimg").fadeOut('fast',function() {
				$("#largeimg").attr("src",$newImage);
				$("#largeimg").fadeIn('fast');
			}) ;
			
			//fade the caption out, replace and fade the new one in
			$("#gallerycaption").fadeOut('fast',function() {
			$("#gallerycaption").html($newTitle);
			$("#gallerycaption").fadeIn('fast');
			});
			//update the alt and title on the new image
			$("#largeimg").attr("alt",$newTitle);
			$("#largeimg").attr("title",$newTitle);
			return false;
		}
})

});
