/*
	Rollover drop-down navigation
	- Shows and hides sub-nav
	- Animates height of container to match contents 
		(height is lost using absolute positioning)
*/

var timer;
var defaultHeight = 29;
var animateTime = 100;	// x2 for close

// DOM ready Events
$(function () {
	// menu rollovers
	// reveal sub navigation when main nav item is rolled over...
	$('ul#navigation > li').hover(function(){
		clearTimeout(timer);
		// Hide all sub-navigation lists
		$('ul#navigation li ul').hide();
		// Show this sub-navigation list
		$(this).find("ul").show();
		// Set height of container to include height of 'this'
		$('ul#navigation').animate({ 
			height: Math.min(117, defaultHeight + $(this).find("ul").height())
			}, animateTime);
	
	},function(){
		// Timeout cancelled on 
		timer=setTimeout(function(){
			// Set height of container back to not include sub-navigations
			$('ul#navigation').animate({ 
				height: defaultHeight
				}, animateTime*2);	
			// Hide all sub-navigation lists
			$('ul#navigation li ul').hide();
		}, 300);
	});
});