var slideshow = new Object();

slideshow.imgs = Array();
slideshow.current = 0;
slideshow.img0 = false;
slideshow.img1 = false;

slideshow.fadeout = function()
{
  var opacity = slideshow.img1.style.opacity;
  opacity = opacity - 0.04;
  
  slideshow.img1.style.opacity = opacity;
  slideshow.img1.style.filter = 'alpha(opacity=' + opacity*100 + ')';
  if (opacity > 0)
  {
    setTimeout("slideshow.fadeout()", 40);
  } else
  {
    slideshow.switchover();
  }
}

slideshow.switchover = function()
{
    this.img1.src = this.img0.src;
    this.img1.style.opacity = 1;
    this.img1.style.filter = "alpha(opacity=100)";
    var nextimage = this.imgs[this.current];
    this.current = (this.imgs[this.current + 1]) ? (this.current += 1) : 0;
    this.img0.src = nextimage;
    // setTimeout("slideshow.switchover2()", 500);
    setTimeout("slideshow.fadeout()", 4000);
}  

slideshow.switchover2 = function()
{
}


slideshow.addimage = function(img)
{
  slideshow.imgs.push(img);
}

slideshow.start = function(img0, img1)
{
  this.img0 = document.getElementById(img0);
  this.img1 = document.getElementById(img1);
  if (!this.img0 && !this.img1) 
  {
   return; 
  }
  
  if(!this.img1)
  {
    return;
  }
  
  this.img0.style.opacity = 1;
  this.img1.style.opacity = 1;
  this.current = 0;
  setTimeout("slideshow.fadeout()", 3000);
}


