window.onload = initFontsize;

function initFontsize() {
	var fontSize = "11";
	if ((getCookie("ruFontSize") != null) &&  (getCookie("ruFontSize") != '')) {
		fontSize =  getCookie("ruFontSize");
	}
	if (fontSize != 11) {
		document.body.style.fontSize = getPercentSize(fontSize) + "%";
	}
}

function enlargeFont() {
	var size = getCookie("ruFontSize");
	if (size == null) {
		size = 11;
	}
	size++;
	if (size > 14) {size = 14}
	document.body.style.fontSize = getPercentSize(size)+'%';
	setCookie("ruFontSize",size);
}

function shrinkFont() {
	var size = getCookie("ruFontSize");
	if (size == null) {
		size = 11;
	}
	size--;
	if (size < 10) {size = 10}
	document.body.style.fontSize = getPercentSize(size)+'%';
	setCookie("ruFontSize",size);
}

function restoreSize() {
	size = "11";
	document.body.style.fontSize = getPercentSize(size)+'%';
	setCookie("ruFontSize",size);	
}

function getPercentSize(size) {
	return (size/16)*100;
}

function setCookie(cookieName,cookieValue) {
	var today = new Date();
	var expire = new Date();
	expire.setTime(today.getTime() + 3600000*24*1000);
	document.cookie = cookieName + "=" + escape(cookieValue) + ";expires="+expire.toGMTString();
}

function getCookie(cookieName) {
	oCookie = document.cookie;
	var index = oCookie.indexOf(cookieName + "=");
	if (index == -1) return null;
	index = oCookie.indexOf("=", index) + 1;
	var endstr = oCookie.indexOf(";", index);
	if (endstr == -1) endstr = oCookie.length;
	return unescape(oCookie.substring(index, endstr));
}