var slider, 
	countdown, 
	canAdvance = true;

$(function(){

	/* FRONT PAGE SLIDER */
	slider = $("#featured-list");
	
	setInterval(function(){
		if (canAdvance) { advanceSlider(); }
	}, 10000);
	
	$(slider)
		.mouseenter(function(){ canAdvance = false; })
		.mouseleave(function(){ canAdvance = true; });
		
	/* STAY CONNECTED TABS */
	$("div.connected-panel:lt(2)").hide();
	$("div.tabs a:eq(2)").addClass("on");
	$("div.tabs a").click(function(e){
		e.preventDefault();
		clickedIndex = $("div.tabs a").index(this);
		$(this).addClass("on").siblings().removeClass("on");
		$("div.connected-panel").eq( clickedIndex ).show().siblings().hide();
	});

});

function advanceSlider(){
	if ( $(slider).not(":animated").length ) {
		( 2320 <= Math.abs( parseInt( $(slider).css("left") ) ) ) 
			? $(slider).animate( {left:'0'}, 1000 ) 
			: $(slider).animate( {left:'-=580'}, 1000 ) ;
	}
}
