// Accordian Menu and Swappable Content Area
// Noel Smart 2009 for The Washington Post

$(document).ready(function()
{
	// Menu Controls
	$('#menu p.menuHead:first').addClass('menuHeadOpen'); // Sets first menu category header as open
	$('#menu div.menuBody:first').addClass('menuBodyOpen'); // Sets first menu category body as open
	$("#menu p.menuHead").mouseover(function() //Mouseover function
    {
	    $(this).addClass('menuHeadOpen').siblings().removeClass('menuHeadOpen'); // Swaps header attributes
		$(this).next("div.menuBody").slideDown("slow").siblings("div.menuBody").slideUp("slow"); // Animates menu
		$(this).next("div.menuBody").addClass('menuBodyOpen').siblings().removeClass('menuBodyOpen'); // Swaps sub-menu attributes
	});
	
	//Content Controls
	$('#contentSwapper #content div.story').hide(); // Hides all divs
	$('#contentSwapper #content div.story:first').show(); // Shows the first div
	$('#contentSwapper #menu a:first').addClass('selected'); // Sets the class of the first link to selected
	$('#contentSwapper #menu a').click(function(){ //When any link is clicked
		$('#contentSwapper #menu a').removeClass('selected'); // Remove selected class from all links
		$(this).addClass('selected'); //Sets clicked link class to selected
		var currentLink = $(this).attr('href'); // Sets variable currentLink to value of href attribute of clicked link
		$('#contentSwapper #content div.story').hide(); // Hides all story divs
		$(currentLink).fadeIn("slow"); // Shows div with id equal to variable currentTab
		return false;
	});
});