/* Javascript */

// Drop Down Menu IE Fix
startList = function() {
    if(document.all && document.getElementById) {
        navRoot = document.getElementById('prinav');
        for(i=0;i<navRoot.childNodes.length;i++) {
            node = navRoot.childNodes[i];
            if(node.nodeName == 'LI') {
                node.onmouseover = function() { this.className += ' over'; }
                node.onmouseout = function() { this.className = this.className.replace(' over',''); }
            }
        }
    }
}
window.onload = startList;

// Opens a URL in a centered popup window
// Usage: <a href="http://www.google.com" onclick="return popUp(this,640,480,false)">Google</a>
function popUp(link,w,h,scroll) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    scroll = (scroll==true) ? '1' : '0';
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
    win = window.open(link.getAttribute('href'),'Popup',winprops)
    if(parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
    return false;
}


// Cross-browser script to bookmark current page
// Usage: <a href="javascript:addToFavourites()" title="Add this page to your Favourites">Add To Favourites</a>
function addToFavourites() {
    var title = document.title;
    var url = window.location.href;
    // IE
    if(document.all) {
        window.external.AddFavorite(url,title);
    }
    // Firefox
    else if(window.sidebar) {
        window.sidebar.addPanel(title,url,'');
    }
    // Other browsers
    else {
        alert('Please hold CTRL-D (Command-D for Mac users) to bookmark this page.');
    }
}

// Prints the current page
// Usage: <a href="javascript:printPage()" title="Print this page">Print Page</a>
function printPage() {
    window.print();
}