/**
* Script is used to manipulate cookies.
*
* @version 1.3
* @title ObjectCookie
* @author Ilya Lebedev ilya@lebedev.net, (c) 2004,2005

((expire == null) ? "" : ";NoExp=" + ('Sun, 09-May-2100 20:00:00 GMT')) +
*
**/

var Cookie = Class.create();
Cookie.prototype = {
	REVISION : 1.3,          // script revision
	c        : {},           // hash of cookies

	initialize : function() {
		if ("" != document.cookie) {
			var p = document.cookie.split(/\s*;\s*/);
			var pL = p.length;
			for (i=0;i<pL;i++) {
				var parts = p[i].split(/\s*=\s*/);
				this.c[parts[0]] = parts[1]?unescape(parts[1]):"";
			}
		}
	},
	
	get : function (name) {
		return this.c[name]?this.c[name]:false;
	},
	
	//document.cookie = "vn"+id+"=N; expires=Thu, 31 Dec 2020 23:59:59 GMT; path=/;";
	set : function (name, value, expire, path, domain, secure) {
		if (""!=name) {
			document.cookie = name + "=" + escape(value) +
			((path == null) ? "" : ";path=" + path) +
			((expire == null) ? "" : ";expires=" + ((typeof(expire) == 'object') ? expire.toGMTString() : new Date(new Date().getTime() + expire * 1000).toGMTString())) +
			((domain == null) ? "" : ";domain=" + domain) +
			((secure == null) ? "" : ";secure");
			this.c[name] = escape(value);
			return true;
		}
		return false;
	},
	
	isSet : function (name) {
		return this.c[name]?true:false;
	},
	
	del : function (name,path,domain) {
		if (this.isSet(name)) {
			document.cookie = name + "=" +
			((path == null) ? "" : "; path=" + path) +
			((domain == null) ? "" : "; domain=" + domain) +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
			delete this.c[name];
			return true;
		}
		return false;
	},
	
	delAll : function () {
		var i;
		for (i in this.c) {
			this.del(i);
		}
		return true;
	}
}
