var SliderBar = new Class({
	Extends: Slider,
	Implements: Options,
	options: {
		sliderContainerObject: null,
		sliderHandleObject: null,
		sliderBarItemsObject: null,
		sliderOptions: null,
		infoObject: null,
		increment: 0,
		totIncrement: 0,
		maxRightIncrement: 0,
		numberOfItems: 0,
		numberOfVisibleItems: 0
	},

	initialize: function(options) {
		this.setOptions(options);
		this.parent(this.options.sliderContainerObject, this.options.sliderHandleObject, this.options.sliderOptions);
		this.fx = new Fx.Morph(this.options.sliderBarItemsObject, {duration: 500, transition: Fx.Transitions.Back.easeInOut});
		this.timer = 0;
		this.auto();
	},
	
	auto: function() {
		this.onNext();
	    this.timer = this.auto.delay(3000, this);
	},

	onNext: function() {
	    if (this.options.totIncrement - this.options.increment < this.options.maxRightIncrement){
	        this.options.totIncrement = 0;
	    } else {
	        this.options.totIncrement -= this.options.increment;
	    }
	    this.set(-this.options.totIncrement/this.options.increment);
	    if (this.timer) this.timer = $clear(this.timer);
	},

    onMouseOver: function(event) {
		if (this.timer) this.timer = $clear(this.timer);
	},
	
	onMouseOut: function(event) {
		this.timer = this.auto.delay(1000, this);
	},

	setInfo: function() {
	    this.options.infoObject.innerHTML = ''+ Math.ceil(((-this.options.totIncrement/this.options.increment)+1)) + ' to ' + Math.ceil(((-this.options.totIncrement/this.options.increment)+this.options.numberOfVisibleItems)) + ' of ' + this.options.numberOfItems + '';
	},
	
	onUpdate: function(val) {
        this.options.totIncrement = val*(-this.options.increment);
		this.setInfo();
        this.fx.start({'margin-left': this.options.totIncrement});
	}
	
});
