var SlideShow = new Class({
    initialize: function(images_path) {
        var fx = []
        var images = new Asset.images(
            [images_path + 'banner_teleferico.jpg',
            images_path + 'banner_banana.jpg',
            images_path + 'banner_ueta.jpg'], {
                onComplete: function() {
                    for(var i = 0; i < images.length; i++) {
                        $('highlight').adopt(images[i]);                        
                    }
                    
                    var ii = 0;    
                    $$('#highlight img').each(function(img)
                    {
                        fx[ii] = new Fx.Slide(img, {
                            duration: 1000
                        })
                        if(ii != 0) {
                            fx[ii].hide();
                        }
                        
                        ii++;
                    }); 
                }                    
            }
        )
        
        this.images = images;       
        this.fx = fx;
        this.counter = 0;
        
        var params = {
            fx: this.fx,
            counter: this.counter
        }
        
        this.slide.periodical(5000, params);
    },
    
    slide: function() {
        var proximo;
        
        if(this.counter == this.fx.length) {
            this.counter = 0;
        }
        
        proximo = this.counter + 1;        
        if(proximo == this.fx.length) {
            proximo = 0;
            this.fx[proximo].show();
            this.fx[this.counter].hide();
               
        } else {
            this.fx[proximo].show();        
            this.fx[this.counter].slideOut();
        }
        
        this.counter += 1;
    }    
    
});
