/**
 * Class to easily manage cookies.
 * @author Ryan Johnson <ryan@livepipe.net>
 * @copyright 2007 LivePipe LLC
 * @package Prototype.Tidbits
 * @license MIT
 * @url http://livepipe.net/projects/prototype_tidbits/
 * @version 1.7.0
 *
 * Additions for Firebug Console and PAMWF interfacing by Michael Morris
 */
PAMWF.Cookie = {

	set: function(name,value,seconds)
	{
		if(seconds)
		{
			d = new Date();
			d.setTime(d.getTime() + (seconds * 1000));
			expiry = '; expires=' + d.toGMTString();
		}
		else
		{
			expiry = '';
		}
			
		document.cookie = name + "=" + value + expiry + "; path=/";
	},

	get: function(name)
	{
		nameEQ = name + "=";
		ca = document.cookie.split(';');

		for(i = 0; i < ca.length; i++)
		{
			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;
	},

	unset: function(name)
	{
		PAMWF.console.info('Unsetting cookie for ' + name );
		Cookie.set(name,'',-1);
	}
};	
	