// Switch the sheet.
function switchFonts(selectedFontSize) {
	$("link[rel='stylesheet']").each( function() {
		$(this).attr({disabled:false});
	});
	$("link[rel='stylesheet'][name!='"+selectedFontSize+"'][name!='normalFonts']").each( function() {
		$(this).attr({disabled:true});
	});
}

$(document).ready( function() {
	// Top nav stuff.
	$("#topNav li[class!='topNavSelected']").css({opacity : .8});
	$("#topNav li[class!='topNavSelected']").hover( function() {
		$(this).stop().animate({
			"paddingTop" : "10px",
			opacity : 1
		},100);
	}, function() {
		$(this).stop().animate({
			"paddingTop" : "0px",
			opacity : .8
		},300);
	});
	$("#topNav li.topNavSelected").css({"paddingTop" : "10px"});
	
	// Display search form
	$("#searchLink").click( function() {
		$("#search").slideToggle();
		return false;
	});
	
	// Homepage feature rotation
	$("#features").before("<div id='featureNav'></div>").cycle({
		pager : "#featureNav"
	});
	
	// Font size changer.
	var fontSize = $.cookie("fontSize");
	var activeStylesheet;

	if ( fontSize ) {
		activeStylesheet = fontSize;
	} else {
		activeStylesheet = "normalFonts";
	}
	$("link[rel='stylesheet'][name!='"+activeStylesheet+"'][name!='normalFonts']").each( function() {
		$(this).attr({disabled:true});
	});
	
	$(".switchFonts").click( function() {
		var selectedFontSize = $(this).attr("href");
		$.cookie("fontSize",selectedFontSize, { expires : 7} );
		switchFonts(selectedFontSize);
		return false;
	});

	// Subpage Tabs
	$("#pageNav li:eq(0)").addClass("pageNavSelected");
	$("div[id^='tab']:gt(0)").hide();
	$("#pageNav li").click( function() {
		$("#pageNav li").removeClass("pageNavSelected");
		$(this).addClass("pageNavSelected");
		
		$("div[id^='tab']").hide();
		var activeTab = $(this).find("a").attr("href");
		$("#"+activeTab).show();
		
		return false;
	});
	$("#subHeaderNav li").hover( function() {
		$(this).find("ul").show();
	}, function() {
		$(this).find("ul").hide();
	});
	
	$("#inputSearch").focus(function(){
		if($(this).val()=='Enter Keywords'){							 
			$(this).val('');
		}
	});

});