$(document).ready( function() {
	/* Functions for hover submenu on top of the page */
	function makeTall() {	
		$(this).children('div.subMenuContainer').fadeIn(200);
	}
	function makeShort() {
		$(this).children('div.subMenuContainer').fadeOut(100);
	}
	var config = {    
		 sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: makeTall, // function = onMouseOver callback (REQUIRED)    
		 timeout: 200, // number = milliseconds delay before onMouseOut    
		 out: makeShort // function = onMouseOut callback (REQUIRED)    
	};
	
	$("#menuContainer li").hoverIntent( config )
	
	
	/* Mouse over highlights */
	$('#menuContainer li a').hover( 
		function () {
			$(this).addClass('hovered');
		},
		function () {
			$(this).removeClass('hovered');
			
		}	
	);
	
	$('.newsItemContainer a').hover( 
		function () {
		$(this).css('color','#FFF');
		},
		function () {
		$(this).css('color','#666');
		}			
	);
	$('#bottomFeaturedStory').hover( 
		function () {
		$(this).css('color','#FFF');
		},
		function () {
		$(this).css('color','#666');
		}			
	);
		
	$('#bottomFeaturedArticle').hover( 
		function () {
		$('#bottomFeaturedArticleText').css('color','#FFF');
		$('#bottomFeaturedArticleText h5 a').css('color','#FFF');
		$('#bottomFeaturedArticleImage img').fadeTo('200','1');
		},
		function () {
		$('#bottomFeaturedArticleText').css('color','#666');
		$('#bottomFeaturedArticleText h5 a').css('color','#666');
		$('#bottomFeaturedArticleImage img').fadeTo('200','0.4');
		}			
	);
});
$(window).resize(function() {
	/* Check to see if subMenu exits page */
	$('#menuContainer li.menuItem').each( function() {
		var tull = $(this).width();		
		var toll = Math.floor(tull / 2 - 8);
		$(this).children('div.subMenuContainer').css('left','-20px');			
		$(this).children('div.subMenuContainer').children('div.subMenuArrow').css('left',toll+'px');	
	});
	
	$('#menuContainer li.mParent').each( function() {							  
		var banan = 532;
		var ex = $(this).offset().left;
		var eple = $(window).width();
		var bananasplit = banan + ex;
		
		if(bananasplit > eple) {				
			var mull = $(this).width();	
			var moll = Math.floor(mull / 2 - 8);
			mill = moll + 414;
			$(this).children('div.subMenuContainer').css('left','-434px');
			$(this).children('div.subMenuContainer').children('div.subMenuArrow').css('left',mill+'px');	
		} else {
			
		}
	});
});
