var secondaryNav = secondaryNav || { activeTimeout: {} };

jQuery(document).ready(function($){

	var tabList = $('ul#secondary-nav, ul#extra-nav');

	tabList.children('li').has('ul').each(function(i) {

		var listId = $(this).attr('id');

		$(this).children('a').eq(0).hoverIntent({
			'over' : function(e){

				var $next_ul = $(e.currentTarget).next('ul');
				var $parent_ul = $(e.currentTarget).closest('ul');
				// console.log('calling hover ' + listId + ' (e=' + e + ') color=' + $(e.currentTarget).css('color') );

				if ( ! $next_ul.is('.navOpen') ) {
					$parent_ul.find('.navOpen').removeClass('navOpen').slideUp();
				    	if ( $(e.currentTarget).css('color') != 'rgb(0, 0, 0)' ) {
						$next_ul.find('ul').show();
						$next_ul.addClass('navOpen').slideDown();
					}
				}
			},
			// No mouseleave...
			'out' : function(){},
			'interval' : 500
		});

		tabList.parent().mouseleave(
			function(e){
				// console.log('leaving hover ' + listId);
				$(e.currentTarget).find('ul.navOpen').removeClass('navOpen').slideUp();
			}
		);
	});

});

