// JavaScript Document

function slideShow( Obj ){

    var pass = this;
    // initializing
    this.curImg = 0;
    this.slides = Obj;
    this.slides.each( function( img, index ){
        if( index > 0 ) img.fade();
        img.set('morph', { duration: 'long' });
    }, this);
    this.next = function(){
        pass.curImg++;
        this.slides.each( function( img, index ){
            img.morph({ opacity: 0 });
        }, this);
        if( pass.curImg == this.slides.length ) pass.curImg = 0;
        if (this.slides[ pass.curImg ]) this.slides[ pass.curImg ].morph({ opacity: 1 });
    }
    this.prev = function(){
        pass.curImg--;
        this.slides.each( function( img, index ){
            img.morph({ opacity: 0 });
        }, this);
        if( pass.curImg < 0 ) pass.curImg = this.slides.length - 1;
        if (this.slides[ pass.curImg ]) this.slides[ pass.curImg ].morph({ opacity: 1 });
    }
}

window.addEvent( 'load', function(){

    if (sshow = new slideShow( $$('div#new-member img') )) {
        sshow.next.periodical( 10000, sshow );
    }

});

