Scroller = Class.create(
{
	initialize: function(scroll,options)
	{
		this.executer = false;
		this.progress = 0;
		this.scroll = $(scroll);
		this.maxWidth = this.scroll.scrollWidth;
		this.options = {afterChange: Prototype.emptyFunction,interval: 0.05,step: 5};
		Object.extend(this.options,options || {});
	},
	left: function()
	{
		this.executer = new PeriodicalExecuter(this.stepLeft.bind(this,this.options.step),this.options.interval);
	},
	right: function()
	{
		this.executer = new PeriodicalExecuter(this.stepRight.bind(this,this.options.step),this.options.interval);
	},
	stop: function(reset)
	{
		if(this.executer)
			this.executer.stop();
	},
	stepLeft: function(amount)
	{
		this.setProgress(Math.max(0,this.progress-amount));
	},
	stepRight: function(amount)
	{
		this.setProgress(Math.min(this.maxWidth,this.progress+amount));
	},
	setProgress: function(value)
	{
		this.progress = value;
		this.scroll.scrollLeft = value;
	}
});

