$(document).ready(function(){
	jumpToPanel( $('#linkContainer a:first') );
	var intervalId = setInterval( function(){nextLink();}, 3000 );

		
	
	$("#linkContainer a").click(function(){
		clearInterval(intervalId);
		makeSelected( $(this) );
		jumpToPanel($(this));
		return false
	});
	
		
	
	

});

function makeSelected(theElement){	
	$('#linkContainer a').removeClass('selected');
	theElement.addClass('selected');
}

function nextLink(){
	next = ( $('#linkContainer a.selected').next().length > 0 ) ? $('#linkContainer a.selected').next() : $('#linkContainer a:first');
	jumpToPanel(next);
}

function jumpToPanel(theElement){
		makeSelected(theElement);
		$('#mask').scrollTo(theElement.attr('href'), 800); // the speed is controlled here
}