window.addEvent('domready', function() {

// POPUP Code
// This function searches for all div elements in the page that have a class value starting with 'popup' and 
// adds an event to the a element contained within to open the link as a popup.
$$('div[class^=popup]').each(function(el) {
    var anchor = el.getElement('a');
    if(anchor){
        var win_height = 800;
        var win_width = 600;
        var title = el.className.replace('popup','');
        if(title.length>0){
            var split_array = title.split(':');
            if(split_array.length = 2){
                if(isNaN(split_array[0] + split_array[1])){}
                else{
                    win_width=split_array[0];
                    win_height=split_array[1];
                }
            }
            
        }
        anchor.addEvent('click', function(e){
            e = new Event(e);
            e.stop();
            window.open(this.href, 'Banner', 'width=' + win_width + ',height=' + win_height + ',scrollbars=yes,resizable=yes');
        });
    }
}); 
 
/*
// PDF Popup trawler. 
// This code checks all a elements to see if they link to pdf's and if so, changes the 
// href attribute to a javascript popup command that opens the /popups/display-pdf page.
$$('a').each(function(el) {
 win_width = 800;
 win_height = 800;
 strtest = el.href;
 if(strtest.lastIndexOf(".pdf")+4 == strtest.length){
   el.href = "javascript:void(window.open('/popups/display-pdf?file="+escape(strtest)+"', 'Pdf', 'width=" + win_width + ",height="+win_height+",scrollbars=yes,resizable=yes'))"
   }
}); 
*/

});

function changePage(value) {
    if(value != 0){
        location.href = value; 
    }
}