c = new Cookie();
function Cookie()
{
	this.isSet = (document.cookie.toString().length != 0);
	this.isEnabled = navigator.cookieEnabled;
	this.expires = new Date();
	this.path = '';
	this.domain = '';
	this.isSecure = false;
	this.getIsSet = function() { return (document.cookie != ""); }
	this.setExpires = function(date) { this.expires = date; }
	this.setPath = function(path) { this.path = path; }
	this.setDomain = function(domain) { this.domain = domain; }
	this.setSecure = function(secure) { this.isSecure = secure; }
	this.erase = function()
	{
		this.setExpires(new Date(new Date().getTime() - 1000000));
		var cArr = this.getCookieAsArray();
		for(var i in cArr) this.setValue(i, '');
		document.cookie = '';
	}
	this.parse = function()
	{
		var cValues = this.getCookieAsArray();
		for(var i in cValues) eval(i + ' = unescape("' + cValues[i] + '");');
	}
	this.getValue = function(name)
	{
		var cValues = this.getCookieAsArray();
		return cValues[name];
	}
	this.setValue = function(name, value) { document.cookie = name + '=' + escape(value) + '; ' + this.getCookieSettings(); }
	this.getCookieAsArray = function()
	{
		if(!document.cookie.toString().length) return new Array();

		cArr = document.cookie.toString().split('; ');
		var cookieArray = new Array();
		for(var x=0; x<cArr.length; x++)
		{
			if(!cArr[x].length) continue;
			cArr[x] = cArr[x].split("=");
			cookieArray[cArr[x][0].toString()] = unescape(cArr[x][1]);
		}

		return cookieArray;
	}
	this.getCookieSettings = function()
	{
		var str = 'expires=' + this.expires.toGMTString() + '; ';
		if(this.domain.length) str += 'path=' + this.path + '; ';
		if(this.domain.length) str += 'domain=' + this.domain + '; ';
		if(this.isSecure) str += 'secure; ';
		return str;
	}
}
