$(function(){

	$(".email-signup input[name='email']").watermark("Email Address");

	$(".twitter-link, .rss-link").fadeTo(0, .5).hover(
		function(){ $(this).stop().animate({'opacity':'1'}, 250); },
		function(){ $(this).stop().animate({'opacity':'.5'}, 100); }
	);

	$("li:has(ul.children), li:has(ul.sub-menu)", ".menu-header")
		.mouseenter(function(){
			$("ul.children, ul.sub-menu", this).fadeIn("fast");
			$(this).addClass("liOver");
		})
		.mouseleave(function(){
			$("ul.children, ul.sub-menu", this).hide();
			$(this).removeClass("liOver");
		});

	/* Featured Stories Slider */
	
	var featuredStories = $("ul.stories-featured");
	var canSlide = true;
	
	setInterval( function(){
		$(featuredStories).parent()
			.mouseenter( 
				function(){ 
					canSlide = false;
					$(this).addClass("shadowed"); 
				} )
			.mouseleave(  
				function(){ 
					canSlide = true;
					$(this).removeClass("shadowed"); 
				} );
		var oneUnit = $("li:first", featuredStories).width();
		var leftVal = Math.abs( parseInt( $(featuredStories).css("left"), 10 ) );
		var ulWidth = $(featuredStories).width();
		if ( canSlide ) {
			if ( leftVal < (ulWidth - oneUnit) ) { 
				$(featuredStories).animate({left:'-=340px'}, 1000);
			} else { 
				$(featuredStories).animate({left:'0'}, 500); 
			}
		}
	}, 5000);
	
});
