$(document).ready(function(){
						   
	$("#photo img").hide();
	$(window).load(
		function(){
      	$("#photo img").fadeIn(400);
    	}
	);
	

	$("#prev div.box").not("#sel").css({opacity: "0.5", cursor:"pointer"}).end().hover(
		function(){
		if ( this.id != "sel" )
		$(this).animate({opacity: 1}, 200);
		}, 
      	function(){
		if ( this.id != "sel" )
        $(this).animate({opacity: 0.5}, 400);
		}
	);



	$("#prev div.box").click(
		function(){
		if ( this.id != "sel" )
		{$("#photo, #text").hide();
		var path = $(this).children(":first").attr("src").replace(/thumb/, "large");
		var txt = $(this).children("div").html();
		$(this).attr("id","sel").css({opacity: "1", cursor:"default"})
		.siblings().removeAttr("id").css({opacity: "0.5", cursor:"pointer"});
		$("#text").empty().html(txt);
		if (txt == null) $("#text").empty();
		$("#work").addClass("load");
		$("#photo img").attr("src",path).load(
				function(){
				$("#work").removeClass("load");
				$("#photo, #text").fadeIn(300);
				}
		);}}
	);


		var n = $("div.box").length;
		if (n <= 9) $("#right").hide();
		if (n > 9) $("#prev").css("width","1404px");
		if (n > 18) $("#prev").css("width","2106px");
		if (n > 27) $("#prev").css("width","2808px");
		
		$("#right").click(
			function(){
			if ( $("#prev").is(":not(:animated)") )
			var p = $("#prev").css("right").replace(/px/, "")*1;
			var w = $("#prev").css("width").replace(/px/, "")*1-1404;
			
			if (p==0) $("#left").show();
			if (p==w) $("#right").hide();
			
			$("#prev").animate({right: p+702}, 1000);
				
			}				  
		);
		
		$("#left").hide().click(
			function(){
			if ( $("#prev").is(":not(:animated)") )
			var p = $("#prev").css("right").replace(/px/, "")*1;
			var w = $("#prev").css("width").replace(/px/, "")*1-1404;

			if (p==702) $("#left").hide();
			if (p!=w) $("#right").show();
			
			$("#prev").animate({right: p-702}, 1000);
			
			}				  
		);
	
	$("#year").html("&ndash;" + new Date().getFullYear());
});