function setFontSize(factor) {
	var minSize = 2;
	var maxSize = 20;
	var fontsize;
	var isMac = false;
	if (navigator.platform.indexOf("Mac")>=0){isMac = true;}
	var fontSize;
	
	if ( factor == "init") {
		var fontSize = GetCookie("SCfontSize");
		
		if (fontSize) {
			var body = document.getElementsByTagName('body')[0];
			body.style.fontSize = fontSize + "px";
			return;
		}
		
		else { return; }
	}
	else
	{
		if (isMac)
		{
			var font = document.body.style.fontSize;

			if (font == '')
			{
				if (factor<0)
				{
				   font = 8;
				}
				else
				{
			       font = 12;
				}
				fontSize = parseInt(font);
			}
			else
			{
			   var i = font.indexOf('px');
			   font = font.substring(0,i);
               fontSize = parseInt(font);

			   if ( (fontSize + factor < maxSize) && (fontSize + factor > minSize)) 
				fontSize =fontSize+factor;

			}

			document.body.style.fontSize=fontSize+"px";
			document.cookie = "SCfontSize=" + fontSize + ";path=/";
		}
		else {
		
			var body = document.getElementsByTagName('body')[0];
			
			try {
				var fontStyle = document.defaultView.getComputedStyle(body, '').getPropertyValue("font-size");
			}
			catch (error) {
				var fontStyle = body.currentStyle.fontSize;
			}
			
			fontSize = parseInt(fontStyle.match(/\d+/));
			
			if ( (fontSize + factor < maxSize) && (fontSize + factor > minSize)) {
				fontSize = fontSize + factor;
			
				body.style.fontSize = fontSize + "px";
				document.cookie = "SCfontSize=" + fontSize + ";path=/";
			}
		}
	}
}

function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	
	while (i < clen) {
		var j = i + alen;
		
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal (j);
		}
				
		i = document.cookie.indexOf(" ", i) + 1;
		
		if (i == 0) break; 
	}
	return null;
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	
	return unescape(document.cookie.substring(offset, endstr));
} 


function loadFontSizer()
{
	setFontSize("init");
}

