﻿function readFontSize() 
{
    var inc = getCookie("TDECUFontSize");
    if (inc != "") 
    {
        changeFontSize(inc);
    }
}

function changeFontSize(inc) 
{
    clearCookie();
    setFontSizeCookie(inc);
    if (document.title == "Insurance Home")
    { }
    else if (document.title == "About Us Home")
    { }
    else if (document.title == "TDECU")
    { }
    else {
        setFont(inc);
    }

}

function setFont(inc) 
{
    changeFontSizeByTagName(inc, 'p');
    changeFontSizeByTagName(inc, 'table');
    changeFontSizeByTagName(inc, 'a');
}

function italicsTextFontSelection(inc)
{
    var p = document.getElementsByTagName('a');
    for (n = 0; n < p.length; n++) 
    {
        if (p.item(n).attributes.getNamedItem("href") == "javascript:changeFontSize(" + inc + ")") 
        {

            p[n].style.fontWeight = 'bold';
        }

    }

}

function changeFontSizeByTagName(inc, tag) {

    var mainSection = document.getElementById('mainContent');
    var p = mainSection.getElementsByTagName(tag);
    for (n = 0; n < p.length; n++) 
    {
            if (p[n].style.fontSize) {
                var size = parseInt(p[n].style.fontSize.replace("px", ""));
            } else {
                var size = 12;
            }
            p[n].style.fontSize = inc + 'px';
    }
}

function changeFontSizeByTagNameForElement(inc, tag, o) {


    var p = o.getElementsByTagName(tag);
    for (n = 0; n < p.length; n++) {
        if (p[n].style.fontSize) {
            var size = parseInt(p[n].style.fontSize.replace("px", ""));
        } else {
            var size = 12;
        }
        p[n].style.fontSize = inc + 'px';
    }
}


function changeFontSizeByID(inc, ID, tag) {

    var mainSection = document.getElementById('mainContent');
    var p = mainSection.getElementById(ID);
    changeFontSizeByTagNameForElement(inc, tag, p);
}

function changeFontSizeByName(inc, name) {
    var mainSection = document.getElementById('mainContent');
    var p = mainSection.getElementById(name);
    for (n = 0; n < p.length; n++) {
        if (p[n].style.fontSize) {
            var size = parseInt(p[n].style.fontSize.replace("px", ""));
        } else {
            var size = 12;
        }
        p[n].style.fontSize = inc + 'px';
    }
}

function setFontSizeCookie(inc) 
{
    setCookie("TDECUFontSize", inc, 1);
}

function clearCookie() 
{
    setCookie("TDECUFontSize", 0, -1);
}

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.toGMTString()) + "; path=/";
}

function getCookie(c_name) 
{
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

