// JavaScript Document

var scrollNewsContinuo = {
	initialize: function(element, options) {
		this.setOptions({
			scrollWait : false,
			scrollDuration: 2500,
			scrollOffsetX:-200,
			scrollOffsetY:0,
			scrollTransition: Fx.Transitions.Linear,
			divScrollerName: "scroller",
			divScrollerStyle: "scroller",
			scrollPeriodical: 15000
		},options);
		
		var divScrolledName = this.options.divScrolledName;
		var divScrollerName = this.options.divScrollerName;
		var divScrollerStyle = this.options.divScrollerStyle;
		var scrollWait = this.options.scrollWait;
		var scrollDuration = this.options.scrollDuration;
		var scrollOffsetX = this.options.scrollOffsetX;
		var scrollOffsetY = this.options.scrollOffsetY;
		var scrollTransition =  this.options.scrollTransition;
		var scrollPeriodical = this.options.scrollPeriodical;
		var periodical = null;
 		var cont = 1;
		var event;
		
		var scrolled = $(element);
		
		var scroller  = new Element('div', {id: divScrollerName});
		scroller.addClass(divScrollerStyle);	
		scroller.wraps(scrolled);
		
		var scrolledHeight = scrolled.getSize().y;
		var scrollerHeight = scroller.getSize().y;
		
		var effetto = new Fx.Tween(scrolled, {duration:(scrollPeriodical * (scrolledHeight / scrollerHeight)), transition:scrollTransition });
		function muoviNews(){
			effetto.start('margin-top', scrollerHeight, -scrolledHeight);
		};
		
		effetto.addEvent('complete', muoviNews);
		muoviNews();
		
		
		scrolled.addEvent('mouseover', function() {
			effetto.pause();
		});
		scrolled.addEvent('mouseout', function() {
			effetto.resume();
		});	
}};

scrollNewsContinuo = new Class(scrollNewsContinuo);
scrollNewsContinuo.implement(new Events);
scrollNewsContinuo.implement(new Options);
