//
// javascript_global.js
// --------------------
// Common JavaScript functions used throughout the site.
//
//
 

function offsitePopup(url) {
    var popUp = window.open(url, 'offsiteWindow', 'width=1000,height=650,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes');
    if (typeof popUp == 'object') {
        popUp.focus();
    }
}

function enlargementPopup(url, title) {
    var popUp = window.open('/lib/popups/enlargement.php?url=' + url + '&title=' + title, 'enlargementWindow', 'width=630,height=600,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no');
    if (typeof popUp == 'object') {
        popUp.focus();
    }
}

/**
 * Displays the specified URL in a new window with all menus, tools, and scrollbars
 *
 * @author  Dan Delaney     http://fluidmind.org/
 * @param   url             URL to display in the popup window
 * @param   width           (Optional) The width of the new popup window
 * @param   height          (Optional) The height of the new popup window
 * @param   windowName      (Optional) The name of the window
 */
function popup(url)
{
    // Default to a 700 x 500 window
    var width = (arguments.length > 1 ? arguments[1] + '' : '700');
    var height = (arguments.length > 2 ? arguments[2] + '' : '500');
    var windowName = (arguments.length > 3 ? arguments[3] : 'popup');

    // Create it
    var popUp = window.open(url, windowName, 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes');

    // Bring it to the front
    if (typeof popUp == 'object') { popUp.focus(); }

    return false;
}  // popup()


/**
 * Displays the specified URL in a new window with NO menus or tools, but with scrollbars
 *
 * @author  Dan Delaney     http://fluidmind.org/
 * @param   url             URL to display in the popup window
 * @param   width           (Optional) The width of the new popup window
 * @param   height          (Optional) The height of the new popup window
 * @param   windowName      (Optional) The name of the window
 */
function popupNoTools(url)
{
    // Default to a 700 x 500 window
    var width = (arguments.length > 1 ? arguments[1] + '' : '700');
    var height = (arguments.length > 2 ? arguments[2] + '' : '500');
    var windowName = (arguments.length > 3 ? arguments[3] : 'popup');

    // Create it
    var popUp = window.open(url, windowName, 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no');

    // Bring it to the front
    if (typeof popUp == 'object') { popUp.focus(); }

    return false;
}  // popupNoTools()


/**
 * Displays the specified URL in a new window with NO menus, tools OR scrollbars
 *
 * @author  Dan Delaney     http://fluidmind.org/
 * @param   url             URL to display in the popup window
 * @param   width           (Optional) The width of the new popup window
 * @param   height          (Optional) The height of the new popup window
 * @param   windowName      (Optional) The name of the window
 */
function popupNoScroll(url)
{
    // Default to a 700 x 500 window
    var width = (arguments.length > 1 ? arguments[1] + '' : '700');
    var height = (arguments.length > 2 ? arguments[2] + '' : '500');
    var windowName = (arguments.length > 3 ? arguments[3] : 'popup');

    // Create it
    var popUp = window.open(url, windowName, 'width=' + width + ',height=' + height + ',scrollbars=no,resizable=no,menubar=no,toolbar=no,location=no');

    // Bring it to the front
    if (typeof popUp == 'object') { popUp.focus(); }

    return false;
}  // popupNoScroll()


function verifyEmailAddress(address) {
}



function globalOnLoad() {

    // Assign link events
    for (var i = 0; i < document.links.length; i++) {
        if (document.links[i].className.match('Offsite')) {
            document.links[i].onclick = function() { offsitePopup(this.href); return false; }
        }
        if (document.links[i].className.match('Enlargement')) {
            document.links[i].onclick = function() { enlargementPopup(this.href, this.title); return false; }
        }
    }

    // Run page onLoad function, if it exists
    if (typeof onLoad != 'undefined') {
        onLoad();
    }

}



// Every page should assign events
window.onload = globalOnLoad;
