$(function(){
		   
	$(".full-img").each(function(i){
		if (i){
			$(this).hide();
		} else {
			$(this).attr("src", $(this).attr("srcx"));
			$("#description").text($(this).next(".description-copy").text());
		}
	});
	
	var idle = 1;
	
	$(".thumb").click(function(){
		var thumbImg = $(this);
		
		if (!(thumbImg.hasClass('curr')) && idle){
			
			idle = 0;
			
			$(".full-img:visible").slideUp('fast',function(){
				$(this).removeAttr('src');
			
				var fullImg = $(".full-img").eq($(".thumb").index(thumbImg));
				var srcx = fullImg.attr('srcx');
				var desc = fullImg.next(".description-copy").text();
				$(".thumb").removeClass('curr');
				thumbImg.addClass('curr');
				
				var imgObj = new Image;
				$(imgObj).load(function(){
						fullImg.attr('src',srcx);
						fullImg.slideDown('fast',function(){
							$("#description").text(desc);
							idle = 1;
						});
				});
				$(imgObj).attr('src',srcx);
			});
	
		}
	})
	.bind("mouseover mouseout",function(){
		$(this).toggleClass('thumb-over');
	});
	
	$("#gallery_link").click(function(){
		$("#screen").fadeIn('fast',function(){
			$("body").css('overflow','hidden');
		});
	});
	
	$("#close, .thumb-box-jplogo").click(function(){
		$("#screen").fadeOut('fast',function(){
			$("body").css('overflow','scroll');
		});
	});
	
});