
function addEvent(obj, evType, fn){
// alert('addEvent is Adding on' + evType + ' to ' + obj + '.');
  if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
  else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; }
  else { return false; }
}

var menuElements = new Array ( 'hpBoxout0', 'hpBoxout1', 'hpBoxout2', 'hpBoxout3' );

function menuEvents(e) {
  // assign event to e
  if (!e) { var e = window.event; }
  // assign target to targ
  var targ;
  if (e.target) { targ = e.target; }
  else if (e.srcElement) { targ = e.srcElement; }
  if (targ.nodeType == 3) { // defeat Safari bug
    targ = targ.parentNode; }
  while (targ.nodeName != 'DIV') { targ = targ.parentNode; }
  // swap classes
  if (e.type == 'mouseover') { targ.className = 'hpBoxoutOver'; }
  if (e.type == 'mouseout') { targ.className = 'hpBoxout'; }
  // activate link when DIV clicked
  if ((e.type == 'click') && (targ.nodeName == 'DIV')) { document.location.href = targ.firstChild.href; }
}


function setEvents() {
  for ( evLoop = 0; evLoop < menuElements.length; evLoop++ ) {
  if ( document.getElementById(menuElements[evLoop]) ) {
      addEvent(document.getElementById(menuElements[evLoop]), 'mouseover', menuEvents);
      addEvent(document.getElementById(menuElements[evLoop]), 'mouseout', menuEvents);
//      addEvent(document.getElementById(menuElements[evLoop]), 'click', menuEvents);
    }
  }
}

addEvent(window, 'load', setEvents);
