
/* =============================== */
/* = General Hover-related tasks = */
/* =============================== */

var Hover = {
  EXIT_DELAY  : 600,
  HOVER_BG_ON : 'url(/images/hover-gradient.gif) left repeat-y',
  HOVER_BG_OFF: 'none',
  
  lastTimer   : null,
  lastCommand : null,
  inhibit     : false,
  
  clearCurrent: function() {
    if(!this.lastTimer) return
    clearTimeout(this.lastTimer)
    eval(this.lastCommand)
    this.lastTimer = this.lastCommand = null
  },
  
  endWith: function(command) {
    if(this.inhibit) return
    this.lastCommand = command
    this.lastTimer = setTimeout(command, this.EXIT_DELAY)
  },
  
  toggle: function(on, container, nubbin) {
    if(this.inhibit) return
    
    if(on) {
      if($(container))
        $(container).style.background = this.HOVER_BG_ON
      Element.showIf(nubbin)
    } else {
      if($(container))
        $(container).style.background = this.HOVER_BG_OFF
      Element.hideIf(nubbin)
    }
  }
}
