
var lastMouseX;
var lastMouseY;
var curPopupWindow = null;
var curPopunderWindow = null;

function manualSubmit(action) {
    var f = document.forms[0];
    f.action = action
    f.submit();
}

function mouseCursor(cursor) {
    var el = event.srcElement;
    switch (cursor) {
        case "hand":
            el.style.cursor = "hand";
            break
        default:
            el.style.cursor = "default";
    }
}

// cross browser compatible
function changeCursor(cursor, evt) {
    evt = (evt) ? evt : event;
    var el = (evt.target) ? evt.target : event.srcElement;

    switch (cursor) {
        case "hand":
            el.style.cursor = "pointer"; // for modzilla, don't change order
            el.style.cursor = "hand"; // for ie
            break
        default:
            el.style.cursor = "";
    }
}

function openPopup(url, name, width, height, features, snapToLastMousePosition) {
    closePopup();
    if (snapToLastMousePosition) {
        if (lastMouseX - width < 0) lastMouseX = width;
        if (lastMouseY + height > screen.height) lastMouseY -= (lastMouseY + height + 50) - screen.height;
        lastMouseX -= width;
        lastMouseY += 10;
        features += "screenX=" + lastMouseX + ",left=" + lastMouseX + "screenY=" + lastMouseY + ",top=" + lastMouseY;
    }
    curPopupWindow = window.open(url, name, features, false);
}

function setLastMousePosition(evt) {
    evt = (evt) ? evt : event;
    lastMouseX = evt.screenX;
    lastMouseY = evt.screenY;
}

function closePopup() {
    if (curPopupWindow != null) {
        if (!curPopupWindow.closed) curPopupWindow.close();
        curPopupWindow = null;
    }
}

function popUp_Scroll(url, name, width, height) {
    openPopup(url, name, width, height, "width=" + width + ",height=" + height + ",dependent=no,resizable=yes,toolbar=no,status=yes,directories=no,menubar=no,scrollbars=1", false);
}

function popUp(url, name, width, height) {
    openPopup(url, name, width, height, "width=" + width + ",height=" + height + ",dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=0", false);
}

function popUp_Snap(url, name, width, height) {
    openPopup(url, name, width, height, "width=" + width + ",height=" + height + ",dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=0", true);
}

function popUnder(url, name, width, height) {
    closePopunder();
    curPopunderWindow = window.open(url, name, "width=" + width + ",height=" + height + ",dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=0");
    curPopunderWindow.blur();
    window.focus();
}

function closePopunder() {
    if (curPopunderWindow != null) {
        if (!curPopunderWindow.closed) curPopunderWindow.close();
        curPopunderWindow = null;
    }
}
function pick(field, val) {
    var f = document.forms[0];
    f[field].value = val;
    closePopup();
    return false;
}
// -- CUSTOM FUNCTIONS ---------------------------------------------------------------------------</>-
//for dropdown menu links to forms
function openLink(el) {
    if (el.options[el.selectedIndex].value == "")
        return false;
    else
        return location.href = el.options[el.selectedIndex].value;
}


// Absolute Div Close Funtion
//this version doesn't block out the flash links on home pages when it's hidden
//use showlinkSize function below if you close the div using this version.

function hidelinkSize(layername) {

    if (!document.getElementById) return

    if (layername.style.visibility == "visible") {
        layername.style.visibility = "hidden";
        layername.style.top = "-9999px";
        layername.style.height = "0px";
        layername.style.width = "0px";

    }
    else {
        layername.style.visibility = "hidden";
        layername.style.top = "-9999px";
        layername.style.height = "0px";
        layername.style.width = "0px";
    }
}

// Div pop up Funtion
//needs input parameters to set size and distace to restore placement - if closed using the close script above, it has moved it off screen.
//call like this: showlinkSize(document.getElementById('Promo2'), '150px', '640px', '260px')
function showlinkSize(layername, topUnit, divWidth, divHeight) {

    if (!document.getElementById)
        return

    if (layername.style.visibility == "hidden") {
        layername.style.visibility = "visible";
        layername.style.top = topUnit;
        layername.style.height = divHeight;
        layername.style.width = divWidth;
    }
    else {
        layername.style.visibility = "visible";
        layername.style.top = topUnit;
        layername.style.height = divHeight;
        layername.style.width = divWidth;
    }
}
// Div pop up Funtion

function showlink(layername) {

    if (!document.getElementById)
        return
    if (layername.style.visibility == "hidden")
        layername.style.visibility = "visible"
    else
        layername.style.visibility = "visible"
}

// Absolute Div Close Funtion

function hidelink(layername) {

    if (!document.getElementById)
        return
    if (layername.style.visibility == "visible")
        layername.style.visibility = "hidden"
    else
        layername.style.visibility = "hidden"
}

