﻿
var startSz = 1;

function changemysize(incr,divs)
// this function is called by the user clicking on a text size choice
{
    var myDivs = new Array();
    myDivs = divs.split(",");
    var sz = startSz;
    sz += incr;
    if (incr==0)sz = 1;
    if (sz < .8) sz = .8;
    //if (sz > 6) sz = 6;
    if (sz > 2) sz = 2;
    startSz = sz;
    
    // find the div to apply the text resizing to
    for (i = 0; i < myDivs.length; i++) {
        document.getElementById(myDivs[i]).style.fontSize = sz + "em";
    }
    // store the text size choice into a cookie
    document.cookie = "CCFontSize=" + sz;
}

function getFontCookie(myname)
// this function is called by the function defaultFontSize()
// this function merely looks for any previously set cookie and then returns its value
{
    // if any cookies have been stored then
    if (document.cookie.length > 0) {
        // where does our cookie begin its existence within the array of cookies  
        mystart = document.cookie.indexOf(myname + "=");
        // if we found our cookie name within the array then
        if (mystart != -1) {
            // lets move to the end of the name thus the beginning of the value
            // the '+1' grabs the '=' symbol also
            mystart = mystart + myname.length + 1;
            // because our document is only storing a single cookie, the end of the cookie is found easily
            myend = document.cookie.length;
            // return the value of the cookie which exists after the cookie name and before the end of the cookie
            return document.cookie.substring(mystart, myend);
        }
    }
    // if we didn't find a cookie then return nothing  
    return "";
}

function defaultFontSize(divs) {
    //alert(getFontCookie("CCFontSize"));
    var myDivs = new Array();
    myDivs = divs.split(",");
    // this function is called by the body onload event
    for (i = 0; i < myDivs.length; i++) {
    // if we found the cookie then
        if (getFontCookie("CCFontSize") > 0) {
            document.getElementById(myDivs[i]).style.fontSize = getFontCookie("CCFontSize") + "em";
    }
    }
}
