﻿function showElement(elementID) {

    var element = document.getElementById(elementID);

    if (element != null) {
        element.style.visibility = "visible";
        element.style.display = "block"
    }

}

function hideElement(elementID) {

    var element = document.getElementById(elementID);

    if (element != null) {
        element.style.visibility = "hidden";
        element.style.display = "none"
    }

}

// confirmation box
function confirmLeave(loc) {
    var where_to = confirm("You are leaving the Meta Financial Group website. Information accessed through this link is not provided by or endorsed by Meta Financial Group. Companies that provide information through website links may have different privacy policies from those of Meta Financial Group.");

    if (where_to == true) window.location = loc;
}

document.onkeydown = CancelEnter

function CancelEnter(e) {
    var intKeyCode = 0;

    // Which browser?
    if (document.all) {
        // IE
        intKeyCode = event.keyCode;
    }
    else {
        // Non IE
        intKeyCode = e.which;
    }

    // Is this enter?
    if ((intKeyCode != null && intKeyCode == 13)) {
        return false;
    }
}


// open window
function popup(url) {
    var width = 800;
    var height = 600;
    popupWithDimensions(url, width, height);

    return false;
}



// open window with dimensions set in link
function popupWithDimensions(url, width, height) {
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=yes';
    params += ', scrollbars=no';
    params += ', status=no';
    params += ', toolbar=no';
    newwin = window.open(url, 'windowname5', params);
    if (window.focus) { newwin.focus() }
    return false;
}

function getCommunity() {
    var communityValue = readCookieKeyValue("MBOLSETTINGS", "Community");
    if (communityValue == null) communityValue = "No Market";
}

function readCookieKeyValue(name, key) {
    var cookieKeyValue = null;
    var cookie = readCookie(name);
    if (cookie != null) {
        cookieKeyValue = readCookieValue(cookie, key);
    }
    return cookieKeyValue;
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function readCookieValue(cookie, key) {
    var keyEQ = key + "=";
    var ca = cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(keyEQ) == 0) return c.substring(keyEQ.length, c.length);
    }
    return null;
}
