/*
 * Purpose: Swaps out the images on mouseOver.
 
 * Notes:The way the image are named will make a difference. 
 * When the mouse is over an image with name arribute=x, 
 * the default source for that image is x. When themouse 
 * moves over that image, it will rename the source to
 * x_h.png and change the splash image to splash_x.jpg
 *
 * Parameters:
 * --e:    the event
 * --mode: mouseIn or mouseOut. True for mouseIn.
 */
function hover(e,mode){
  var targ;
  var srcname;
  var splashName;
  
  if (!e){
    var e=window.event; 
  }
  if (e.target){
    targ=e.target;
  }
  else if (e.srcElement){
    targ=e.srcElement;
  }
  if (targ.nodeType==3){ // defeat Safari bug
    targ = targ.parentNode;
  }
  
  srcname=targ.name;
  if(srcname=="" || targ.tagName.toUpperCase()!="IMG"){  // more safari bugs :(
    return;
  }
  
  
  if(mode){
    splashName="images/splash_"+srcname+".jpg";
    srcname="images/"+srcname+"_h.jpg";
   
  }
  else{
    splashName="images/splash_main.jpg";
    srcname="images/"+srcname+".jpg";
  }
  targ.src=srcname;
  document.getElementById("splash").src=splashName;
}

/* Purpose: Remove the overlay images from the document
 * Notes: When the page loads, the broswer doesn't know what the 
 * overlay images will be. When the mouse over events occur, the
 * user will have to wait for the new images to be loaded. This
 * creates a poor experience.
 *
 * The way around this is to load the overlay images in hidden 
 * sections of the page. Though the images are not visible, they
 * do affect the layout, etc. This function will remove the overlays
 * from the document.
 *
 * Removing the images from the document forces the browser to dl
 * them. Effectively caching the overlays to provide instant 
 * experience w/o any waiting.
 *
 * Depending on where you've placed the hidden images, when the page 
 * loads, there can be a glitch as everything pops into place.
 * Remember to place the images in their own section below the main
 * content. This will avoid that glitch.
 */
function removeOverlays(){
  var elm;

  while( (elm=document.getElementById("overlay")) !=null){
    elm.parentNode.removeChild(elm);
  }

}
