
// Bill Weinman's Common JavaScript Rollover Engine
// As described in "Creative HTML Design", by Lynda and Bill Weinman
// (c) 1997 Bill Weinman
// 
// You are free to use this script, and modify it to 
// your heart's content. You must leave this entire header
// --including this notice--intact, and make sure there 
// is a reference to our web site: <http://www.htmlbook.com/>. 

function var_init(path) {

   // names of images
   imagenames = new Array(
     "home_b", "books_b", "medieval_b", "pavilions_b", "mac_b", "links_b",
     "home_g", "books_g", "medieval_g", "pavilions_g", "mac_g", "links_g"
    );

   // suffixes for mouseover and mouseout
   suffixes = new Array( "_on", "_off" );

   // filename extension (".gif", ".jpg", or ".png")
   ext = ".gif";
} 

function roll_init(path) {
   // get the variables
   var_init(path);  // this calls the function from the web page

   // find out what browser this is
   // this will work in "Mozilla" 3+ (includes MSIE 4)

   if(navigator.appName.indexOf("Netscape") != -1) {
      if( (navigator.appVersion.indexOf("3.") != -1) || 
          (navigator.appVersion.indexOf("4.") != -1) ||
          (navigator.appVersion.indexOf("5.") != -1) ) {
        okay = true;
      }
    }
   if(navigator.appVersion.indexOf("MSIE") != -1) {
      if( (navigator.appVersion.indexOf("4.") != -1) ||
          (navigator.appVersion.indexOf("5.") != -1) ) {
        okay = true;
     }
   }

   // these are from the web page too. 
   son  = suffixes[0];  
   soff = suffixes[1];


   // this uses eval to create variables 
   // ... and to pre-load the images. 
   for (var i = 0; i < imagenames.length; i++) {
      var name = imagenames[i];
      var ion  = "r" + name + "on";
      var ioff = "r" + name + "off";
      eval(ion  + " = new Image()");
      eval(ion  + ".src = '" + path + name + son  + ext + "'");
      eval(ioff + " = new Image()");
      eval(ioff + ".src = '" + path + name + soff + ext + "'");
    }
}

// the onMouseOver entry point
function over(imgname) {
   if (!okay) return true; // just leave unless okay

   // swap in the "on" image
  eval("document." + imgname + ".src = r" + imgname + "on.src");
  return true;
}

// the onMouseOut entry point
function out(imgname)
{
if (!okay) return true; // just leave unless okay

   // swap in the "off" image
   eval("document." + imgname + ".src = r" + imgname + "off.src");
   return true;
}


