jQuery(function($) {
	var textVisibilityState = false; // state manager
	$(".section div.credits").toggle();
 	// init credit actions
	$("#credits").bind("click", function(){
		if(($(".section div.content").css("display"))=="block"){
			$(".section div.content, .section div.content p").fadeOut("slow");
			$(".section div.credits, .section div.credits p").fadeIn("slow");
		}else{
			$(".section div.content, .section div.content p").fadeIn("slow");
			$(".section div.credits, .section div.credits p").fadeOut("slow");
		}
		($("#credits a").text()=="Credits") ? $("#credits a").text("Turn Off Credits") : $("#credits a").text("Credits");
		return false;
	});
	$("#overlap").mouseover( function(){ 
		textVisibilityState = false;
		if($("#overlap").css("top")=="368px") $("#overlap").animate({top:239}, "slow", function(){if(!textVisibilityState)deactivateText();});
	} );
	// init button_panel actions
 	$("#button_panel a").bind("click", function(){
		var id = $(this).attr("id");
		if($("#overlap").css("top")=="368px"){
			$("#overlap").animate({top:239},"slow",function(){
			deactivateText();
			activateText(id);
			$("#overlap").animate({top:368}, "slow");
			});
		}else{
			deactivateText();
			activateText(id);
			$("#overlap").animate({top:368}, "slow");
		}
		return false;
	});
	// display descriptions
	function activateText(id){
		textVisibilityState = true;
		switch(id){
			case "experience":
				$("#text_experience").css("display","block");
				break;
			case "leader":
				$("#text_leader").css("display","block");
				break;
			case "results":
				$("#text_results").css("display","block");	
				break;
		}
	}
	// hide descriptions
	function deactivateText(){
		$("#text_experience").css("display","none");
		$("#text_leader").css("display","none");
		$("#text_results").css("display","none");
	}
 });
