CP = {};
Window.addEvent('domready', function() {
	with(CP) {
		var HashCookie = new MooHash.Cookie('CP_Settings', {duration: 3650});
		var PanelItems = $$('#Panel h2');
		var QuickRef = {};
		
		PanelItems.each(function(item) {
			if(Exceptions.contains(item.getText().toLowerCase())) return;
			item.setStyle('cursor', 'pointer');
			item._effect = new Fx.Slide(item.getNext(), {duration: 500});
			item._state = (Default == 'Closed') ? false : true;
			if(!item._state) item._effect.hide();
			item.addEvent('click', function() {
				if(!this._state) {
					this._effect.slideIn();
					this._state = true;
				} else {
					this._effect.slideOut();
					this._state = false;
				}
				var Id = item.getText();
				HashCookie.set(Id, this._state);
			}.bind(item));
			
			QuickRef[item.getText()] = item;
		});
		
		HashCookie.each(function(val, key) {
			var el = QuickRef[key];
			if(!el) return;
			if(!val) el._effect.hide();
			else el._effect.show();
			el._state = val;
		});
	}
});
