/*******************************************************************************
*  hoverbox_ie.js
* -----------------------------------------------------------------------------
*  A workaround for IE6's no support for :hover pseudo-class on non-<a> tags.
*  See the "hoverbox" CSS selector for info.
*******************************************************************************/

/*
 * getElementsByClass()
 * @see http://www.dustindiaz.com/top-ten-javascript/ (item #8)
 */
function getElementsByClass(node, searchClass, tag)
{
  var classElements = new Array();
  var els = node.getElementsByTagName(tag); // use "*" for all elements
  var elsLen = els.length;
  var pattern = new RegExp("\\b"+searchClass+"\\b");
  for (var i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

/*
 * vbHover() (adapted Suckerfish)
 * @see http://www.htmldog.com/articles/suckerfish/
 */
vbHover = function() {
  var vbEls = getElementsByClass(document, 'hoverbox', 'div');
  for (var i = 0; i < vbEls.length; i++) {
    vbEls[i].onmouseover = function() {
      this.className += " hoverbox-hover";
    }
    vbEls[i].onmouseout = function() {
      this.className=this.className.replace(new RegExp(" hoverbox-hover\\b"), "");
    }
  }
}

if (window.attachEvent) window.attachEvent("onload", vbHover);
