// Hover.js
// Javascript Behaviour for the Hover Visual Effect
// Copyright (c) by Matthias Hertel, http://www.mathertel.de
// This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx
// ----- 
// 02.04.2006 created by Matthias Hertel
// 11.07.2007 enabling disabled elements

// The hover behaviour must be attached to the document level only once.
// To enable this effect it is necesary to just include this file.

var HoverBehaviour = {

  // ----- Properties -----
  _obj: null, // the current hovered object

  // ----- Events -----
  // add hover effect
  onmouseover: function(evt) {
    var obj = evt.srcElement;

    if ((! jcl.isIE) && (obj) && (obj.attributes["hover"]))
       obj.hover = obj.attributes["hover"];
    if (obj.hover == "false")
      obj.hover = false;
    if ((obj) && (obj.hover) && (obj != HoverBehaviour._obj) && (obj.className.indexOf("disabled") < 0)) {
      HoverBehaviour._obj = obj;
      obj.className = obj.className + "Hover";
    } // if
  },

  // remove hover effect
  onmouseout: function(evt) {
    var obj = evt.srcElement;
    if ((obj != null) && (obj == HoverBehaviour._obj)) {
      var cn = obj.className.split(" ");
      cn[0] = cn[0].replace(/(Pushed|Hover)$/, "");
      obj.className = cn.join(" ");
      HoverBehaviour._obj = null;
    } // if 
  },

  // remove hover effect
  onmousedown: function(evt) {
    var obj = evt.srcElement;
    if (obj == HoverBehaviour._obj)
      obj.className = obj.className.replace(/(Pushed|Hover)$/, "") + "Pushed";
  },

  // remove hover effect
  onmouseup: function(evt) {
    var obj = evt.srcElement;
    if (obj == HoverBehaviour._obj)
      obj.className = obj.className.replace(/(Pushed|Hover)$/, "") + "Hover";
  }
} // HoverBehaviour

jcl.LoadBehaviour(document, HoverBehaviour);  
