﻿/*No Spam Mailto Links*/
function mailLink(topLevel, domain, user) {
    window.location = 'mailto:' + user + '@' + domain + "." + topLevel;
}
/*Clear Search Box*/
function selectSb() {
    if (document.getElementById) {
        sb = document.getElementById('txtSearch')
        if (sb.value == 'Search') {
            sb.value = '';
        }
        else if (sb.value == '') {
        sb.value = 'Search';
        }
    } 
}
/*Set/Get Cookies*/
function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toUTCString()) + ";path=/";
}
function getCookie(c_name) {
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++) {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == c_name) {
            return unescape(y);
        }
    }
}
/*Set Low Bandwidth Choice On Load*/
function setLbChoice() {
    var lbCookie = getCookie("sjb_style_bandwidth");
    if (lbCookie != "high" && lbCookie != "low") {
        var loaded = false;
        var time = 15000;
        window.onload = function () {
            loaded = true;
        };
        setTimeout(function () {
            if (!loaded) {
                var lbChoice = confirm("This page is taking a long time to load. Press 'Ok' to view a low-bandwidth version of the site or 'Cancel' to continue to wait. You can change your choice using the 'Display Options' controls.");
                if (lbChoice == true) {
                    setCookie("sjb_style_bandwidth", "low", 30);
                    location.reload(true);
                }
                else {
                    setCookie("sjb_style_bandwidth", "high", 30);
                }
            }
        }, time);
    }
}
//set initial page display if js is turned on
function setPage() {
    if (document.getElementById) {
        document.getElementById('noJsStyle').href = '/CSS/none.css';
        document.getElementById('txtSearch').value = 'Search';
    }
}
/*Make things visible/not*/
function toggleVisible(elementID) {
    element = document.getElementById(elementID);
    if (element.className == "visible") {
        element.className = "";
        if (elementID == "displayOptions") {
            setCookie("sjb_" + elementID + "_visible", "false", 30);
        } 
    }
    else {
        element.className = "visible";
        setCookie("sjb_" + elementID + "_visible", "true", 30);
        if (elementID == "displayOptions") {
            setCookie("sjb_" + elementID + "_visible", "true", 30);
        }
    }
}
function shareOn() {
    if (document.getElementById) {
        document.getElementById('share').className = 'shareOn';
        document.getElementById('shareOut').className = 'shareOut';
    }
}
function shareOff() {
    if (document.getElementById) {
        document.getElementById('share').className = 'shareOff';
        document.getElementById('shareOut').className = 'shareOff';
    }
}
