Event.observe(window, 'load', function() {
	var fontSizeCookie = readCookie('fontSizeCookie');
	if(fontSizeCookie)
	{
		setFontSize(null,fontSizeCookie);
	}

	AjaxRequest.updateLink('content');

});


/*
 * Overriding Ajax Loader
 */
AjaxRequest.startLoading = function(instance)
{
	$('ajax-loader').show();
}

AjaxRequest.stopLoading = function(instance)
{
	$('ajax-loader').hide();
}

function setFontSize(action,fontSize) {
	if(fontSize)
	{
		document.body.style.fontSize = fontSize;
	}
	else
	{
		currentSize = parseInt(document.body.style.fontSize);
		if(!currentSize)
			currentSize = 12;

		if((action < 0 && currentSize > 10) || (action > 0 && currentSize < 18))
		{
			document.body.style.fontSize = parseInt(currentSize) + (2 * parseInt(action)) + 'px';
		}
	}

	var expireDays = 50;
	setCookie("fontSizeCookie", document.body.style.fontSize, expireDays);
}

function setCookie(name, value, expireDays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate()+expireDays);
	document.cookie = name + "=" + value + "; expires=" + exdate.toGMTString() + "; 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;
}
