// JScript File

function PhotoAlbum_addImage(imageSrc,imageDesc, image2Desc)
{
    this.imageArray[this.maxIndex] = new Image(); 
    this.imageArray[this.maxIndex].src = imageSrc;
    this.descArray[this.maxIndex] = imageDesc;
    this.desc2Array[this.maxIndex] = image2Desc;
    this.maxIndex++;
}

function PhotoAlbum_displayImage()
{
    document.getElementById(this.imageTag).src = this.imageArray[this.curIndex].src;
    document.getElementById(this.descTag).firstChild.nodeValue = this.descArray[this.curIndex];
    document.getElementById(this.desc2Tag).firstChild.nodeValue = this.desc2Array[this.curIndex];
}

function PhotoAlbum_firstImage()
{
    this.curIndex = 0;
    this.displayImage()
}

function PhotoAlbum_nextImage()
{
    this.curIndex++;
    if( this.curIndex >= this.maxIndex ) 
      this.curIndex = this.minIndex;
    this.displayImage();
}

function PhotoAlbum_prevImage()
{
    this.curIndex--;
    if( this.curIndex < this.minIndex )
      this.curIndex = this.maxIndex - 1;
    this.displayImage();
}

function PhotoAlbum_slideShow()
{
   this.nextImage();

   var thisObj = this;
   if( this.timeout > 0 )
     this.t = setTimeout(function() {thisObj.slideshow()}, this.timeout );
}

function PhotoAlbum(imageID,descID,desc2ID,interval)
{
   this.minIndex = 0;
   this.maxIndex = 0;
   this.curIndex = 0;
   this.imageTag = imageID;
   this.descTag = descID;
   this.desc2Tag = desc2ID;
   this.timeout = interval*1000;
   this.imageArray = new Array();
   this.descArray = new Array();
   this.desc2Array = new Array();
   
   this.addImage = PhotoAlbum_addImage;
   this.displayImage = PhotoAlbum_displayImage;
   this.firstImage = PhotoAlbum_firstImage;
   this.nextImage = PhotoAlbum_nextImage;
   this.prevImage = PhotoAlbum_prevImage;
   this.slideshow = PhotoAlbum_slideShow;
   
   var thisObj = this;
   if( this.timeout > 0 )
     this.t = setTimeout(function() {thisObj.slideshow()}, this.timeout );
}
