$(document).ready(function(){
	
	// Variable to store the number of sets
	var numItems = $("#sub_nav a").length - 1;
	
	// Hides every definition list "year_set" then shows the first project set and sets its class to "active_year_set"
	$(".year_set").css({ display: "none" });
	$(".year_set").eq(numItems).css({ display: "block" });
	$(".year_set").eq(numItems).toggleClass("active_year_set");
		
	// Set the year to have the current_section class
	$("#sub_nav a").eq(0).toggleClass("current_section");
	
	// Sets the year H3 to the year of the latest set
	var startingYear = $("#sub_nav a").eq(0).html();
	$(".awards_header").html(startingYear);
	
	// Sets up the click function for every sub navigation link
	$("#sub_nav a").each(function(int){
		$(this).click( function(){ 
			// Find the "active_year_set" then hide it
			$(".active_year_set").hide();
			// Turn off the existing "active_year_set", then turn it on for the clicked set
			$(".active_year_set").toggleClass("active_year_set");
			$(".year_set").eq(numItems - int).toggleClass("active_year_set");
			// Show the clicked set
			$(".active_year_set").fadeIn("medium");
			
			// Remove the .current_section class from any existing link, then add it to the clicked link
			if ($(".current_section")) {
				$(".current_section").toggleClass("current_section");
			}
			$(this).toggleClass("current_section");
			
			// Sets the year H3 to match the year of the active set
			var clickedYear = $(this).html();
			$(".awards_header").html(clickedYear);
			
			return false;
		});
	});
	
});




