<!-- EN N-Go. 15/10/2009. Some Prototype functions to do various things. // -->

<!-- Watch the onload and set the base css font size. This is extended to allow a simple image re-size routine. //--> 

<!--
	//
	//	Some cookie read/write stuff. Probably has loads already and 
	//	prototype offers some, but these are old and reliable...
	//
-->

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 
	{
		var 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;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}

<!-- 
	//
	//	This sets a base font size or loads it from a pre-selected cookie. 
	//	It also allows the setting of a cookie from a previous selection... wurd.
	//	
-->
	
Event.observe(window, 'load', function() 
{  
	if (readCookie('fontsize') == null)
	{
		setBaseCSS(0.9);
	}
	else
	{
		var size = readCookie('fontsize');
		setBaseCSS(size);
	}
});

function setBaseCSS(sizeme)
{
	var sSize = sizeme+"em";
	$('app').style.fontSize = sSize;
	createCookie('fontsize', sizeme, 30);
}