/*****************
Borrowed by Chris Mendis from Peter-Paul Koch on 23 February 2007.
Source: http://www.quirksmode.org/js/cookies.html
*****************/

var Cookies = {
	/*****
	creatCookie() writes a cookie name/value pair to the current HTML document.
	
	PARAMETERS
	name: A String that represents the cookie's name.
	value: A String that represents the cookie's value.
	days: The Number that represents the number of days before the cookie should expire.
	
	RETURNS
	Nothing.
	*****/
	createCookie: function(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=/";
	},

	/*****
	readCookie() attempts to return the value of a cookie.
	
	PARAMETERS
	name: A String the represents the name of the cookie to retrieve.
	
	RETURNS
	A String that represents the named cookie's value or null if the named cookie is non-existent.
	*****/
	readCookie: 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;
	},

	/*****
	eraseCookie() causes a cookie to immediately expire.
	
	PARAMETERS
	name: A String that represents the name of the cookie to immediately expire.
	
	RETURNS
	Nothing.
	
	NOTES
	If a nonexistent cookie is passed to eraseCookie(), it will effectively be created
	and then immediately expired.
	*****/
	eraseCookie: function(name) {
		createCookie(name,"",-1);
	}
};
