// Copyright Arran Maclean @ riverinteractive

function set_cookie(fontsize)
{
	var the_cookie = "textsize=" + fontsize;
	var the_date = new Date("December 31, 2050");
	var the_cookie_date = the_date.toGMTString();
	the_cookie = the_cookie + ";expires=" + the_cookie_date;
	document.cookie = the_cookie;
}


function get_size() {
	var cookieInfo = document.cookie;
	var pos = cookieInfo.indexOf("textsize=");
	var textsize = 80;
	if (pos != -1)
	{
		var start = pos + 9;
		var end = cookieInfo.indexOf(";", start);
		if (end == -1) end = cookieInfo.length;
		var value = cookieInfo.substring(start,end);
		textsize = parseInt(value);
	}
	// alert("Cookie returning " + textsize);
	return isNaN(textsize) ? 80 : textsize;
}

function set_size(size) {
	document.body.style.fontSize = "" + size + "%";
	// alert("Size set to " + size + "%");
	set_cookie(size);
}

function change_size(increment) {
	var textsize = get_size();
	textsize += increment;
	if (textsize < 30) {
		textsize = 30;
	}
	set_size(textsize);
}

function decrease() {
	change_size(-10);
}

function increase() {
	change_size(10);
}
