function Cookie(docObj, objName, expDate, path, domain, secure) {
	this.$document = docObj;
	this.$name = objName;
	if (expDate) this.$expiration = expDate;
	else this.$expiration = null;
	if (path) this.$path = path; else this.$path = null;
	if (domain) this.$domain = domain; else this.$domain = null;
	if (secure) this.$secure = true; else this.$secure = false;
}

/*
This cookie calculates by the hour (whenExp * 360000)

Timing Reference
1000 		= 1 sec. (1000)
60000		= 1 min. (60 * 1000)
3600000		= 1 hr.  (60 * 60 * 1000)
86400000	= 1 day  (24 * 60 * 60 * 1000)
604800000	= 1 week (7 * 24 * 60 * 60 * 1000)
*/

function _cookie_set(val) {
	var cookieval = "";
	for (var prop in this) {
		if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) continue;
		if (cookieval != "") cookieval += '&';
		cookieval += prop + ':' + escape(this[prop]);
		}

	if (val) cookieval = val + "&" + cookieval;
	var cookie = this.$name + '=' + cookieval;
	if (this.$expiration) cookie += '; expires=' + this.$expiration.toGMTString();
	if (this.$path) cookie += '; path=' + this.$path;
	if (this.$domain) cookie += '; domain=' + this.$domain;
	if (this.$secure) cookie += '; secure';

	this.$document.cookie = cookie;
}

function _cookie_get() {
	var allcookies = this.$document.cookie;
	if (allcookies == "") return false;

	var start = allcookies.indexOf(this.$name + '=' );
	if (start == -1) return false; //cookie not defined for this page
	start += this.$name.length + 1; //skip name and equals sign
	var end = allcookies.indexOf(';', start);
	if (end == -1) end = allcookies.length;
	var cookieval = allcookies.substring(start, end);

	var a = cookieval.split('&'); //break into array of name/value pairs
	for(var i=0; i < a.length; i++) //break each pair into an array
		a[i] = a[i].split(':');

	for(var i = 0; i < a.length; i++) {
		this[a[i][0]] = unescape(a[i][1]);
	}

	return true;
}

function _cookie_kill() {
	var cookie;
	cookie = this.$name + '=';
	if (this.$path) cookie += '; path=' + this.$path;
	if (this.$domain) cookie += '; domain=' + this.$domain;
	cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
	this.$document.cookie = cookie;
}

new Cookie();
Cookie.prototype.set = _cookie_set;
Cookie.prototype.get = _cookie_get;
Cookie.prototype.kill = _cookie_kill;

//alert ("cookieClass loaded");
