function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {oldonload();}
            func();
        }
    }
}

function linkControl() {

    var thishost = window.location.host;
    var filetype = ".pdf";

    if (!document.getElementsByTagName) return false;
    var links = document.getElementsByTagName("a");
    for (var i=0; i<links.length; i++) {
        var link = links[i];

        // select outgoing links which are not e-mail links
        if ((link.host.indexOf(thishost) == -1) && (link.href.indexOf('@') == -1) && (link.href.indexOf('javascript') == -1)) {
            link.onclick = function() {
                window.open(this.href);
                return false;
            }
        }

        // select links with the specified filetype
        if (link.getAttribute("href").indexOf(filetype) != -1) {
            link.onclick = function() {
                window.open(this.href);
                return false;
            }
        }
    }
}

addLoadEvent(linkControl);