/* (c) eKnowlogie 2003.  All rights reserved. 

   This Javascript package is used to replace mouse-sensitive images 
   ("buttons") in response to mouse operations.  Multiple groups of 
   images ("menus") can be collected to operate in relatioship to 
   each other and independent of other mouse-sensitive image groups in 
   the same page.  This way, for example, when a button is clicked and 
   its "selected" image displayed, the "normal" image will also be 
   displayed for the previously selected menu.  Other alternative group 
   behaviors can also be implemented. 

   Currently, each button "MyButton" is required to have three images, 
   the "normal" image which is displayed by default, the "mouse-over" image 
   displayed when the mouse is moved over the button, and the "selected" 
   image displayed when the button becomes selected.  These three images 
   mus reside in the same directory, with the same suffix type (e.g. 
   ".jpg" and with names "MyButton", "MyButtonMouseOver" and "MyButtonSelected" 
   respectively. 

   To use this package, create a new menu, register all buttons for that 
   menu, assign the same button name in the "id" attribute of the "img" tag, 
   and invoke the provided event operations in the attributes "onmouseover", 
   "onmouseout", and "onclick" in the "img" tag.
*/


   function newMenu (imageFilePath, imageFileSuffix) {

      var menu = new Object ();
      menu. imageFilePath = imageFilePath;
      menu. imageFileSuffix = imageFileSuffix;
      menu. selectedButton = null;
      return menu;
   }


   function registerButton (imageName, menu) {
            
      if (document.images) {

         eval ("menu." + imageName + " = new Object ();");
         eval ("menu." + imageName + ".normal = new Image ();");
         eval ("menu." + imageName + ".mouseOver = new Image ();");
         eval ("menu." + imageName + ".selected = new Image ();");

         menu [imageName].normal.src    = menu.imageFilePath + imageName + menu.imageFileSuffix;
         menu [imageName].mouseOver.src = menu.imageFilePath + imageName + "MouseOver" + menu.imageFileSuffix;
         menu [imageName].selected.src  = menu.imageFilePath + imageName + "Selected" + menu.imageFileSuffix;   
      }
   }

				
   function mouseOver (imageName, menu) {

      if (document.images && (menu. selectedButton != imageName)) {
         document.images [imageName]. src = menu [imageName].mouseOver.src;
      }
   }
		

   function mouseOut (imageName, menu) {

      if (document.images && (menu. selectedButton != imageName)) {
         document.images [imageName]. src = menu [imageName].normal.src;
      }
   }


   function mouseClick (imageName, menu) {

      if (document.images) {
         document.images [imageName]. src = menu [imageName].selected.src;
         if ((menu. selectedButton != null)  && (menu. selectedButton != imageName)) {
            document. images [menu. selectedButton]. src = menu [menu. selectedButton].normal.src;
         }
         menu. selectedButton = imageName;
      }
   }