$(document).ready(function() {
			
	$("hr").replaceWith("<div class='hr'></div>");
	
	// Get that menu looking nice		
	$('ul.nav').superfish({ 
	    delay:       1000,                            // one second delay on mouseout 
	    animation:   {opacity:'show'},  // fade-in and slide-down animation 
	    speed:       'fast',                          // faster animation speed 
	    autoArrows:  false,                           // disable generation of arrow mark-up 
	    dropShadows: false                            // disable drop shadows 
	});
	
	// Get that rotator mov'in
	var frameCount = $('#feature').children('div.frame').size();
	var featureHeight = frameCount * 270;
	$("#feature").css({width: featureHeight});


   /*
   *  Newsletter Form
   *  ===============
   */
   $('input.placeholder').val($('input.placeholder').data('instructions'));
   $('input.placeholder').focus(function() {
      if($(this).val() == $(this).data('instructions')) {
         $(this).val('');
      }
   });
   $('input.placeholder').blur(function() {
      if($(this).val() == '') {
         $(this).val($(this).data('instructions'));
      }
   });


	/* $('#newsfeed li.first a').click(function() {
		$("#feature-wrapper").scrollTo($("#feature div.first"), 800, {easing: 'easeInOutSine'});
		return false;
	});
	
	$('#newsfeed li.second a').click(function() {
		$("#feature-wrapper").scrollTo($("#feature div.second"), 800, {easing: 'easeInOutSine'});
		return false;
	});
	
	$('#newsfeed li.third a').click(function() {
		$("#feature-wrapper").scrollTo($("#feature div.third"), 800, {easing: 'easeInOutSine'});
		return false;
	});
	
	$('#newsfeed li.last a').click(function() {
		$("#feature-wrapper").scrollTo($("#feature div.last"), 800, {easing: 'easeInOutSine'});
		return false;
	}); */
	
	var timer = 0;	
	var clicked = 0;
	var slideIndex = 0;
	
	function slideShow() {		
		
		// content of moreSnow function		
		//if(clicked == 0) {
		var timer = setTimeout(slideShow, 7000);
		$("#newsfeed li").removeClass('active');
		$("#feature-wrapper").scrollTo($("#feature div:eq("+slideIndex+")"), 1000, {easing: 'easeInOutSine'});				
		if(slideIndex < 3) {
			$("#newsfeed ul li:eq("+slideIndex+")").addClass("active");
			slideIndex++;
		}else{
			$("#newsfeed ul li:eq("+slideIndex+")").addClass("active");
			slideIndex = 0;			
		}
		// repeat
		//}else{
		// if paused
		//clearTimeout(timer);
		//alert('paused');
		//}				
	}
	slideShow();
	
	// Pause Button
	$("#newsfeed a").click(function() {	
		var $parentLi = $(this).parent("li");
		$("#newsfeed li").removeClass('active');		
		$($parentLi).addClass('active');
		index = $("#newsfeed ul li").index($parentLi);
		$("#feature-wrapper").scrollTo($("#feature div:eq("+index+")"), 1000, {easing: 'easeInOutSine'});
		slideIndex = index;		
		//clicked = 1;
		clearTimeout(timer);			
		return false;
	});

	// Click Span to visit links
	$("#newsfeed li a span").click(function() {
		var linkLocation = $(this).parent("a").attr("href");
		window.location = linkLocation;		
		//alert('click');
	});
	
	// Span Hover
	$("#newsfeed li a span").hover(function() {
		$(this).css("text-decoration", "underline");
	}, function() {
		$(this).css("text-decoration", "none");
	});

});
