/* $Id: extlinks.js 2 2006-03-05 18:54:16Z martin $ */

function extlinks_attach_events()
{
  var an = document.getElementsByTagName("a");
  var i;
  var this_href;
  var sidx;
  
  this_href = window.location.href;
  sidx = this_href.indexOf("://") + 3; /* Get index of '://' after protocol string */
  sidx = this_href.indexOf("/", sidx) + 1; /* Get index of first slash after this */
  
  this_href = this_href.substring(0, sidx);

  for(i=0; i < an.length; i++)
   {
     if ( an[i].href  /* href exists; not the case for navigation-only anchors */
       && an[i].href.indexOf("://") != -1 /* a protocol is given; filters 'javascript:' and 'mailto:' and similar */
       && an[i].href.indexOf(this_href) != 0 ) /* not a local link */
      {
        /* Open in new window */
        if (!an[i].onclick) 
         { an[i].onclick = function (e) { window.open(this.href); return false; }; }
    /*    an[i].onkeypress || an[i].onkeypress = function (e) { window.open(this.href); return false; }; */
      }
   }
}

