var prefsLoaded = false;
var defaultFontSize = 100;
var currentFontSize = defaultFontSize;
var cookieName = "fontSize_bellevue";

/************************************************************\
*
\************************************************************/
function startFont()
{
	fsize = readCookie(cookieName);
	if (parseInt(fsize)) {
		fsize = parseInt(fsize)
		if(fsize > 160)
		{
			fsize = 100;
		}
		if(fsize < 60)
		{
			fsize = 100;
		}
		setFontSize(fsize);
		currentFontSize	= fsize;
		createCookie(cookieName, currentFontSize, 365);
	}
}
function revertStyles()
{
	currentFontSize = defaultFontSize;
	setFontSize(currentFontSize);
}
/************************************************************\
*
\************************************************************/
function changeFontSize(sizeDifference)
{
	currentFontSize = parseInt(currentFontSize) + sizeDifference;//parseInt(sizeDifference * 10);
	if(currentFontSize > 160)
	{
		currentFontSize = "160";
	}
	else if(currentFontSize < 60)
	{
		currentFontSize = "60";
	}
	setFontSize(currentFontSize);
}
;
/************************************************************\
*
\************************************************************/
function setFontSize(fontSize)
{
	if (document.getElementById('content'))
	{
		document.getElementById('content').style.fontSize = fontSize + '%';
		document.getElementById('content').style.lineHeight = (fontSize * 1.5) + '%';
	}
	
	if (document.getElementById('links_gruen'))
	{
		document.getElementById('links_gruen').style.fontSize = fontSize + '%';
		document.getElementById('links_gruen').style.lineHeight = (fontSize * 1.5) + '%';
	}
	
	if (document.getElementById('navioben'))
	{
		document.getElementById('navioben').style.fontSize = fontSize + '%';
		document.getElementById('navioben').style.lineHeight = (fontSize * 1.5) + '%';
	}
	
	if (document.getElementById('blau'))
	{
		document.getElementById('blau').style.fontSize = fontSize + '%';
		document.getElementById('blau').style.lineHeight = (fontSize * 1.5) + '%';
	}
	
	if (document.getElementById('gruen'))
	{
		document.getElementById('gruen').style.fontSize = fontSize + '%';
		document.getElementById('gruen').style.lineHeight = (fontSize * 1.5) + '%';
	}
	
	createCookie(cookieName, currentFontSize, 365);	
}
/************************************************************\
*
\************************************************************/
function setUserOptions()
{
	var cookie = readCookie("style");
	if(!prefsLoaded)
	{
		cookie = readCookie(cookieName);
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);
		prefsLoaded = true;
	}
}
/************************************************************\
*
\************************************************************/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
/************************************************************\
*
\************************************************************/
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
	var c = ca[i];
	while (c.charAt(0)==' ') c = c.substring(1,c.length);
	if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
onload = function() {
	startFont();
}