function loadImages()
{
  images    = new Array();
  numImages = 8;
  for (frame = 1; frame < numImages+1; frame++)
  {
    images[frame]     = new Image();
    images[frame].src = "ect_slides/slide_0" + frame + ".jpg";
  }
}
// Function: loadText
// Purpose:  Stores textual descriptions for images into an array.
function loadText()
{    
  text      = new Array();
  text[1] = "Millions of people battle depression. Often times, anti-depressant medications are effective. In some cases, however, these medications are ineffective.";
  text[2] = "Electro Convulsive Therapy or ECT is a long established, safe, and effective treatment for the debilitating symptoms of severe depression, bipolar, mania, and some forms of schizophrenia.";
  text[3] = "ECT is thought to cause changes in the brain that decrease symptoms or even cause them to stop.  These changes occur quicker with ECT than with medications.";
  text[4] = "ECT Treatments are given on Monday, Wednesday, and Friday mornings.  Treatments are given in a series, usually 6-12 treatments. There is no limit to the number of treatments a patient may have over a lifetime.";
  text[5] = "In the treatment room, the patient is given an anesthetic medication and a muscle relaxant to help them go to sleep and relax their muscles.  There is an anesthesiologist, psychiatrist, and registered nurse in the treatment room attending to the patient at all times.";
  text[6] = "While the patient is asleep, a small amount of electrical current is used to stimulate a brief seizure within the brain.  The seizure lasts only about 30-60 seconds.  The seizure activity is minimal and is usually only seen in the hands and feet.";
  text[7] = "The patient wakes up in a recovery room and will be monitored until their discharge. "; 
   text[8] = "If you have any questions, please ask your psychiatrist, or contact us at the Pine Rest ECT clinic at 616-281-6341.";
}
// 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 = 'Slide ' + i + ' of 8';        // 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
}
  
