var InOutSlider = new Class({
	
	//implements
	Implements: [Options, Events],

	//options
	options: {
		transition: 'expo:in:out',
		mode: 'horizontal',
		current_index: 0,
		interval: 7500,
		duration: 850
	},
	
	// FX instance container object
	fx : {},
	timer : 0,
	elements: {},
	
	//initialization
	initialize: function(elements, options) {
		//set options
		this.setOptions(options);
		// Set the elements into the class
		this.elements = elements;
		// Create FX instances
		this.elements.each(function(elem, index){
			this.fx[index] =  new Fx.Slide(elem, {
				mode: this.options.mode,
				duration: this.options.duration,
				transition: this.options.transition
			});
		},this);
		// Reset all slides to be 'out'
		this.hideAll();
		// Lets get this party started!!
		this.start();
	},
	
	//  Hides all elements
	hideAll: function(){
		Object.each(this.fx, function(fx, index){
			if(index!=this.options.current_index){
				fx.hide();
			}
		},this);
	},
	
	// Slide an element in
	slideIn: function(index) {
		(function() { this.fx[index].slideIn(); }).delay(this.options.duration - (this.options.duration / 2) , this);
		
	},
	
	// Slide an element out
	slideOut: function(index) {
		this.fx[index].slideOut();
	},
	
	// Start the timer to show each slide periodically
	start: function(){
		this.timer = this.next.periodical(this.options.interval, this);
	},
	
	// Stop the slide rotation and clear the timer
	stop: function(){
		clearInterval(this.timer);
	},
	
	// Hide one slide then show the next
	next: function(){
		this.slideOut(this.options.current_index);
		if(this.options.current_index<this.elements.length-1){
			this.options.current_index++;
		}
		else{
			this.options.current_index = 0;
		}
		this.slideIn(this.options.current_index);
	}
});

