  CrossFadeImages = function() {
    this.active = 1;
    this.container = $(CrossFadeImages.arguments[0]);
    this.containername = CrossFadeImages.arguments[0];
    this.images = CrossFadeImages.arguments.length-1;
    for(i=1;i!=CrossFadeImages.arguments.length;i++) {
      el = document.createElement('IMG');
      el.id = this.containername+'_'+i;
      el.src = CrossFadeImages.arguments[i];
      if (i == 1) this.setOpacity(el,100); else this.setOpacity(el,0);
      el.style.position = 'absolute';
      this.container.appendChild(el);
    }
    new PeriodicalExecuter(this.startFade.bind(this),5);
  }

  CrossFadeImages.prototype.setOpacity = function(el,o) {
    el.style.opacity = (o / 101);
    el.style.MozOpacity = (o / 100);
    el.style.KhtmlOpacity = (o / 100);
    el.style.filter = "alpha(opacity=" + o + ")";
  }

  CrossFadeImages.prototype.startFade = function() {
    i = (this.active+1>this.images) ? 1 : this.active+1;
    this.current = $(this.containername+'_'+this.active);
    this.next = $(this.containername+'_'+i);
    this.currentopacity = 100;
    this.nextopacity = 0;
    this.pe = new PeriodicalExecuter(this.fade.bind(this),0.01);
    this.active = i;
   }

  CrossFadeImages.prototype.fade = function() {
    this.currentopacity -= 2;
    this.nextopacity += 2;
    this.setOpacity(this.current,this.currentopacity);
    this.setOpacity(this.next,this.nextopacity);
    if (this.currentopacity == 0)
      this.pe.stop();
  }
