/** Script to flip picture source. */

// Base directory of the images album.
var PICTURE_DIR = "images/mainNavigation/";

// The img html element containing the top image.
var VIOLIN_TOP_IMG;

// The img html element contanining the bottom image.
var VIOLIN_BOTTOM_IMG;

// An array containing the top and bottom image names for the various 
// navigation links.
var IMAGE_MAP_ARRAY; 

/**
 * Constructor to create a map of image names.
 */
function navigationMap(top,bottom)
{
  this.top = top;
  this.bottom = bottom;
}

/**
 * Initialize the main page.  Load the necessary images,
 * set the global variables.
 */
function initImageMaps()
{
  if (document.getElementById)
  {
    VIOLIN_TOP_IMG = document.getElementById("defaultTop");
    VIOLIN_BOTTOM_IMG = document.getElementById("defaultBottom");
  }
  else
  {
    VIOLIN_TOP_IMG = document.defaultTop;
    VIOLIN_BOTTOM_IMG = document.defaultBottom;
  }


  // Initialize the image map array.
  IMAGE_MAP_ARRAY = new Array();
  IMAGE_MAP_ARRAY["default"] = new navigationMap("defaultTop.gif","defaultBottom.gif");
  IMAGE_MAP_ARRAY["generalInformation"] = new navigationMap("generalInfoTop.gif","generalInfoBottom.gif");
  IMAGE_MAP_ARRAY["faculty"] = new navigationMap("facultyTop.gif","facultyBottom.gif");
  IMAGE_MAP_ARRAY["facility"] = new navigationMap("facilityTop.gif","facilityBottom.gif");
  IMAGE_MAP_ARRAY["pictureAlbum"] = new navigationMap("pictureAlbumTop.gif","pictureAlbumBottom.gif");
  IMAGE_MAP_ARRAY["requestInformation"] = new navigationMap("requestInformationTop.gif","requestInformationBottom.gif");
  IMAGE_MAP_ARRAY["qualifications"] = new navigationMap("qualificationsTop.gif","qualificationsBottom.gif");
  IMAGE_MAP_ARRAY["recreationalInformation"] = new navigationMap("recreationTop.gif","recreationBottom.gif");
  IMAGE_MAP_ARRAY["sampleSchedule"] = new navigationMap("sampleScheduleTop.gif","sampleScheduleBottom.gif");
  IMAGE_MAP_ARRAY["applicationInformation"] = new navigationMap("applicationInformationTop.gif","applicationInformationBottom.gif");
  IMAGE_MAP_ARRAY["registeredStudents"] = new navigationMap("registeredStudentsTop.gif","registeredStudentsBottom.gif");
}

/**
 * Replace the picture of the violin top and violin bottom
 * found on the main page with the following two image titles.
 */
function flipImage(mapName)
{
  var map = IMAGE_MAP_ARRAY[mapName];

  // Get the image directory.
  var imageTop = PICTURE_DIR + map.top;
  var imageBottom = PICTURE_DIR + map.bottom;

  VIOLIN_TOP_IMG.src=imageTop;
  VIOLIN_BOTTOM_IMG.src=imageBottom;
}

