// Function used to swap images from the given array of images and timeout
var slides = new Array();
var slideLinks = new Array();
var currentSlide = -1;
function Slideshow( target, timeout )
{
  if(typeof timeout == 'undefined') timeout = 3000;
  var scount = slides.length;
  if(document.images)
  {
    var nextSlide = currentSlide + 1;
    if(nextSlide >= scount) nextSlide = 0;
    if(slides[nextSlide] && slides[nextSlide].complete)
    {
      var etarget = ElementById(target);
      // make sure target is valid. It might not be valid  if the page has not finished loading
      if(etarget)
      {
        etarget.src = slides[nextSlide].src;
        currentSlide = nextSlide;
      }
      setTimeout('Slideshow(\''+ target +'\','+ timeout +')', timeout);

    }
    else
    {
      setTimeout('Slideshow(\''+ target +'\','+ timeout +')', timeout);
    }
  }
}

// This function should be used to supply an onclick function to the slideshow
function SlideshowClicked()
{
  if(currentSlide >= 0 && currentSlide < slideLinks.length && typeof slideLinks[currentSlide] != 'undefined')
    window.location = slideLinks[currentSlide];
}
