/**
 * jQuery simple cookie plugin by Christopher Thorn:
 * 				- ( a method "jQuery.cookie" accepting 3 parameters: cookieName [, cookieValue] [, daysTilExpiration] )
 *				- ( a method "jQuery.cookie" accepting 2 parameters: cookieName, {erase:true} )
 *				- ( a method "jQuery.cookie" accepting 1 parameter: cookieName; returning cookieValue )
 **/
// main closure so the global namespace is not polluted:
;(function($)
{
	// these three functions were found on the internets and encapsulated with a closure and a privileged jQuery method:
	
	// private createCookie
	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=/";
	};
	
	// private readCookie
	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;
	};
	
	// private eraseCookie
	function eraseCookie(name)
	{
		createCookie(name,"",-1);
	};
	
	// public privileged jQuery.cookie (takes the three forms described above)
	$.cookie = function()
	{
		var a=arguments;
		if(a[1] && a[1].erase)
			return eraseCookie(a[0]);
		
		else if(a.length > 1)
			return createCookie(a[0], a[1], a[2]);
		else
			return readCookie(a[0]);
	};
	
})
(/*powered by*/ jQuery);