function setFontSize(factor) {
	var anchors = document.getElementsByTagName("a");
	
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
		}
	}

	if ( factor == "init") {
		var fontSize = GetCookie("SCfontSize");
		
		if (fontSize) {
			var body = document.getElementsByTagName('body')[0];
			body.style.fontSize = fontSize + "px";
			return;
		}
		
		else { return; }
	}
	
	else {
		var body = document.getElementsByTagName('body')[0];
		
		try {
			var fontStyle = document.defaultView.getComputedStyle(body, '').getPropertyValue("font-size");
		}
		
		catch (error) {
			var fontStyle = body.currentStyle.fontSize;
		}
		
		var fontSize = parseInt(fontStyle.match(/\d+/));
		
		// Catches errors is cookie contains a font size in a format other than px
		if (!(fontSize + 1)) fontSize = 12;
		
		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));
} 