// open all external links in a new window

function scanforlinks()
{
    if (!document.getElementsByTagName)
        return false;

    links = document.getElementsByTagName('a');

    for (i=0; i < links.length; i++)
    {      
        var link = links[i];
        var href = link.getAttribute('href');

        if (href &&
            ((href.indexOf('http:')   == 0 && 
              href.indexOf('http://'  + window.location.host) != 0) ||
             (href.indexOf('https:')  == 0 && 
              href.indexOf('https://' + window.location.host) != 0) ||
             (href.indexOf('ftp:')    == 0 &&
              href.indexOf('ftp://'   + window.location.host) != 0)))
        {
            link.setAttribute('target','_blank');
        }
    }
}

if (window.addEventListener) 
    window.addEventListener("load", scanforlinks, false);
else if (window.attachEvent) 
    window.attachEvent("onload", scanforlinks);

