var VisibilityArea = {
	known_area_ids: Object(),

	registerArea: function(name, id) {
		if(!name) {
			alert("Name not set, can't register Toggle Visibility Area with id '"+id+"'");
			return;
		}

		if (!VisibilityArea.known_area_ids[name]) {
			VisibilityArea.known_area_ids[name] = new Array();
		}

		VisibilityArea.known_area_ids[name].push(id);
	},

	show: function(name) {
		if(!name) {
			for(var key in VisibilityArea.known_area_ids) {
				VisibilityArea.show_intern(key);
			}
		} else {
			VisibilityArea.show_intern(name);
		}
	},

	show_intern: function(name) {
		var ids = VisibilityArea.known_area_ids[name];
		if(!ids) return;
		if(!ids.length) return;
		for(var i=0; i<ids.length; i++) {
			var current_area = document.getElementById(ids[i]);
			if(current_area) current_area.style.display = 'block';
		}
	},

	hide: function(name) {
		if(!name) {
			for(var key in VisibilityArea.known_area_ids) {
				VisibilityArea.hide_intern(key);
			}
		} else {
			VisibilityArea.hide_intern(name);
		}
	},

	hide_intern: function(name) {
		var ids = VisibilityArea.known_area_ids[name];
		if(!ids) return;
		if(!ids.length) return;
		for(var i=0; i<ids.length; i++) {
			var current_area = document.getElementById(ids[i]);
			if(current_area) current_area.style.display = 'none';
		}
	},

	toggle: function(name) {
		if(!name) {
			for(var key in VisibilityArea.known_area_ids) {
				VisibilityArea.toggle_intern(key);
			}
		} else {
			VisibilityArea.toggle_intern(name);
		}
	},

	toggle_intern: function(name) {
		var ids = VisibilityArea.known_area_ids[name];
		if(!ids) return;
		if(!ids.length) return;
		for(var i=0; i<ids.length; i++) {
			var current_area = document.getElementById(ids[i]);
			if(current_area) {
				if(current_area.style.display == 'none') {
					current_area.style.display = 'block';
				} else {
					current_area.style.display = 'none';
				}
			}
		}
	}
}

