var cPhotoSlide = new Class({
							
	Implements: [Events, Options],
	
	options : {
		delay : 0,
		wait : 4000,
		randomize : false,
		index : 1
	},	
	initialize: function(elemento, options) {
		if($chk(elemento)){
			this._elemento = elemento;
			this.setOptions(options);
			this._v_imagenes = this._elemento.getElements('img');
			this._total_imagenes = this.getImagesProperties().length;
			this._imagenes_visibles = Math.round(this._elemento.getSize().x/this.getImagesProperties().width);
			this._steps = this._imagenes_visibles;
			this._index = (this.options.index>0 && this.options.index<=this._steps) ? this.options.index-2 : -1;
			if(this.options.randomize){
				this._index = $random(1, this._steps);
				this._index -= 2;
			}
			this._indexN = this._index+this._steps;
			//
			if(this._total_imagenes>this._imagenes_visibles){
				this._v_imagenes.each(function(ele, ind){
					ele.store('propiedades', ele.getProperties('src','alt','title')).set({
						'styles' : {
							'opacity' : (ind+1)<this._total_imagenes ? 1 : 0
						}
					});
				}, this);
				this.initMoveImages(1);
			}
		}
	},
	getImagesProperties : function() {
		return { length : this._v_imagenes.length, width : this._v_imagenes[0].getSize().x }
	},
	moveImages : function() {
		this._index = this._index>=(this._steps-1) ? 0 : this._index+1;
		var _objA = this._v_imagenes[this._index];
		//
		this._indexN = this._indexN>=(this._total_imagenes-1) ? 0 : this._indexN+1;
		var _objB = this._v_imagenes[this._indexN];	
		var _objBprop = _objB.retrieve('propiedades');
		//
		
		new Fx.Tween(_objA,{duration:400}).start('opacity', 0).addEvent('complete', function(){
			_objA.set({
				'src' : _objBprop.src,
				'alt' : _objBprop.alt,
				'title' : _objBprop.title
			});
			
			new Fx.Tween(_objA,{duration:800}).start('opacity', 1).addEvent('complete', function(){
				this.initMoveImages(0);
			}.bind(this));
		}.bind(this));
	
	},
	initMoveImages : function(t) {
		this.moveImages.delay(t ? this.options.wait + this.options.delay : this.options.wait, this);
	}
});
