function rescape(string) { return String(string).replace(rescape.re, "\\$1"); }
rescape.re = /([\/()[\]{}|*+-.,^$?\\])/g;

var Cookie = {
	set: function(name, value, options) {
		options = options || {};
		var a = [name +'='+ value];
		if (options.expires)
			a[a.length] = 'expires='+ new Date(new Date().getTime() + options.expires * 24 * 60 * 60 * 1000).toUTCString();
		if (options.path)
			a[a.length] = 'path='+ options.path;
		if (options.domain)
			a[a.length] = 'domain='+ options.domain;
		if (options.secure)
			a[a.length] = 'secure'
		document.cookie = a.join('; ');
	},
	rem: function(name, options) {
		options = options || {};
		options.expires = -1;
		this.set(name, '', options);
	},
	get: function(name) {
		var res = String(document.cookie).match(new RegExp('\\b'+ rescape(name) +'=([^;]*)'));
		return res && res[1] || null;
	}
};

