$(function () {
	
	//Determin the correct width for each 
	
	//Determin the maximum height required for nested ULs and store in maxHeight var
	maxHeight = 0;
	
	$('ul#navigation ul').each(function(){
		if ( $(this).height() > maxHeight ) { maxHeight = $(this).height() }
	});
	


	//onclick - reveal or hide subnavigation, with height set by maxHeight
	
	$('ul#navigation li a.top_level').click( function () {

		if ( $('div#navigation_wrap').height() > 20 ) {
			
			$('div#navigation_btm').fadeOut(200);
			
			$('div#navigation_wrap').animate({ height: "20px" },{easing: "easeOutQuint"});
		
		}else{
			
			
			
			$('div#navigation_wrap').animate({ height: Math.max((maxHeight + 50), 120)+'px'}, {easing: "easeOutQuint"});
			
			$('div#navigation_btm').fadeIn(200);
			
		}
		return false;
	});
	
});

