
  function slideshow(element, location, number) {
   // element in document that displays the image
   this.element = element;

   // functions for navigation
   this.showNextImage = showNextImage;
   this.showPreviousImage = showPreviousImage;
   this.enlarge = enlarge;

   // index of current image
   this.currentImage = 0;

   // build array pointing to sources of images
   this.imageArray = new Array();
   this.imageBigArray = new Array();
   for ( i = 1; i <= number; i++ ) {
    if ( i <= 9 ) {
     this.imageArray[ i - 1 ] = location + "0" + i + ".png";
     this.imageBigArray[ i - 1 ] = location + "big_0" + i + ".png";
    } else {
     this.imageArray[ i - 1 ] = location + i + ".png";
     this.imageBigArray[ i - 1 ] = location + "big_" + i + ".png";
    }
   }

  }

  function enlarge() {
    window.open( this.imageBigArray[ this.currentImage ], "Image", "" );
  }

  function showPreviousImage() {
   if (0 == this.currentImage)
    return;

   this.currentImage = this.currentImage - 1;
   document[ this.element ].src = this.imageArray[ this.currentImage ];

   updateIndex( this.currentImage + 1, this.imageArray.length );
  }
 
  function showNextImage() {
   if ( this.imageArray.length - 1 == this.currentImage )
    return;

   this.currentImage = this.currentImage + 1;
   document[ this.element ].src = this.imageArray[ this.currentImage ];

   updateIndex( this.currentImage + 1, this.imageArray.length );
  }

  function updateIndex(index, total) {
   var result = index + " of " + total;
   if ( document.getElementById ) {
    document.getElementById( "slideshow_index" ).innerHTML = result;
   }
   return result;
  }
