function loadImages()
{
  images    = new Array();
  numImages = 12;
  for (frame = 1; frame < numImages+1; frame++)
  {
    images[frame]     = new Image();
    images[frame].src = "images/" + frame + ".jpg";
  }
}
// Function: loadText
// Purpose:  Stores textual descriptions for images into an array.
function loadText()
{    
  text      = new Array();
  text[1] = "Penguins are one of the most well-known animals in the world. They are members of the bird family. They are birds because they lay eggs, they have feathers, and they are warm-blooded animals. Most birds fly but penguins can not fly. They have flippers that help them swim instead of wings for flying. ";
  text[2] = "Penguins are found in many different habitats, or places. They live from the frozen land of Antarctica to the sandy beaches of Africa. They live from the rocky coasts of South America to the coasts of New Zealand. Penguins have adapted to more habitats and climates than any other animal in the world. ";
  text[3] = "Penguins have long, flat flippers that help them swim and dive for fish, squid, and krill. They have very short legs that are set far back on their lower body. They stand upright and waddle when they walk.";
  text[4] = "Penguins are covered with waterproof feathers. The feathers are stiff, short and grow close together. These feathers grow over a thick coat of fluffy down. Penguins have a thick layer of blubber, or fat right under their skin. This blubber keeps them warm or insulated from the cold snow and icy waters they swim in. ";
  text[5] = "All penguins have about the same colors. They have a black back and a white belly. This is called protective coloration or camouflage. When a penguin floats on its belly in the water their enemies, such as a leopard seal or the killer whale can not see the penguin. This is because when the predator looks up through the water it can not see the penguin because the light shining through the water makes everything look white. This is also true for the black head and back. As the penguin floats in the water, its black coloring is hard to see in the water because the water also looks black. The black coloring on the back and head also helps the penguin soak in the warmth from the sun.";
  text[6] = "Penguins are amazing swimmers. When penguins float they use their flippers to paddle through the water. When they dive and swim they use their flippers to fly through the water. They use their flippers for swimming like other birds use their wings for flying. Most penguins can dive very deep and can hold their breath for many minutes. They have large round eyes that help them to see in the dark water. Penguins can swim up to hundreds of miles in search of food.";
  text[7] = "Penguins move over land by walking, jumping and sliding. Penguins that live on the ice can slide or go tobogganing on their bellies down hills and slopes. They lay down and push off with their flippers and slide across the ice. Penguins are also good jumpers. They can jump the height and width of their own bodies. They often hop or jump over rocks or holes."; 
   text[8] = "Like all birds, penguins lay eggs and they each have their own mating habits. Penguins form a bond between a male and female. This is done through different actions from the males. The male will flap his flippers, puff out his breast feathers, arch his neck, and make loud braying sounds to show off for the females. Once a pair have bonded they will mate. Soon after one or two eggs are laid. The eggs are cared for by both parents in some type of nest made out of rocks, pebbles, sticks, anything they can find. The Emperor penguin rolls the egg onto the top of the male's feet. It takes from 30 to 60 days for the eggs to hatch, depending on which kind of penguin it is. After the chick has been raised, the male and female break up. But often they will return to the same breeding ground and mate year after year.";
    text[9] = "Penguin chicks are covered with a thick layer of warm fuzzy, brown feathers called down. This down keeps them very warm. The male and female both care for the chicks by bringing back food to them in their stomachs. They force food up out of their stomachs and place it in the chicks' mouth. Eventhough two eggs are hatched, often only one chick will survive. Once the chicks are 2 to 3 weeks old, they will gather together in groups called a creche. The chicks will stay together in groups for warmth and safety while the parents go to the open sea to hunt for food. When the parents return they will call to their chicks. The chicks recognize its parents' sound and will go to them.";
   text[10] = "Penguins have several animals that hunt them for food. These animals are called predators. These include the large sea birds like the skuas, gulls, sheathbills, and petrels. These large birds will steal eggs and chicks that are not guarded. Penguins are also in danger when they are in the water. They are often attacked by sea leopards, killer whales, fur seals, seal lions, and sharks. The leopard seal is the greatest threat. It hides and waits in the water just under the ice and catches the penguins when they jump in to hunt for food. The penguins are an important part of the food chain in their habitat.";
   text[11] = "One hundred years ago millions of penguins were killed for the oil in their bodies. This oil was used for lamp fuel and for paint. Today penguins are not hunted and their habitats have been developed into Wildlife Preserves. Eventhough penguins were humted in the past most kinds of penguins are very numerous. Some colonies have one million mating pairs. One threat to the penguins is pollution from oil spills into the feeding waters off Africa and South America. Also global warming is causing damage to the ozone layer over the Antarctica. This is decreasing the amount of food for them in the ocean. A decrease in their food supply could cause a decrease in the number of penguins.";
    text[12] = "Penguins are one of the easiest birds to recognize. They are one of the most loved animals in the world. These interesting animals were first seen by the white explorers when Magellan sailed around the rocky coasts of South America in 1519. The sailors thought these strange new birds looked like the Great Auk of Greenland and Iceland. The Great Auk, which is now extinct, was a large black and white bird that did not fly. The spanish word for Great Auk is pinguis taken from the Latin word penguigo, which means fat. The early Spanish explorers where the first to see the penguin and they gave it its name.";
}
// 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
}
  

