var Cookie = Class.create();
Cookie.prototype = {
	initialize: function(option) {
		this.option = {
		name:window.location.host,
		path:null,
		domain:null,
		secure:false,
		expires:null
		};
		for (key in option)
			this.option[key] = option[key];	
			
		this.param = new Object();
		this.load();
	},
	
	load: function() {
		if (document.cookie) { 
			var tmp1 = document.cookie + ";";
			var from = tmp1.indexOf(this.option.name + "=");
			if (from != -1) {
				var tmp2 = tmp1.substr(from, tmp1.length - from);
				var cookie = decodeURI(tmp2.substr((this.option.name + "=").length, tmp2.indexOf(";") - (this.option.name + "=").length));
				var params = cookie.split(",");
				for(i = 0; i < params.length; i++) {
					var param = params[i].split("`");
					this.set(param[0], param[1]);
				}
			}
		}
	},
	
	store:function() {
		var cookie ="", value = "";
		
		for (var key in this.param) {
			if (value)
				value += ",";	
			value += key + "`" + this.param[key];
		}
		cookie = this.option.name + "=" + encodeURI(value) + "; ";
		if (this.option.expires)
			cookie += "expires=" + this.option.expires + "; "; 
		cookie += "path=" + ((this.option.path) ? this.option.path : "/")  + "; "; 
		if (this.option.domain)
			cookie += "domain=" + this.option.domain + "; "; 	
		if (this.option.secure)
			cookie += "secure" + "; ";
		document.cookie = cookie;		
	},
	
	get:function(key) {
		if (this.has(key))
			return this.param[key];
		return null;
	},
	
	set:function(key, value) {
		this.param[key] = value;	
	},
	
	has:function(key) {
		var undefined;
		if (this.param[key] === undefined)
			return false;
		return true;		
	}
}





