$(document).ready(function(){

	$('#header_fv').load(frontpagepath + 'header.html',
		function() {
			$('#header_fv #persistentnav ul li.tab:last a.primary').css('border-right', 'none');
			
			var config = {    
			     sensitivity: 5, // number = sensitivity threshold (must be 1 or higher)    
			     interval: 100, // number = milliseconds for onMouseOver polling interval    
			     over: menuShow, // function = onMouseOver callback (REQUIRED)    
			     timeout: 200, // number = milliseconds delay before onMouseOut    
			     out: menuHide // function = onMouseOut callback (REQUIRED)    
			};

			$('#header_fv #persistentnav ul li.tab').hoverIntent(config)
		}
	);
	
	function menuShow() {

		var selectedLink = $(this);
		var adjacentLeftLink = $(this).prev();
		var menuContent = $(this).find('.menu');
		
		adjacentLeftLink.find('a.primary').css('border-right', 'none');
		adjacentLeftLink.css('padding-right', '1px');
		selectedLink.css('background', '#FFFFFF');
		selectedLink.find('.primary').css('color', '#9D1B33');
		
		if (menuContent.length == 0) {
			selectedLink.css('padding-bottom', '1px');
		}
		else {
			menuContent.show();
			selectedLink.css('padding-bottom', '');
			selectedLink.css('background', '#FFFFFF url(' + frontpagepath + 'images/arrow_down_gray.gif) bottom center no-repeat');
		}
		
	}
	
	function menuHide() {
		
		var selectedLink = $(this);
		var adjacentLeftLink = $(this).prev();	
		
		if (adjacentLeftLink.length != 0) {
			adjacentLeftLink.css('padding-right', '0');
			adjacentLeftLink.find( 'a.primary' ).css( 'border-right', '1px solid #FFFFFF' );
		}

		selectedLink.css('background', '');
		selectedLink.find('.primary').css('color', '');
		$(this).find('.menu').fadeOut('fast');
	}
	
});