// @(#) $Id: externalLinks.js 453 2005-08-23 10:50:17Z andy $

function externalLinksToNewWindow () {
    for ( var i = 0 ; i < document.links.length; i++ ) {
        var link = document.links[i];

        // Curse the infernal variations of DOM0.  Sometimes hostname
        // has a port number on it, sometimes it doesn't.  Ditto for
        // "host" (which should always have a port number).  Instead,
        // just strip off anything after a colon and hope for the best.
        var link_hostname = link.hostname.replace(/:[0-9]+$/, "");

        // Ignore internal links.
        if ( link_hostname == document.location.hostname )
            continue;

        link.title = "Opens in a new window";
        link.onclick = function () { window.open( this.href ); return false }
        if ( link.className ) {
            link.className = link.className + " external";
        } else {
            link.className = "external";
        }
    }
}

addLoadEvent( externalLinksToNewWindow );

// vim: set ai et sw=4 :
