function slideshow( slideshowname ) {
  this.name = slideshowname;
  this.repeat = true;

  // Number of images to pre-fetch.
  // -1 = preload all images.
  //  0 = load each image is it is used.
  //  n = pre-fetch n images ahead of the current image.
  // I recommend preloading all images unless you have large
  // images, or a large amount of images.
  this.prefetch = -1;
  this.image; // IMAGE element on your HTML page. For example, document.images.SLIDES1IMG

  this.textid;
  this.text_title_id;
  this.slide_image_id;

  // Milliseconds to pause between slides.
  // Individual slides can override this.
  this.timeout = 3000;

  // Hook functions to be called before and after updating the slide
  // this.pre_update_hook = function() { }
  // this.post_update_hook = function() { }

  // These are private variables
  this.slides = new Array();
  this.current = 0;
  this.timeoutid = 0;

  //--------------------------------------------------
  // Public methods
  //--------------------------------------------------
  this.add_slide = function(slide) {
    var i = this.slides.length;
    if (this.prefetch == -1) {
      slide.load();
    }
    this.slides[i] = slide;
  }

  //--------------------------------------------------
  this.pause = function() {
    if (this.timeoutid != 0) {
      clearTimeout(this.timeoutid);
      this.timeoutid = 0;
    }
	return(false);
  }

  //--------------------------------------------------
  this.play = function(timeout) {
	 // alert('playing...');
	 // alert(this.slides.length);
    this.pause();
  
    if (timeout) {
      this.timeout = timeout;
    }
  
    timeout = this.timeout;
/*	
	// If the current slide has a custom timeout, use it; otherwise use the default timeout
    if (typeof this.slides[ this.current ].timeout != 'undefined' && this.slides[ this.current ].timeout) {
      timeout = this.slides[ this.current ].timeout;
    } else {
      timeout = this.timeout;
    }
*/	
	//alert(timeout);

    // After the timeout, call this.loop()
    this.timeoutid = setTimeout( this.name + ".loop()", timeout);
	return(false);
  }


 this.continue_play = function continue_play()
	{
		this.next();
		this.play();
		return(false);
	}


  //--------------------------------------------------
  this.update = function() {
    // Make sure the slideshow has been initialized correctly
   // if (! this.valid_image()) { return(false); }
  
    // Convenience variable for the current slide
    var slide = this.slides[ this.current ];

    // Load the slide image if necessary
    slide.load();
  
  // do filter removed here.

    // Update the image.
   // this.image.src = slide.image.src;

    // Update the text
   // this.display_text();
	//r.innerHTML = text;
	//alert(this.textid);
	//alert(document.getElementById(this.textid));
	document.getElementById(this.textid).innerHTML = slide.text;
	document.getElementById(this.text_title_id).innerHTML = slide.text_title;
	document.getElementById(this.slide_image_id).src = slide.src;

/*    // Call the post-update hook function if one was specified
    if (typeof this.post_update_hook == 'function') {
      this.post_update_hook();
    }
*/
    // Do we need to pre-fetch images?
    if (this.prefetch > 0) {

      var next, prev, count;

      // Pre-fetch the next slide image(s)
      next = this.current;
      prev = this.current;
      count = 0;
      do {

        // Get the next and previous slide number
        // Loop past the ends of the slideshow if necessary
        if (++next >= this.slides.length) next = 0;
        if (--prev < 0) prev = this.slides.length - 1;

        // Preload the slide image
        this.slides[next].load();
        this.slides[prev].load();

        // Keep going until we have fetched
        // the designated number of slides

      } while (++count < this.prefetch);
    }
  }


//--------------------------------------------------
  this.next = function() {
    // Increment the image number
    if (this.current < this.slides.length - 1) {
      this.current++;
    } else if (this.repeat) {
      this.current = 0;
    }

    this.update();
  }


  //--------------------------------------------------
  this.previous = function() {
    // This method goes to the previous slide.
  
    // Decrement the image number
    if (this.current > 0) {
      this.current--;
    } else if (this.repeat) {
      this.current = this.slides.length - 1;
    }
  
    this.update();
  }


  //--------------------------------------------------
  this.display_text = function() {
    // Display the text for the current slide
  
    text = this.slides[ this.current ].text;
  
    // If a text id has been specified, then change the contents of the HTML element
    if (this.textid) {

      r = this.getElementById(this.textid);
      if (!r) { return false; }
      if (typeof r.innerHTML == 'undefined') { return false; }

      // Update the text
      r.innerHTML = text;
    }
	//alert(text);
  }


  //--------------------------------------------------
  this.hotlink = function() {
    // This method calls the hotlink() method for the current slide.
  
    this.slides[ this.current ].hotlink();
  }


  //==================================================
  // Private methods
  //==================================================

  //--------------------------------------------------
  this.loop = function() {
    // internal / JavaScript timeout.

	// Make sure the next slide image has finished loading
    if (this.current < this.slides.length - 1) {
      next_slide = this.slides[this.current + 1];
      if (next_slide.image.complete == null || next_slide.image.complete) {
        this.next();
      }
    } else { // we're at the last slide
      this.next();
    }
    
    // Keep playing the slideshow
    this.play( );
  }


  //--------------------------------------------------
  this.valid_image = function() {
    // Returns 1 if a valid image has been set for the slideshow
	return((this.image)?true:false);
  }

  //--------------------------------------------------
  this.getElementById = function(element_id) {
    // This method returns the element corresponding to the id

    if (document.getElementById) {
      return document.getElementById(element_id);
    }
    else if (document.all) {
      return document.all[element_id];
    }
    else if (document.layers) {
      return document.layers[element_id];
    } else {
      return undefined;
    }
  }
  
}
