/* rollover.js - Simple JavaScript rollover system with image caching

   Copyright 2005 Building Insight Technologies Inc.

   For this system to work, rollover image pairs must use the
   following naming convention:

   normal image:    path/foo.gif
   rollover image:  path/foo_over.gif

   Implement rollovers for any <img> tag like so:

   <img src="/img/foo.gif" onload="rollover(this)" />
*/

var rollover_cache = new Array();

function do_roll()
{
  this.src = this.src.slice( 0, -4 )+"_over.gif";

  return true;
}

function do_unroll()
{
  this.src = this.src.slice( 0, -9 )+".gif";

  return true;
}

function rollover( tag )
{
  var i = rollover_cache.length;

  rollover_cache[i] = new Image();
  rollover_cache[i].src = tag.src.slice( 0, -4 )+"_over.gif";

  tag.onmouseover=do_roll;
  tag.onmouseout=do_unroll;
  tag.onload=null;  // avoid calling rollover() again on mouseover/mouseout

  return true;
}

