var CookieCore = function(){
	this.cookie_name = "cms_b3studio";
	this.host_url;
	this.path = "/";
	this.expires = 60;
	this.secure = false;
	this.values = null;
	
	this.set = function(key, val) {
		this.load();
		this.values[key] = val;
		this.save();
	}
	
	this.get = function(key) {
		this.load();
		return this.values[key] != 'undefined' ? this.values[key] : null;
	}
	
	this.unset = function(key) {
		this.load();
		if(typeof(this.values) == 'undefined') return;
		delete this.values[key];
		this.save();
	}
	
	this.save = function(){
		$.cookie(this.cookie_name, this.getValues(), {
			expires: this.expires,
			path: this.path,
			domain: this.host_url,
			secure: this.secure
		});
	}
	
	this.reset = function(){
		$.cookie(this.cookie_name, null);
	}
	
	this.load = function(){
		if(this.values != null) return;
		var value = $.cookie(this.cookie_name);
		if(value == null){
			this.values = new Array();
			this.save();
		}else{
			eval("this.values = " + value + ";");
		}
	}
	
	this.getValues = function(){
		var ret = "{";
		var key;
		for(key in this.values){
			if(ret.length > 1){
				ret += ',';
			}
			ret += '"' + key + '":"' + this.values[key] + '"'
		}
		ret += "}";
		return ret;
	}
}
var cmsCookieManager = new CookieCore();
