function slideshow( slideshowname, image )
{
  this.name = slideshowname
  this.image = image
  this.timeout = 3000

  this.images = new Array()
  this.links = new Array()
  this.current = 0
  this.timeoutid = 0

  this.add_slide = slideshow_add_slide
  this.set_image = slideshow_set_image

  this.play = slideshow_play
  this.pause = slideshow_pause

  this.next = slideshow_next
  this.previous = slideshow_previous

  this.loop = slideshow_loop
  this.valid_image = slideshow_valid_image
}

function slideshow_add_slide(image_url)
{
  if (!document.images)
    return

  var i = this.images.length;

  this.images[i] = new Image()
  this.images[i].src = image_url
}

function slideshow_set_image( imageobject ) {
  if (!document.images)
    return

  this.image = imageobject
}

function slideshow_valid_image() {
	if (!this.image) {
		this.pause
    	window.status = "Error: slideshow image not initialized for " + this.name
	    return 0
	}  else
		return 1
	}

function slideshow_next( ) {
	if (! this.valid_image()) return;
	if (this.current < this.images.length - 1)
		this.current++
	else
		this.current = 0

	if(document.all){
		this.image.filters.blendTrans.apply()
	}
	this.image.src = this.images[ this.current ].src
	if (document.all) {
		this.image.filters.blendTrans.play()
	}
}

function slideshow_previous( ) {
	if (! this.valid_image()) return;
	if (this.current > 0)
		this.current--
	else
		this.current = this.images.length - 1
		this.image.src = this.images[ this.current ].src
}

function slideshow_loop( ) {
	this.next( )
	this.play( )
}

function slideshow_play( ) {
	this.timeoutid = setTimeout( this.name + ".loop()", this.timeout)
}

function slideshow_pause( ) {
	if (this.timeoutid != 0) {
		clearTimeout(this.timeoutid)
		this.timeoutid = 0
	}
}
