/*
	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);
	});
	
	
	$('.booknow a').click(function(){
		var target = $(this).attr("href");
		window.open(target, 'popup', 'height=600,width=600,toolbar=no');
		return false;
	});
	
	if( $('.booknow a').attr("href") == "" ){
		$(this).hide();
	};
});
