/*
                     __                      ___                           __                    
         __         /\ \__                  /\_ \                         /\ \     __            
 __  __ /\_\   _ __ \ \ ,_\  __  __     __  \//\ \       __       __      \_\ \   /\_\     ___   
/\ \/\ \\/\ \ /\`'__\\ \ \/ /\ \/\ \  /'__`\  \ \ \    /'_ `\   /'__`\    /'_` \  \/\ \   / __`\ 
\ \ \_/ |\ \ \\ \ \/  \ \ \_\ \ \_\ \/\ \L\.\_ \_\ \_ /\ \L\ \ /\ \L\.\_ /\ \L\ \  \ \ \ /\ \L\ \
 \ \___/  \ \_\\ \_\   \ \__\\ \____/\ \__/.\_\/\____\\ \____ \\ \__/.\_\\ \___,_\ _\ \ \\ \____/
  \/__/    \/_/ \/_/    \/__/ \/___/  \/__/\/_/\/____/ \/___L\ \\/__/\/_/ \/__,_ //\ \_\ \\/___/ 
                                                         /\____/                  \ \____/       
                                                         \_/__/                    \/___/        
*/

var mooVsimpleSlide = new Class ({

	Implements: [Events, Options],

	options: {
		onStart     : Class.empty,
		onComplete  : Class.empty,
		transition  : Fx.Transitions.linear,
		duration    : 500,
		wait        : 5000
	},

	initialize: function(container, items, options) {
		this.setOptions(options);
		this.cont     = $(container);
		this.ziWidth  = this.cont.getCoordinates().width;
		this.ziHeight = this.cont.getCoordinates().height;
		this.items    = this.cont.getChildren('+items+') || [];
		this.itemsNum = this.items.length;
		this.fxOptions = { duration: this.options.duration, transition: this.options.transition };
		
		this.items.setStyle ('position', 'absolute');
		this.items.setStyles ({
			'left': 0,
			'top' : 0
		});
		for (var i = 1; i < this.itemsNum; i ++){
			this.items[i].setStyle('opacity', 0);
		}
		this.i = 0;
		this.play.delay(this.options.wait, this);
	},

	play: function(){
		this.i == this.itemsNum - 1 ? this.j = 0 : this.j = this.i + 1;
		var appFx = new Fx.Tween(this.items[this.j], this.fxOptions).start('opacity', 1);
		var disFx = new Fx.Tween(this.items[this.i], this.fxOptions).start('opacity', 0);
		this.i ++;
		if (this.i == this.itemsNum) this.i = 0; 
		this.enRoute = this.play.delay(this.options.wait, this);
	}

});