function Slideshow(id, imgs)
{

  this.id = id;
  this.imgs = new Array(imgs.length);
  for (var i = 0; i < imgs.length; i++)
  {
    this.imgs[i] = new Image();
    this.imgs[i].src = imgs[i];
  }

  this.counter = 0;
  this.flipImage = flipImage;
}

function flipImage()
{
  this.counter = (this.counter >= this.imgs.length - 1) ? 0 : (this.counter + 1);
  document[this.id].src = this.imgs[this.counter].src;
}



var gl_anim_slideshows;
var gl_anim_activeIndex = 0;
var gl_anim_timeout = 2000;

function animate()
{
  if (arguments.length) {
    gl_anim_slideshows = arguments;

    setTimeout("animate()", gl_anim_timeout);
  } else {
    gl_anim_activeIndex = (gl_anim_activeIndex >= gl_anim_slideshows.length - 1) ? 0 : (gl_anim_activeIndex + 1);
    gl_anim_slideshows[gl_anim_activeIndex].flipImage();

    setTimeout("animate()", gl_anim_timeout);
  }
}

