/***********************************************
** File:      %M%  version %I%
** Author:    nat
** Modified:  %G%
** Copyright: I-Next Ltd
***********************************************/
/* ident %W% */

function initRollovers() {
  if ( document.images ){
    var preLoad = new Array();
    var tempSrc;
    for (var i = 0; i < document.images.length; i ++ ){

      // Only add rollover to images with the classname 'rollover'
      if ( document.images[i].className == 'rollover' ){
        var src = document.images[i].getAttribute('src'); // get the src
        var ext = src.substring( src.lastIndexOf('.'), src.length ); // get the file extension
        var hsrc = src.replace( ext, '_r' + ext ); // store the rollover src
        document.images[i].setAttribute('hsrc', hsrc); // set the new src attribute
        document.images[i].style.cursor = 'hand'; // Hand cursor where supported

        // Preload the image
        preLoad[i] = new Image();
        preLoad[i].src = hsrc;

        // Add the rollover functions
        document.images[i].onmouseover = function(){
          tempSrc = this.getAttribute('src');
          this.setAttribute('src', this.getAttribute('hsrc'));
        }
        document.images[i].onmouseout = function(){
          if (!tempSrc) tempSrc = this.getAttribute('src').replace('_r'+ftype, ftype);
          this.setAttribute('src', tempSrc);
        }
      }
    }
  }
}
window.onload = initRollovers;
