// cache.js

/*
 * Cache the rollover images.  This only works for png images.
 *
 * To use. create an array (imageNames) that contains the names of the base images
 * to load (not rollover or clicked versions), without the extension.
 * Call cacheImages with the pathToRoot variable from the servlet context and
 * that array.  For example:
 *
 * imageNames = new Array("About_It.png", "Examples.png");
 * cacheImages(pathToRoot, imageNames);
 */
function cacheImages(imageNames) {
  var imageObjects = new Array(3*imageNames.length);

  for(var i=0; i<imageNames.length; i++) {
    imageObjects[3*i] = new Image();
    imageObjects[3*i+1] = new Image();
    imageObjects[3*i+2] = new Image();
    imageObjects[3*i].src = imageNames[i] + ".png";
    imageObjects[3*i+1].src = imageNames[i] + "-rollover.png";
    imageObjects[3*i+2].src = imageNames[i] + "-clicked.png";
  }
}
