<!--
/* Constructor of class ImageManager: initialize member variables */
function ImageManager()
{
  ImageManager.prototype.allImages = new Array();  // contains the relative paths to the images
  ImageManager.prototype.currentIndex = -1;
  ImageManager.prototype.maxElementsPerRow = 6;
}

var imageManager = new ImageManager();

ImageManager.prototype.switchToNextImage = function()
{
  if ( this.currentIndex < this.allImages.length - 1 ) {
    this.switchToImage( this.currentIndex + 1 );
  }
}
ImageManager.prototype.switchToPreviousImage = function()
{
  if ( this.currentIndex > 0 ) {
    this.switchToImage( this.currentIndex - 1 );
  }
}

ImageManager.prototype.switchToImage = function( indexToUse )
{
    if ( indexToUse >= 0 && indexToUse < this.allImages.length ) {
	lastHighlighted = this.currentIndex+1;
	this.currentIndex = indexToUse;
	var bigImage = document.getElementById('big_changing_image');
	if ( bigImage != null ) {
	    bigImage.src = this.allImages[indexToUse];
	}

	theNumber = indexToUse+1;
	bulletName = "smallBullet" + theNumber;
	var bulletImage = document.getElementById(bulletName);
	var theSource = bulletImage.src;
	if ( theSource.search( /_high.png$/ ) == -1 ) {
	    // highlight currently selected small bullet
	    theSource = theSource.replace( /.png$/, "_high.png" );
	    bulletImage.src = theSource;

	    // unhighlight last highlighted small bullet
	    bulletName = "smallBullet" + lastHighlighted;
	    bulletImage = document.getElementById(bulletName);
	    theSource = bulletImage.src;
	    theSource = theSource.replace( /_high.png$/, ".png" );
	    bulletImage.src = theSource;
	}

    }
}


/* Initialize with all images to be switched between.
   Arguments:
      the directory containing the images
      the number of the highest index to be used
 */
ImageManager.prototype.init = function( baseDirectory, maxIndex )
{
  for ( var i=0; i<maxIndex; i++ ) {
    number = i+1;
    numberString = i>=9 ? number : "0" + number;
    //alert( baseDirectory + "/" + numberString + ".jpg" );
    this.allImages[i] = baseDirectory + "/" + numberString + ".jpg";
  }
  if( this.allImages.length > 0 ) {
    this.switchToImage( 0 );
  }
}

//-->

