/*	boxkill3.js
	M G O'Farrell, III
	030205

	JavaScript to kill the focus box
	around text links

	based upon an earlier script (boxkill.js),
        that blew-out when it encountered an IMG
        used as a link, and more generalized than
        a successor script (boxkill2.js), that
	considered only "A" and "AREA" elements to
	have the blur() method.
*/

function focusHandler(e) { 
  /* elements in HTML 4.01 that support the tabindex property
     and therefore also have the blur() method.
     the _'s allows us to exclude elements like "B" and "P". 
  */
  var has_tabindex = "A_AREA_BUTTON_INPUT_OBJECT_SELECT_TEXTAREA_";

  if (!e)
    e = window.event;

  if (e.target) // "Netscape"
    obj = e.target;
  else if (e.srcElement) // Micro$oft
    obj = e.srcElement;
  else // oops! no idea what we've got here
    return;

  /* obj can still be an element that does not have a
     blur() method. if this happens on, say, an IMG,
     an exception occurs. therefore, it's necessary to
     do nothing if capture has occured on an element
     contained within the link object itself.

     since in modern JavaScript implementations, the 
     event will "bubble-up" to the next element in the
     DOM hierarchy, the blur() method will eventually
     be applied, and applied properly.
  */
    
  /* if current object does not support the tabindex
     property, then bail.
  */
  if(has_tabindex.indexOf( obj.tagName + "_" ) == -1)
    return;

  obj.blur();
}

function boxKill() { 
  if (document.links)
    for ( i = 0; i < document.links.length; i++ ) {
      // register our event handler for each link
      document.links[i].onfocus = focusHandler;
    }
}
