
// Thanks to www.quirksmode.org for the cookie scripts!

/** Instantiate cookie management object */
var Cookies = {};

/** Create a cookie using a name-value pair
* @param string Name of cookie
* @param string Value to save
* @param int Number of days before expiry
* @returns void */
Cookies.Write = function(name, value, days)
{
	var expires = "";
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime() + (days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+value+expires+"; path=/";
};

/** Read and return the value of a cookie
* @param string Name of cookie
* @returns string */
Cookies.Read = function(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;
};

/** Delete a given cookie
* @param string Name of cookie
* @returns void */
Cookies.Delete = function(name)
{
	Cookies.Write(name, "" , -1);
}


//=============================================================================================================

/** Delete a given cookie
* @param string Name of cookie
* @returns void */
function ApplyNewTextSize(size)
{
	if ((size == 'huge') || (size == 'large'))
	{
		Cookies.Write('text_size', size, 7);
		document.body.className = 'text_'+size;
	}
	else
	{
		Cookies.Write('text_size', 'normal', 7);
		document.body.className = '';
	}
	
	if (window.matchHeights)
	{
		window.matchHeights(true);
		window.matchHeights();
	}
	
	return true;
};

