var ImgShow = Class.create();
  ImgShow.prototype = {
    initialize: function(element, options) {
      this.element = $(element);
      this.options = Object.extend(options);
      this.images = $A(document.getElementsByClassName(this.options.className, this.element));

      this.prepareimages();
      this.registerCallback();
    },

    prepareimages: function() {
      this.currentimage = this.images.first();
      this.element.style.position = 'relative';
      this.element.style.height = this.images.max(function(image) {
        var visible = Element.visible(image), height;
        Element.setStyle(image, {position: 'absolute', width: '100%', left: '0px'});
        if (!visible) Element.show(image);
        height = Element.getHeight(image);
        if (!visible) Element.hide(image);
        return height;
      }).toString() + 'px';
    },

    nextimage: function() {
      return this.images[(this.images.indexOf(this.currentimage) + 1) % this.images.length];
    },

    registerCallback: function() {
      window.setTimeout(this.tick.bind(this), 1000);
    },

    tick: function() {
      var currentimage = this.currentimage, nextimage = this.nextimage();

      new Effect.Parallel([
        new Effect.Fade(currentimage, {sync: true}),
        new Effect.Appear(nextimage, {sync: true})
      ], {
        duration: 3,
        afterFinish: (function(effect) {
          this.currentimage = nextimage;
          this.registerCallback();
        }).bind(this)
      })
    }
  }