$(document).ready( function(){

	$(".thumbnails li a").each(function(){
		$(this).css({
			backgroundImage: "url(/portfolio/" + $(this).parent().parent().parent().children(":first").text() + "/" + $(this).html() + "-t.jpg)"
		})
		if ( !$("body").hasClass("statement") ){
			$(this).mouseover(function(){
				$("#display .item").hide();
				$("#display .item").eq( $(this).parent().prevAll().length ).show();
			});			
		} else {
			$(this).click(function(){
				window.location.href = "index.html";
			});
		}
	});
});

$(window).load( function(){
	$("#display .item").each(function(){

		dW = 588;
		pW = $(this).contents("p").width();
		if (pW < 20) pW = 170;
		iW = $(this).contents("img:first").attr('width');
		rW = dW - pW - iW;
		leftSpace = Math.floor(rW/2);
		
		dH = 545;
		iH = $(this).contents("img:first").attr('height');
		pH = $(this).contents("p").height();
		if (pH < 10) pH = 52;
		rH = dH - iH;
		topSpace = Math.floor(rH/2);
		
		pLeft = leftSpace + iW +30;
		pTop = topSpace + iH - pH;
		
		$(this).contents("img").css({
			marginLeft: leftSpace,
			marginTop: topSpace
		});
		$(this).contents("p").css({
			left: pLeft,
			top: pTop
		});
		
	});

	//$('#display img').reflect({height:0.25,opacity:0.25});
	
	
	$("#display .item:gt(0)").css({
		display:"none"
	})
	
	$("#display").css({
		left:"411px"
	});
	
	
	
});
