// Changes the font size of the element and stores the size in a cookie
function changeFontSize(strID, strSize)
{
	// get the element
	document.getElementById(strID).style.fontSize = strSize;
	// set the cookie
	SetCookie("fontSize",strSize,"December,31,2029");
}

// Function to find any cookied font size on the clients machine and set the font to their preference as specified in the cookie
function getFontSize(strID) {
	// check if the object whose id is given exists
	if(document.getElementById(strID)) {

		// create regular expression to match pattern 'fontSize=.......' till a semicolon is encountered or the string ends
		var regEx = new RegExp("fontSize=[^;]+");

		// if cookie exists
		if(regEx.test(document.cookie)){

			// if match found, then extract the part of the string matching the regular expression pattern
			var cookieEntry = document.cookie.toString().match(regEx);

			if(cookieEntry != '') {

				// from the match, extract the font size
				var fontSize = cookieEntry.toString().substring(9, cookieEntry.toString().length);

				// call the function to change the font size accordingly
				changeFontSize(strID, fontSize.toString());
			}
		}
	}
}

function SetCookie(name,value,expires)
{
	var exp = new Date(expires);
	document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString(); + ";path=";
}
