// Acher.Mao 2006-4-4 Created
// 使用例子:注意：Script部分的调用必须放在后面
/*
<a href='javascript:ss.goUrl()'><img style="FILTER: revealTrans(duration=1, transition=5)" 
	src="" width="170" height="120" border="1" id=imgBox0 name=imgBox0>
</a>
<SCRIPT>
ss = new slideshow("ss", "imgBox0");
ss.add_slide("Img241135485.jpg", "图片注释");
ss.add_slide("小熊.GIF", "");
ss.next();
</SCRIPT>
*/

function slideshow(slideshowname, imagename) {
  // Name of this object
  // (required if you want your slideshow to auto-play)
  // For example, "SLIDES1"
  this.name = slideshowname;

  // IMAGE element on your HTML page.
  // For example, document.images.SLIDES1IMG
  this.image = document.getElementById(imagename);

  this.interval = 3000;

  // These are private variables
  this.slides = new Array();
  this.memos = new Array();
  this.current = 0;

  //--------------------------------------------------
  // Public methods
  //--------------------------------------------------
  this.add_slide = function(slide, memo) {
    var i = this.slides.length;
    this.slides[i] = slide;
    this.memos[i] = memo;
  }

  //--------------------------------------------------
  this.next = function() {
    // This method advances to the next slide.
    // Increment the image number
    if (this.current < this.slides.length - 1) {
      this.current++;
    } else {
      this.current = 0;
    }

    this.image.filters.revealTrans.Transition=Math.floor(Math.random() * 23);
    this.image.filters.revealTrans.apply();
    this.image.filters.revealTrans.play();
	this.image.src = this.slides[this.current];
	this.image.alt = this.memos[this.current];
	theTimer=setTimeout(this.name + ".next()", this.interval);
  }

  this.goUrl = function(){
	window.open(this.slides[this.current], '_blank');
  }

  //--------------------------------------------------
  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;
    }
  }
}
