function Slideshow(aArguments) {
  var arg
  this.transition_time=1000
  this.image_time=2000
  this.current_time=0
  this.step=25
  this.displayed=false
  this.images=[]
  this.index=-1
  for (arg in aArguments) {
    this[arg]=aArguments[arg]
  }
  Slideshow._slideshows[this.id]=this
}
Slideshow._slideshows={}
Slideshow.getSlideshow = function(id) {
  return Slideshow._slideshows[id]
}
Slideshow.prototype.initialize = function(aContainerDiv) {  
  this.container = aContainerDiv
  this.container.style.backgroundPosition = "center top"
  this.container.style.backgroundRepeat = "no-repeat"
  this.container.style.textAlign = "center"
  if ("height" in this) {
    this.container.style.height = this.height + "px"
  }
  if ("width" in this) {
    this.container.style.width = this.width
  }
  if ("bgcolor" in this) {
    this.container.style.backgroundColor = this.bgcolor
  }
  this.newImage = aContainerDiv.appendChild(
      document.createElement("img"))
  this.setOpacity()
  this.nextImage()
  setInterval(getDelegate(this, this.animate),this.step)
}
Slideshow.prototype.setOpacity = function() {
  var opacity = Math.min(1,this.current_time / this.transition_time)
  this.newImage.style.opacity=opacity
  this.newImage.style.filter='alpha(opacity=' + (opacity*100) + ')'
}

Slideshow.prototype.display = function() {
  document.write("<div id='" + this.id + "'></div>")
  this.initialize(_(this.id))
  //traiter this.bgcolor this.height, this.width
}
Slideshow.prototype.nextImage = function() {
  this.index = (this.index + 1) % this.images.length
  this.newImage.src = this.images[this.index]
}
Slideshow.prototype.animate = function() {
  if (!this.displayed) {
    if (this.current_time >= this.transition_time) {
      this.container.style.backgroundImage = "url(" + this.images[this.index] +")"
      this.displayed = true
      this.current_time = 0
      this.setOpacity()
      this.nextImage()
    } else if (this.newImage.complete) {
      this.setOpacity()
      this.current_time = this.current_time + this.step
    }
    
  } else  {
    if (this.current_time >= this.image_time) {
      this.displayed=false
      this.current_time = 0
    } else {
      this.current_time = this.current_time + this.step
    }
  } 
}