 //imagecache
  var loadedImages = []
  
  function Slideshow() {
    this.d = [ document.getElementById("d1"), document.getElementById("d2") ];
    this.d[1].onload =
    this.d[0].onload = function () { 
      this.style.visibility = "visible";
      
      if (!loadedImages[this.index]) {
        var img = new Image();
        img.src = this.src;
        loadedImages[this.index]=img;
      }
      
      fade(1, 100, 100, 4000); 
    
    }
    this.s = 0;
    this.b = 0;
  }
  
  Slideshow.prototype.next = function () {
    if (document.loadbusy) return;
    
    this.b ^= 1;
    
    document.loadbusy = true;
    
    document.alphaTarget = this.d[this.b];
    setAlpha(0);
    this.d[this.b].style.zIndex = 100;
    this.d[this.b^1].style.zIndex = 0;
    this.d[this.b].index = this.s;
    this.d[this.b].src = slides[this.s];
    
    this.s ++;
    if (this.s >= slides.length) this.s = 0;
    
  }
  
  function fade (os, oe, s, d) {
    var t = 0;
    
    if (os > oe) {
      for(var i = os; i >= oe; i-=4) {
        setTimeout("setAlpha("+i+")", (t * s));
        t++;
      }
    } else {
      for(var i = os; i <= oe; i+=4) {
        setTimeout("setAlpha("+i+")", (t * s));
        t++;
      }
    }
    
    setTimeout("setDone()", (t * s)+d);
  }
  
  function setAlpha(v) {
    var st = document.alphaTarget.style;
    st.opacity = (v / 100);
    st.MozOpacity = (v / 100);
    st.KhtmlOpacity = (v / 100);
    st.filter = "alpha(opacity=" + v + ")";
  }
  
  function setDone() { document.loadbusy = false; }