function do_scroll_resume() {
	//set status to running
	scroll_running = true;
}
function do_scroll_pause() {
	//set status to pause
	scroll_running = false;
}
function do_scroll() {
	//if scroller is running, then move a little up
	scroll_top += scroll_running ? -0.5 : 0;
	//set the positions
	$('.news-block-content .news_scroller .newsitems').css( 'position','relative' ).css( 'top', ''+scroll_top+"px" );	
	//if the top position is way beyond the total height of ticker
	//then start over again from bottom
	if( scroll_top<-1*news_height + 55  ) scroll_top = ticker_height ; //orig. senza il +55
	//set the timer to invoke scroll again
	setTimeout( 'do_scroll()', 40 );
}
//events
function evt_do_scroll_resume() {
	//set status to running
	evt_scroll_running = true;
}
function evt_do_scroll_pause() {
	//set status to pause
	evt_scroll_running = false;
}
function evt_do_scroll() {
	//if scroller is running, then move a little up
	evt_scroll_top += evt_scroll_running ? -0.5 : 0;
	//set the positions
	$('.events-block-content .events_scroller .eventsitems').css( 'position','relative' ).css( 'top', ''+evt_scroll_top+"px" );	
	//if the top position is way beyond the total height of ticker
	//then start over again from bottom
	if( evt_scroll_top<-1*events_height + 55  ) evt_scroll_top = evt_ticker_height;
	//set the timer to invoke scroll again
	setTimeout( 'evt_do_scroll()', 40 );
}

$(document).ready(function(){
	//events
    //height of the events ticker widget
    evt_ticker_height = $('.events-block-content').height() - 15;
    //height of all the events elements combined
    events_height=$('.events-block-content .events_scroller .eventsitems').height();
    //scroll top offset
    evt_scroll_top = 0;
    //scroll status
    evt_scroll_running = true;

	//when mouse is over the scroller, pause
	$('.events-block-scroller').mouseover( evt_do_scroll_pause );
	//when mouse is out of the scroller, resume
	$('.events-block-scroller').mouseout( evt_do_scroll_resume );
	//start the scrolling
	evt_do_scroll();
	
	//NEWS
    //height of the news ticker widget
    ticker_height = $('.news-block-content').height() - 15; // orig. - 15
    //height of all the news elements combined
    news_height=$('.news-block-content .news_scroller .newsitems').height();
    //scroll top offset
    scroll_top = 0;
    //scroll status
    scroll_running = true;

	//when mouse is over the scroller, pause
	$('.news-block-scroller').mouseover( do_scroll_pause );
	//when mouse is out of the scroller, resume
	$('.news-block-scroller').mouseout( do_scroll_resume );
	//start the scrolling
	do_scroll();
});
