/**
 * @author Fábio Miranda Costa <fabiomcosta@gmail.com>
 * http://www.meiocodigo.com
 */
var meioSlider = new Class({
	
	Implements: [Options],
	
	options: {
		transition: Fx.Transitions.Expo.easeOut
	},
	
	initialize: function($container,$elements,options){
		this.$container = $container;
		this.$elements = $elements;
		this.elementWidth = this.$elements[0].getSize().x.toInt();
		this.currentPage = 0;
		this.setOptions(options);
		this.fx = new Fx.Tween(this.$container,{property:'left',transition:this.options.transition,link:'cancel'});
		this.leftArrow = this.options.arrows[0];
		this.rightArrow = this.options.arrows[1];
		this.initSlider();
	},
	
	initSlider: function(){
		var elsLength = this.$elements.length;
		if( elsLength > 1 ){
			this.leftArrow.addEvent('click',function(){
				if( this.currentPage > 0 ){
					this.currentPage--;
					this.fx.start(-(this.currentPage*this.elementWidth));
				}
				return false;
			}.bind(this));
			this.rightArrow.addEvent('click',function(){
				if( this.currentPage < (elsLength-1) ){
					this.currentPage++;
					this.fx.start(-(this.currentPage*this.elementWidth));
				}
				return false;
			}.bind(this));
		}
	}
});