$(document).ready(function(){
	
	//$(document).pngFix();
	var projectsBuild = false;
	
	$("#javaScript").hide();
	
	/////////////////////////////////
	// MENU ITEMS				   //
	/////////////////////////////////
	
	
	$("#logo ul li a").click(
		function(){
			$(this).parent().siblings().find("a").removeClass("active");
			$(this).addClass("active");
			showScreen($(this).attr("rel"));
		}
	)
	
	
	
	
	/////////////////////////////////
	// SCREENS   				   //
	/////////////////////////////////
	
	$("#rightCol").children().each(
		function(){
			$(this).css("left", "-750px");
			$(this).css("display", "block");
		}
	);
	
	$("#start").css("left", "0px");
	$("#recent").click( function(){$("#logo ul li a").eq(0).click();});
	
	
	function showScreen( id ){
		if(!projectsBuild){
			buildProjects();
			projectsBuild = true;
		}
		$("#" + id).siblings().animate({ left: -750}, 500, "easeout", function(){$("#" + id).animate({ left: 0}, 500, "easeout");});
		
		
	}
	
	
	/////////////////////////////////
	// PROJECT ITEMS			   //
	/////////////////////////////////
	
	function buildProjects(){
		var projectCount = $("#rightCol dl").length - 1;	
		$("#rightCol #projects dl").each(
			function(i){
				var position = -(projectCount-i) * 170 - 288;
				$(this).css("position", "absolute");
				$(this).css("left", position + "px");
				$(this).hover( showDescription, hideDescription);
				setTimeout( "throwInNext()", i*200);
			}
		);	
	
	}
	
	
	
	
	function showDescription( ){
		var index = $(this).prevAll().length;
		$(this).find("dd").animate({ left: 170}, 300, "easeout");
		$(this).nextAll().each( function(i){
			$(this).stop();
			$(this).animate({ left: (index+1+i)*170 + 170}, 300, "easeout");
		});
	}
	
	function hideDescription(){
		var index = $(this).prevAll().length;
		$(this).find("dd").animate({ left: 8}, 300, "easeout");
		$(this).nextAll().each( function(i){
			$(this).stop();
			$(this).animate({ left: (index+1+i)*170}, 300, "easeout");
		});
	}
	
	
	/////////////////////////////////
	// LIGHTBOX					   //
	/////////////////////////////////
	
	$("#playExusuMovie").fancybox({ 'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true, 'overlayOpacity': 0.8, 'playWidth': 768, 'playHeight': 445 });
	
	
	
});


var recentProject = 2;

function throwInNext( ){
		$("#rightCol dl").eq(recentProject).animate({ left: recentProject*170}, 1000, "easeout");
		recentProject--;
}





