function init()
{
	var el = document.getElementById("FontSizeTool");
	if(el != undefined)
	{
		el.style.display = "block";
		el.innerHTML = "<a href=\"#\" onclick=\"ChangeFontSize(.1);\" id=\"FontSizeBigger\">A+</a><a href=\"#\" onclick=\"ChangeFontSize(-.1);\" id=\"FontSizeSmaller\">A-</a>";
		var fontSize = getCookie("User.FontSize");
		if (fontSize != "" )
			SetFontSize( parseFloat(fontSize) );
	}
}

//////////////////////////////////////////////////


function ChangeFontSize(changeSize)
{
	var currentSizeString = document.body.style.fontSize;
	if (currentSizeString == undefined || currentSizeString == "")
		currentSizeString = "1em";
	var size = parseFloat(currentSizeString.replace("em", ""));
	if ( (changeSize < 0 && size > .8) || (changeSize > 0 && size < 1.2) )
		size += changeSize;
	SetFontSize(size);
	setCookie("User.FontSize", size.toString(), 20);
}

function SetFontSize(size)
{
	document.body.style.fontSize = size.toString() + "em";
}

//////////////////////////////////////////////////

function setCookie(CookieName, Value, ExpireDays)
{
	var ExpireOnDate = new Date();
	ExpireOnDate.setDate( ExpireOnDate.getDate() + parseInt(ExpireDays) );
	var CookieString = CookieName + "=" + escape(Value) + 
		"; path=/" + 
		( (ExpireOnDate==null) ? "" : "; expires="+ ExpireOnDate.toGMTString() );
	document.cookie = CookieString;
}

function getCookie(CookieName)
{
	var Value = "";
	if (document.cookie.length > 0)
	{
		var Cookies = document.cookie.toString() + "\n";
		var RegEx = new RegExp( CookieName +"=(.*?)[;\n]", "gi" );
		var Matches = RegEx.exec(Cookies);
		if( Matches )
			Value = unescape(Matches[1]);
	}
	return Value;
}

//////////////////////////////////////////////////


if (window.addEventListener)
{
	window.addEventListener("load", init, false);
}
else
{
	if (window.attachEvent)
	{
		window.attachEvent("onload", init);
	}
	else
	{
		document.onload = init;
	}
}


