/*
 * Allows the user to easily change the font size of the text on the page
 */
intFontSize = 1;

<!-- Function to change to base font size of the page -->
function changeFontSize(intSize) {
	if (intSize == 1 ) { document.body.style.fontSize = "70%"; }
	if (intSize == 2 ) { document.body.style.fontSize = "small";	}
	if (intSize == 3 ) { document.body.style.fontSize = "100%";	}
	if (intSize == 4 ) { document.body.style.fontSize = "120%"; }
	if (intSize < 1 | intSize > 4) { intSize = 1; }
	var savedFont = saveFontSize(intSize);
	intFontSize = intSize;
}

<!-- Function to save the user selected font size into a session cookie -->
function saveFontSize(intSize) {
	if (document.cookie) {
		var expire = new Date();
		expire.setDate(expire.getDate() + 1);
		setCookie("fsize", intSize, expire, "/");
		return true;
	}
}

<!-- Function to change the base font size each time the page is started -->
<!-- If a value is set in the cookie -->
function setDefaultFont() {
	// make the accessibility id contents visible
	if (document.getElementById && document.getElementsByTagName && document.cookie) {
		var oElement =  document.getElementById("accesibility");
		var oNodes = oElement.getElementsByTagName("p");
		for(i=0; i < oNodes.length; i++) {
			oNodes[i].style.visibility = "visible";
		}
	}
	var testCookie = getCookie("fsize");
	if (testCookie) {
		intFontSize = testCookie
		changeFontSize(intFontSize);
	}
}

/*
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape(value) +
        ((domain) ? "; domain=" + escape(domain) : "") +		
        ((path) ? "; path=" + escape(path) : "") +
        ((secure) ? "; secure" : "") + 
        ((expires) ? "; expires=" + expires.toGMTString() : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.lastIndexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(setDefaultFont);
addLoadEvent(function() {
  /* more code to run on page load */ 
	}
);
