
// Get cookie function - Return the value of the cookie
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + 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));
}

function smallFont() {
	// Change the current font size and write the value back to cookie (12px)
	document.body.style.fontSize = '75%';
	document.cookie = "fontsize=small; path=/";
}

function medFont() {
	// Change the current font size and write the value back to cookie (14px)
	document.body.style.fontSize = '87.5%';
	document.cookie = "fontsize=med; path=/";
}

function largeFont() {
	// Change the current font size and write the value back to cookie (16px)
	document.body.style.fontSize = '100%';
	document.cookie = "fontsize=large; path=/";
}

function checkFontSize() {
	try {
		// Do this onload
		var receivedCookieData = getCookie("fontsize");
		if (receivedCookieData !== null) {
			if(receivedCookieData == "small") {
				smallFont();
			}
			if(receivedCookieData == "med") {
				medFont();
			}
			if(receivedCookieData == "large") {
				largeFont();
			}
		} else {
			smallFont();
		}
	} catch(e) { }
}

