var navTimeout;
var shouldHide = true;
$(document).ready(function() {
	// dynamically add the li.bottom to each the WP generated dropmenus
	$('.vertical_menu li ul').append('<li class="bottom"></li>');

	$('#r_sidebar .vertical_menu li').hover(function() { 
		$('#l_sidebar .vertical_menu ul').hide();
	}, function() { return; });
	
	$('#l_sidebar .vertical_menu li').hover(function() { 
		$('#r_sidebar .vertical_menu ul').hide();
	}, function() { return; });
	
	$('.vertical_menu li').hover(function() { 
		if($(this).hasClass('top')) {
			$('.vertical_menu ul').hide();
		} else {
			$(this).parent('ul').find('> li > ul').hide();
		}
		$('> ul:first', this).show();
		shouldHide = false;
	}, function() { return; });
	
	$('.vertical_menu > ul').bind('mouseleave', function() { 
		shouldHide = true;
		navTimeout = setTimeout(function() {
			if(shouldHide) {
				$('.vertical_menu ul').each(function() { $(this).hide(); });
			}
		}, 1500);
	});
	$('ul.vertical_menu').bind('mouseleave', function() { 
		shouldHide = true;
		navTimeout = setTimeout(function() {
			if(shouldHide) {
				$('.vertical_menu ul').each(function() { $(this).hide(); });
			}
		}, 1500);
	});	
	
	var zIndexNumber = 1000;
	$('div, ul').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
	
	$('.flashPopup').click(function() {
		window.open(this.href, 'flashPopup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=604,height=392,left = 418,top = 254');		
		return false;
	});
});
