// Author: Glenn Pittman
// Last Modified: 08 Sept. 2011
// Description: jQuery script that animates the display and hiding of the subnav menus in the site's
//		main navigation.


/////////////////////////////////////////////////////////
// 				navMenuAnimation function
/////////////////////////////////////////////////////////
// WHAT IT DOES: 
//		1. Uses the id of the primary nav to establish which subnav to display.
//		2. Loops through all the subnav menus and hides any that are set to "display: block".
//		3. Finds the appropriate subnav menu and slides it open.
//
// PARAMETERS ACCEPTED: none
//
// RETURN VALUE: none

function navMenuAnimation() {

	$('.primary_nav_item').click(function() {
										
		var navId = $(this).attr('id');  // the id of the primary nav item that has been clicked.
		var subNavId = "";  // empty variable that will contain the subnav menu to be displayed.
		
		// statement to assign the appropraite subnav menu id to the subNavId variable based on 
		// which primary nav item was clicked.
		switch(navId) {
			case "productions_primarynav" : subNavId = "productions_subnav";
			break;
			
			case "extras_primarynav" : subNavId = "extras_subnav";
			break;
			
			case "shopping_primarynav" : subNavId = "shopping_subnav";
			break;
			
			case "company_primarynav" : subNavId = "company_subnav";
			break;
			
			default: ;
		}
		
		// Loop to cycle through the subnav menus and hide any that are displayed.
		$('#subnav ul').each(function() {
		
			var displayValue = $(this).css('display');
			//alert(displayValue);
		
			if (displayValue === "block") {
			
				$(this).slideToggle('fast');
		
			};
		
		});
		
		// Lastly, we slide open the subnav menu that was requested.
		$('#subnav').find('#' + subNavId).slideToggle('fast');
								
	});	

}
