/*
Classe Scrolling()

metodi pubblici: init(
	scroller (String)        : selettore css per raggiungere l'elemento con jquery
	containerHeight (Number) : la dimensione del contenitore della parte scorrevole in pixel
	duration (Number)        : durata dello scorrimento in millisecondi	
)
*/

function Scrolling() {
	var istance; //da usare come alias di "this" quando richiamo i callback con jquery

	var height;
	var scrollAmount;
	var containerHeight;
	var duration;
	var scrollerObj;

	this.init = function init(scroller, containerHeight, duration) {
		this.scrollerObj = $(scroller);
		this.height = this.scrollerObj.height();
		this.scrollAmount = - this.height;
		this.containerHeight = containerHeight;
		this.duration = duration;
		this.scrollContent();
	}
	
	this.scrollContent = function scrollContent() {
		this.scrollerObj.css('top',this.containerHeight + 'px');
		istance = this;
		this.scrollerObj.animate({top: this.scrollAmount}, this.duration, "linear",  function() {
			istance.scrollContent();
		});
	}
}
