var scrollIndex = 3;

var timer = "";

function stopScroll(){
	clearTimeout(timer);
}

function scrollNewsBox(){

	$('.nyhederleft_container .news-latest-container')[0].scrollTo('div.news-later-item:eq('+scrollIndex+')',false);
	
	if(scrollIndex==0){
		scrollIndex += 3;
		timer = setTimeout('scrollNewsBox()',8000);	
	} else if(scrollIndex >= 9){
		scrollIndex = 0;
		timer = setTimeout('scrollNewsBox()',7000);
	} else {
		scrollIndex += 3;
		timer = setTimeout('scrollNewsBox()',7000);
	}	
	
}


$(function(){

	$('.nyhederleft_container .news-latest-container').css('height','200px');
	$('.nyhederleft_container .news-latest-container').css('overflow','auto');
	$('.nyhederleft_container .news-latest-container').jScrollPane({animateTo:true, animateInterval:60, animateStep:15});
	//$('.news-latest-container').jScrollPane({animateTo:true, animateInterval:60, animateStep:6});
	//$('.news-latest-container').jScrollPane({animateTo:true, animateInterval:100, animateStep:1});


	
	$('.jScrollPaneContainer').mouseover(function(){
		stopScroll();
	});

	$('.jScrollPaneContainer').mouseout(function(){
		timer = setTimeout('scrollNewsBox()',2000);
	});
	
	timer = setTimeout('scrollNewsBox()',7000);
}); 


