// script.aculo.us CarouselEffect.js

// Copyright(c) 2008 - Gaiaware AS, http://ajaxwidgets.com
//
// CarouselEffect.js is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
Effect.CarouselEffect = Class.create();
Effect.CarouselEffect.prototype = Object.extend(new Effect.Base(), {
	initialize: function(element, options) {
		this.element = $(element);
		this.options = Object.extend({
			scroll:500,
			max:1500
		}, options || {});
		this.start(this.options);
	},
	setup: function() {
		this.orPlace = this.element.scrollLeft;
		if( this.orPlace > this.options.max )
			this.toPlace = 0;
		else
			this.toPlace = this.orPlace + this.options.scroll;
		this.amount = this.toPlace - this.orPlace;
	},
	update: function(position) {
		this.element.scrollLeft = this.orPlace + (this.amount * position);
	},
	
	finish: function(){
		this.element.scrollLeft = this.toPlace;
	}
});
