// -----------------------------------------------------------------------------
// Generic RollOver
//
// Copyright (C) 2000 Jacob Hage - [jacob@hage.dk]
// Distributed under the terms of the GNU Library General Public License
// -----------------------------------------------------------------------------
// --------------------------------------------------------
// Called in the "init" function onLoad. n = name, s = status, d = layer (leave blank)
// --------------------------------------------------------
function createRollOver(n,s,d) {
// --- Find image object ---
 var p;
 var i;
 var x;
 if(!d) d=document;
 if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document;
  n=n.substring(0,p);
 }
 if(!(x=d[n])&&d.all) x=d.all[n];
 for(i=0;!x&&i<d.images.length;i++){
  x=d.images[i][n];
 }
 for(i=0;!x&&d.layers&&i<d.layers.length;i++){
  createRollOver(n,s,d.layers[i].document);
 }
// --- Find file name and extension ---
 imgName = (x.src.slice(0,x.src.lastIndexOf("_")+1)); // Setting the filename without extension
 imgExt  = (x.src.slice(x.src.lastIndexOf("."),x.src.length)); // setting extension
 
// --- Call the rollover object ---
 eval("R_"+n+" = new rollOver(x,imgName,imgExt,s)");
}
// --------------------------------------------------------
// Generate the rollover object
// --------------------------------------------------------
function rollOver(img,imgName,imgExt,status){
 this.file  = img;
 this.normal  = new Image();
 this.normal.src = imgName+'normal'+imgExt;
 this.over  = new Image();
 this.over.src  = imgName+'over'+imgExt;
 this.click  = new Image();
 this.click.src = imgName+'click'+imgExt;
 this.text  = status;
}
// --------------------------------------------------------
// Function called onMouseOver, onMouseOut, onClick 
// --------------------------------------------------------
function swap(obj,action){ 
 if (document.images && clicked != eval("R_"+obj)) {
  if(clicked != eval("R_"+obj)){
   eval("R_"+obj+".file.src = R_"+obj+"."+action+".src");
  }
// --- Test for any button being clicked
  if(action=="click"){
// --- Setting the previous clicked's source to normal state
   if(clicked)clicked.file.src = clicked.normal.src;
// --- Setting the current clicked image
   clicked = eval("R_"+obj);
// --- Setting the status bar if any
  } else if(action=="over" && eval("R_"+obj+".text")){
   window.status = eval("R_"+obj+".text");
  } else {
   window.status = "";
  }
 }
}
// --- Holds the object of the currently clicked image. Empty by default.
var clicked = null;
