function slideShow( Obj ){
	var pass = this;
    // Initializing
    this.slides = Obj;
    pass.curImg = 0//$random(0, this.slides.length - 1);
	this.slides[ pass.curImg ].setStyle('visibility', 'visible');
	this.slides[ pass.curImg ].setStyle('opacity', 1);
	this.slides[ pass.curImg ].setStyle('z-index', 2);
 
	this.rand = function(){
		randNum = pass.curImg;
		while (randNum == pass.curImg) {
			randNum = $random(0, this.slides.length - 1);
		}
		pass.curImg = randNum;
        this.slides.each( function( img, index ){ 
            img.morph({ opacity: 0 });
        }, this);
        this.slides[ pass.curImg ].morph({ opacity: 1 });
    }
    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;
        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;
        this.slides[ pass.curImg ].morph({ opacity: 1 });
    }
}

window.addEvent( 'load', function(){
   sshow = new slideShow( $$('#mainimg img') );
   sshow.next.periodical( 6000, sshow ); //make next be rand for random
});
