﻿// JScript File

/*
 * increaseFontSize
 *
 * This function reads the currently set font size of the body element of
 * the page, if it finds nothing which would be the case when it is called the 
 * very first time on a standard page then it sets the font size to 15px. 
 * It then takes either the read in value or 15px, increases the font size by 
 * 2px and then saves the value back to the page.
 *
 */
function FontSize(div, size) {
	// get a reference to the body element
	var block = document.getElementById(div);
/*
	// get the font size from the body element
	var fontSize = "" + block.style.fontSize;
	if (fontSize.length == 0)
	{	// there is no recorded size (and the default is 15px)
		fontSize = 15;
	}
	else
	{	// there is a font size already there, get it by removing 
		// the "px" from the end of the string
		fontSize = fontSize.substr(0,fontSize.length - 2);
	}
	
	// increment the font size by two (this is done with subtraction, 
	// because javascript on some browsers will fail to treat the string "15"
	// as a number for addition, but always do it correctly for subtraction).
	fontSize = fontSize -(-2);

	// save it to the cookie
	createCookie("font", fontSize+"px", 365);
*/
	// write it back to the page
	block.style.fontSize = size+"em";
}

/*
 * decreaseFontSize
 *
 * This function reads the currently set font size of the body element of
 * the page, if it finds nothing which would be the case when it is called the 
 * very first time on a standard page then it sets the font size to 15px. 
 * It then takes either the read in value or 15px, decreases the font size by 
 * 2px and then saves the value back to the page.
 *
 */
function decreaseFontSize() {
	// get a reference to the body element
	var bodyRef = document.getElementsByTagName("body");
	bodyRef = bodyRef.item(0);
	
	// get the font size from the body element
	var fontSize = "" + bodyRef.style.fontSize;
	
	if (fontSize.length == 0)
	{	// there is no recorded size (and the default is 15px)
		fontSize = 15;
	}
	else
	{	// there is a font size already there, get it by removing 
		// the "px" from the end of the string
		fontSize = fontSize.substr(0,fontSize.length - 2);
	}

	// decrement the font size by two
	fontSize = fontSize - 2;
	
	// there is a minimum font size of 8px
	if (fontSize <= 8)
	{
		fontSize = 8;
	}
	
	// write it back to the page
	bodyRef.style.fontSize = fontSize+"px";
	
	// save it to the cookie
	createCookie("font", fontSize+"px", 365);
}