$(document).ready(function()
{
	
	centerThis('content'); 

	$("ul#items").fadeOut(3000);
	
	$("#menu").click(function() {
			
		$("ul#items").slideToggle("slow");		
		return false;
	});
		
	$("#photos a").click(function() {
		var imageSource = $(this).attr("href");
		
		$("#photos a").removeClass("selected");
 		$(this).addClass("selected"); 
				
		$("#wrap").addClass("loading");
		showImage(imageSource);
		return false;
	});
});

function showImage(src)
{
	$("#wrap img").fadeOut("fast").remove();

	var largeImage = new Image();

	$(largeImage).load(function() {
		$(this)[0].style.display = "none";
		$("#wrap").append(this).removeClass("loading");
									 
		$(this).fadeIn("slow");              
	});    
	$(largeImage).attr("src", src).attr("id", "photo");
}

function centerThis(div) {
	var winH = $(window).height();
	var centerDiv = $('#' + div);
	var topPadding = parseInt(centerDiv.css("padding-top"), 10);
	var topMargin = parseInt(centerDiv.css("margin-top"), 10);
	centerDiv.css('top', winH/2-centerDiv.height()/2-topPadding-topMargin);
}

$(window).resize(function(){
	centerThis('content'); 
});