var Switch = Class.create({
  initialize: function(imageClass, time, effect) {
    if(document.getElementsByClassName(imageClass)) {
        this.image = document.getElementsByClassName(imageClass);
        for(i = 1; i < this.image.length; i++) {
            this.image[i].style.display = "none";
        }
    }
    this.time = time;
    this.effect = effect;
    this.current_image = 0;
    this.next_image = 1; 
   
    if(this.image.length > 1) {
        this.galerie();
    }
  },
  nextimage: function() {
    if(this.effect == 1) { 
        new Effect.Fade(this.image[this.current_image],{duration: 2.0}); 
        new Effect.Appear(this.image[this.next_image]); 
    }
    if(this.effect == 2) { 
        new Effect.BlindUp(this.image[this.current_image]); 
        new Effect.BlindDown(this.image[this.next_image]); 
    }
    if(this.effect == 3) { 
        new Effect.Fade(this.image[this.current_image]); 
        new Effect.Appear(this.image[this.next_image]); 
        new Effect.BlindUp(this.image[this.current_image]); 
        new Effect.BlindDown(this.image[this.next_image]); 
    }
    
    if(this.next_image == (this.image.length-1)) {
        this.current_image = this.next_image;
        this.next_image = 0;
    } else {
        this.current_image = this.next_image;
        this.next_image++;
    }
    this.galerie();  
  },
  galerie: function() {
    setTimeout(this.nextimage.bind(this),this.time);   
  }
});
