var minFlashHeight = 200;
var isFading = false;
var first = true;
$(document).ready(function(){
	$("#nav li a").bind("click", function(){
		if(!isFading) {
			var alllinks = $("#nav li a");
			alllinks.css("cursor","default");
			isFading = true;
			$("#nav li.active").removeClass("active");
			$(this).parent().addClass("active");
			var currentDiv = $($(this).attr("href"));
			var sideDiv = $($(this).attr("id"));
			
			$("#text div.active").fadeOut(500,function(){
				$("#text").animate({scrollTop: 0}, 10);
				$("#text div.active").removeClass("active");
				currentDiv.fadeIn(500,function(){
					isFading = false;
					currentDiv.addClass("active");
					alllinks.css("cursor","pointer");
				});
			});
			
			$("#text2 div.active").fadeOut(500,function(){
				$("#text2").animate({scrollTop: 0}, 10);
				$("#text2 div.active").removeClass("active");
				sideDiv.fadeIn(500,function(){
					isFading = false;
					sideDiv.addClass("active");
					alllinks.css("cursor","pointer");
				});
			});
		}
		return false;
	});

	headerHeight();
	$(window).bind('resize', function(){headerHeight();});

});

function headerHeight() {
	var flashHeight = 500;
	var windowHeight = $(window).height();
	if(windowHeight<747) {
		flashHeight = windowHeight - 257;
		if(flashHeight<minFlashHeight) flashHeight = minFlashHeight;
	}
	var flashWidth = flashHeight * 2;
	
	if(first) {
		so = new SWFObject("images/36SmartPeople.swf", "ca", flashWidth, flashHeight, "8", "#ffffff");
		so.addParam("wmode", "transparent");
		so.write("header");
		first = false;
	} else {
		$("#ca").attr("height",flashHeight).attr("width",flashWidth);
	}
}