﻿if (!document.cookie) {
	document.cookie = "CurrentFont=85%";
}

function SetFont(newSize) {

	if (document.getElementById('main-div')) {
		document.getElementById('main-div').style.fontSize = newSize;
	}

	if (document.getElementById('content-home')) {
		document.getElementById('content-home').style.fontSize = newSize;
	}

}

function ToggleFont() {

	newFontSize = '85%';

	if (GetFontSize() == '85%') {
		newFontSize = '100%';
	} else if (GetFontSize() == '100%') {
		newFontSize = '110%';
	} else if (GetFontSize() == '110%') {
		newFontSize = '85%';
	}

	SetFont(newFontSize);

	myDate = new Date();
	
	nextYear = myDate.getFullYear() + 1
	document.cookie = "CurrentFont=" + newFontSize + "; path=/; expires=31/12/" + nextYear + " 00:00:00";

}

function GetFontSize() {

	CookieArray = document.cookie.split(';');

	var FontSetting = '85%';

	for (i=0; i<CookieArray.length; i++) {
		if (CookieArray[i].split('=')[0].indexOf('CurrentFont') != -1) {
			FontSetting = CookieArray[i].split('=')[1];
		}
	}

	return FontSetting;

}

InitFont = function() {
	SetFont(GetFontSize());
}

window.onload=InitFont;
