/*//height of the news ticker widget
ticker_height_1 = 0;
//height of all the news elements combined
news_height_1=$('.newsitems_1').height()*2;
//scroll top offset
scroll_top_1 = 0;
//scroll status
scroll_running_1 = true;
*/



ticker_height_2 = 0;
//height of all the news elements combined
news_height_2=$('.newsitems_2').height()*2;
//scroll top offset
scroll_top_2 = 0;
//scroll status
scroll_running_2 = true;





function do_scroll_resume_1() {
	//set status to running
	scroll_running_1 = true;
}
function do_scroll_pause_1() {
	//set status to pause
	scroll_running_1 = false;
}
function do_scroll_resume_2() {
	//set status to running
	scroll_running_2 = true;
}
function do_scroll_pause_2() {
	//set status to pause
	scroll_running_2 = false;
}


function do_scroll_1() {
	//if scroller is running, then move a little up
	scroll_top_1 += scroll_running_1 ? -1 : 0;
	//set the positions
	$('.newsitems_1').css( 'position','relative' ).css( 'top', ''+scroll_top_1+"px" );	
	//if the top position is way beyond the total height of ticker
	//then start over again from bottom
	if( scroll_top_1<(-1*news_height_1)/2 ) scroll_top_1 = ticker_height_1;
	//set the timer to invoke scroll again
	setTimeout( 'do_scroll_1()', 40 );
}



function do_scroll_2() {
	//if scroller is running, then move a little up
	scroll_top_2 += scroll_running_2 ? -1 : 0;
	//set the positions
	$('.newsitems_2').css( 'position','relative' ).css( 'top', ''+scroll_top_2+"px" );	
	//if the top position is way beyond the total height of ticker
	//then start over again from bottom
	if( scroll_top_2<(-1*news_height_2)/2 ) scroll_top_2 = ticker_height_2;
	//set the timer to invoke scroll again
	setTimeout( 'do_scroll_2()', 40 );
}







$(document).ready(function(){
	//when mouse is over the scroller, pause
	/*$('.newsitems_1').html($('.newsitems_1').html() + $('.newsitems_1').html());
	$('.news_scroller_1').mouseover( do_scroll_pause_1 );
	//when mouse is out of the scroller, resume
	$('.news_scroller_1').mouseout( do_scroll_resume_1 );
	//start the scrolling
	do_scroll_1();
	*/
	
	$('.newsitems_2').html($('.newsitems_2').html() + $('.newsitems_2').html());
	$('.news_scroller_2').mouseover( do_scroll_pause_2 );
	//when mouse is out of the scroller, resume
	$('.news_scroller_2').mouseout( do_scroll_resume_2 );
	//start the scrolling
	do_scroll_2();
	
	
	
	
});
