// Function: loadImages
// Purpose:  Reads in images (named 1.jpg through i.jpg) into an array.

function loadImages()
{
  images    = new Array();
  numImages = 13;
  for (frame = 1; frame < numImages+1; frame++)
  {
    images[frame]     = new Image();
    images[frame].src = "indoor/" + frame + ".jpg";
  }
}

// Function: loadText
// Purpose:  Stores textual descriptions for images into an array.

function loadText()
{    
  text      = new Array();
  text[1] = "Hi, I'm Buddha, Beve's dog.  Come on in and I'll show you her house.";
  text[2] = "After you come in the front door turn right into the kitchen - but first stop to give me a treat!";
  text[3] = "Facing the next room and looking right there is a couch, desk, and Uncle Tom's art (this painting is called Six Pack).";
  text[4] = "To the left is a wood burning stove and Uncle Tom\'s \"The Other Helga\" painting.  Thru the sliding glass doors is the deck to the yard, we'll go there later.  Thru the door on the left is the dining room.";
  text[5] = 'The dining room.  Like the last room, there are lots of windows here too.';
  text[6] = 'To the left of the dining room is the living room with a fireplace.';
  text[7] = "As we leave the living room make sure to rub up on the new couch.  We're now back at the front door but this time we will turn towards the bedrooms rather than the kitchen.";
  text[8] = "Turning right down the hallway leads to Beve's bedroom.";
  text[9] = "This is where I sleep.  I can look out the sliding glass doors at my yard and hot tub or I can look up at Uncle Tom's painting.";
  text[10] = "The bedroom has a bathroom with a unique feature - 2 doorways, but only one door!  You can close the door to the bedroom or close the door to the toilet, but not both!";
  text[11] = 'Going back down the hallway and to the right is where Beve has been spending a lot of time lately.';
  text[12] = "I don't mind if she spends a lot of time with her new toy, I still get lots of hugs.";
  text[13] = "Also in this hallway is the guest room and bathroom.  This is the guest room.  All the bedroom closets in the house have mirror doors.  With all the mirrors and windows, everything is so open!  This is the end of the indoor tour, click GO OUTSIDE below for the outdoor tour.";
}

// 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
}
