﻿function toggle_language_func_visibility(display, hide) {
    var e = document.getElementById(display);
    // Display "choose language" section
    if (e.style.display == 'block')
        e.style.display = 'none';
    else
        e.style.display = 'block';
    // Hide button and current language section
    var h = document.getElementById(hide);
    if (h != null)
        h.style.display = 'none';
}

function setCookie(value) {
    if (document.forms[0].elements["defaultLocationCheckBox"].checked) {
        var defaultValue = "http://www.secotools.com/";
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + 365);
        document.cookie = "secoDefaultUrl=" + defaultValue + escape(value) + ";expires=" + exdate.toUTCString() + ";path=/;";
    }
}

function getCookie(check_name) {
    // split this cookie up into name/value pairs
    // note: document.cookie only returns name=value, not the other components
    var a_all_cookies = document.cookie.split(';');
    var a_temp_cookie = '';
    var cookie_name = '';
    var cookie_value = null;
    var b_cookie_found = false; // set boolean t/f default f
    var i = 0;
    for (i; i < a_all_cookies.length; i++) {
        // split each namevalue pair
        a_temp_cookie = a_all_cookies[i].split('=');

        // trim left/right whitespace
        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
        if (cookie_name == check_name) {
            // handle no value but exists
            if (a_temp_cookie.length > 1) {
                cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }
            return cookie_value;
            break;
        }
        a_temp_cookie = null;
        cookie_name = '';
    }
    return null;
}
