function initLinks() {
    // find all the links in the document
    var links = document.getElementsByTagName("a");

    // loop through the links and add onclick event handler to the appropriate
    // (in this case ones with class of 'newWin' somewhere in the 'class' attribute
    // also changes the title of the link (to refelect js enabled and opening new window)
    for(var i=0;i<links.length;i++) {

        var linkClassAttribute = links[i].className.toLowerCase();

        if(linkClassAttribute.match("newwin")) {
            links[i].onclick = openNewWin;
            links[i].onkeypress = openNewWin;
            var linkTitle = links[i].getAttribute("title");
            if(linkTitle) {
            links[i].setAttribute("title", linkTitle + " (will open in a new window)");
                }
            }

        }
}
function openNewWin() {
    // quite simple.... open new window with referenced objects href
    if(window.open(this.href)) {
        return false;
        } else {
    return true;
    }
}

window.onload = function() {
        initLinks();
}
