$(document).ready(function(){
	
	$("nav a").hover(
		function(){
			if(!($(this).hasClass("active"))){$(this).animate({opacity:1},400);
			};
		},
		function(){
			if(!($(this).hasClass("active"))){$(this).animate({opacity:.5},400);
			};
		}
	);
	
	var timer;
	function setActiveTab() {
			clearTimeout(timer);
			$("#content .article, #content .article h2").stop(true, false).animate({opacity:0},300).removeClass("center active");
				$(activeId).css({visibility: "visible",opacity:0}).addClass("active").stop(true, false).animate({opacity:1},400);
				$(activeId+" h2").css({visibility: "visible",opacity:0}).addClass("active left").stop(true, false).animate({opacity:1},300);
			if(activeNav == "no1") {
				$("#no1 h2 img").stop(true, false).css({height: "45px",width: "105px"});
			} else if(activeNav == "dbld") {
				$("#dbld h2 img").stop(true, false).css({height:"246px",width:"316px"});
			} else if(activeNav == "essf") {
				$("#essf h2 img").stop(true, false).css({height:"136px",width:"245px"});
			} else if(activeNav == "hystk") {
				$("#hystk h2 img").stop(true, false).css({height:"70px",width:"245px"});
			}	
			backToSplash();
	};
	function backToSplash() {
		timer = setTimeout(function(){
			$("#content .article, #content .article h2").stop(true, false).animate({opacity:0},300,function(){
				$("#content .article, #content .article h2").removeClass("left active").removeAttr("style");
				$("#no1 h2 img").stop(true, false).css({height: "60px",width: "140px"});
				$("#dbld h2 img").stop(true, false).css({height:"300px",width:"385px"});
				$("#essf h2 img").stop(true, false).css({height:"145px",width:"260px"});
				$("#hystk h2 img").stop(true, false).css({height:"85px",width:"300px"});
				$("#content .article h2").addClass("center active").stop().animate({opacity:1},400);
				$("nav a").animate({opacity:.5}).removeClass("active");
			});
		},120000);
	};
	$("nav a").click(function() {
		activeNav = $(this).attr("class");
		activeId = "#"+activeNav;
		if(!($(this).hasClass("active"))) {
			setActiveTab();
			$("nav a").not(this).animate({opacity:.5}).removeClass("active");
			$(this).addClass("active");
		}
		return false;
	});
});