var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

var COOKIEJS = true;

var Cookie = Class.create();
Cookie.prototype = {
	version : '0.3',
	name : '',
	life : '',
	path : '',
	doma : '',
	valu : '',
	value : function() {
		if (arguments[0]) {
			this.valu = arguments[0];
			this.update();
		}
		else {
			var start = document.cookie.indexOf(this.name+'=');
			var len = start+this.name.length+1;
			if ((!start) && (this.name != document.cookie.substring(0,this.name.length))) return null;
			if (start == -1) return null;
			var end = document.cookie.indexOf(';',len);
			if (end == -1) end = document.cookie.length;
			this.valu = unescape(document.cookie.substring(len,end));
			return (this.valu == 'undefined')?('[NO COOKIE]'):(this.valu);
		}
	},
	lifetime : function() {
		if (arguments[0]) {
			this.life = arguments[0];
			this.update();
		} else {
			return (this.life == '')?('[NO LIFETIME SET]'):(this.life);
		}
	},
	destroy : function() {
		this.life = 0;
		this.update();
	},
	update : function() {
		var date = new Date();
		date.setTime(date.getTime()+(this.life*24*60*60*1000));
		document.cookie = this.name + '=' +escape(this.valu) +
		( (this.life) ? (';expires=' + date.toGMTString()) : ('') ) +
		( (this.path) ? (';path=' + this.path) : ('') ) +
		( (this.doma) ? (';domain=' + this.doma) : ('') );
	},
	initialize: function() {
		this.name = arguments[0];
		this.life = arguments[1];
		this.path = arguments[2];
		this.doma = (document.layers)?('.'+arguments[3]):(arguments[3]);
		this.valu = this.value();
	}
}