/**
 * 
 * $Id: cookies.js 3604 2009-08-13 17:24:51Z tpuhlick $
 *
 * @author Chris Lewis <clewis@ocenture.com>
 */

var Cookies = {
	
	set: function(name, value, expiredays, path) {
		var exdate = new Date();
		exdate.setDate(exdate.getDate() + expiredays);
		
		var cString = name + "=" + escape(value) +
			((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
		
		if(path == null) path = "/";
		document.cookie = cString + '; path=' + path;
	},
		
	get: function(name) {
		if(document.cookie.length > 0) {
			c_start=document.cookie.indexOf(name + "=");
			if (c_start!=-1) { 
				c_start=c_start + name.length+1; 
				c_end=document.cookie.indexOf(";",c_start);
				if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
			} 
		}
		return null;
	},
	
	remove: function(name) {
		var lastValue = this.get(name);
		this.set(name, "", -1);
		return lastValue;
	}
	
}