﻿/*
 * global-functions.js
 *
 * Contains all the common functions that are used by pages on the site.
 */


// Opens a popup window.
function openPopup(link, name, width, height, scroll) {
    if (link && link.href) {
        name = name || "";
        features = "top=0,left=0,screenX=0,screenY=0";
        if (width)  features = features + ",width=" + width;
        if (height) features = features + ",height=" + height;
        if (scroll) features = features + ",scrollbars=" + scroll;

        // Open the window.
        var w = window.open(link.href, name, features);
        if (!w.opener) w.opener = self; // Sets the opener (if not assigned automatically)
        w.focus(); // Moves the new window to the top.
       
        return false;
    }
    else {
        return true;
    }
}


// Opens a new window.
// Like openPopup() but doesn't require a link (just the URL/href will do).
function openNew(href, name, width, height, scroll) {
    name = name || "";
    features = "top=0,left=0,screenX=0,screenY=0";
    if (width)  features = features + ",width=" + width;
    if (height) features = features + ",height=" + height;
    if (scroll) features = features + ",scrollbars=" + scroll;
    
    // Open the window.
    var w = window.open(href, name, features);
    if (!w.opener) w.opener = self; // Sets the opener (if not assigned automatically)
    w.focus(); // Moves the new window to the top.

    return false;
}


// Navigates to a new window.
function navigate(href) {
    window.location = href;
    return true;
}


function linkMouseOver(imageName) {
    image = $(imageName);
    if (image && image.src) {
        image.src = "/global/images/visa_test_over.gif";
    }
}


function linkMouseOut(imageName) {
    image = $(imageName);
    if (image && image.src) {
        image.src = "/global/images/visa_test.gif";
    }
}
