

   // Program: SlideShow.js
   // By:      Duane Gran at Ball University
   // Purpose: The user can pan through a series of images with textual
   //          descriptions for each image.

   // Function: loadImages
   // Purpose:  Reads in images (named 1.jpg through i.jpg) into an array.

   function loadImages()
   {
     images    = new Array();
     numImages = 4;
     for (frame = 1; frame < numImages+1; frame++)
     {
       images[frame]     = new Image();
       images[frame].src = "./javascripts/hagar_images/" + frame + ".jpg";
     }
   }

   // Function: loadText
   // Purpose:  Stores textual descriptions for images into an array.

   function loadText()
   {    
     text      = new Array();
     text[1] = "Maquette seen in mirror";
     text[2] = "Scholars' dating: 1648";
     text[3] = "Scholars' dating: 1656";
     text[4] = "Scholars' dating: 1642";
     
     	 
   }

   // Function: displayImage
   // Purpose:  First sets the textual description and the image counter,
   //           then sets the source of the <IMG> tag with the name of
   //           slideShow.

   function displayImage()
   {
     document.textForm.ta.value = text[i];         // text description
     document.numForm.imageCount.value = i;        // image number
     document.slideshow.src=images[i].src;          // display image 
   }

   // Function: next
   // Purpose:  Handles a request to view the next image.  If the next image
   //           doesn't exist, it wraps around to the beginning of the array.

   function next()
   {
     i++;                                          // increment
     if (i == numImages+1)
       i = 1;                                      // restart at first image
     displayImage();                               // display the image
   }

   // Function: previous
   // Purpose:  Same as next() but it wraps backward.

   function previous()
   {
     i--;                                          // decrement
     if (i == 0)
       i = images.length-1;                        // restart at last image
     displayImage();                               // display the image
   }

   // Function: jump
   // Purpose:  Based on number entered by user, jump to that image.

   function jump()
   {
     i = document.numForm.imageCount.value;        // set image index
     if (i > numImages)                            // if out of range
       window.alert("There are only " + numImages + " images available.");
     else
       displayImage();                             // display the image
   }
