/*
 * (c) 2004 Ian Eure.
 * http://www.websprockets.com/index.php?p=19
 */

function extPopup()
{
    window.open(this.href);
    return false;
}

function thunk()
{
    this.popup();
    return false;
}

function initLinks()
{
    /* Current location */
    var cl = window.location.protocol + '//' + window.location.host;
    var links = document.getElementsByTagName('a');
    var i;
    var proto;
    
    for (i = 0; i < links.length; i++) {
        /* Link protocol */
        proto = links[i].href.slice(0, links[i].href.indexOf(':'));

        /* Ignore some */
        if (!links[i].href.length ||
            proto == 'mailto' ||
            proto == 'javascript') {
            continue;
        }

        /* See if the link is external */
        if (links[i].href.slice(0, cl.length) != cl) {
            links[i].popup = extPopup;
            links[i].onclick = thunk;
        }
    }
}