$.fn.regionManager = function(params) {
	var defaults = {
		state:'hide',
		content:'',
		resetContent:false
	};
	
	if(params) {
		$.extend(defaults, params);
	}


	return this.each(function() {
		// Unless we are told to hide, show the panel
		if(defaults.state == 'hide') {
			$(this).hide();
		}
		else {
			//hide the regions
			$(this).find("[@xregion]").hide();
			
			if(defaults.resetContent) {
				$(this).find("[@xregion=" + defaults.state + "]").html('');
			}
			
			if(defaults.content.length > 0) {
				$(this).find("[@xregion=" + defaults.state + "]").html(defaults.content);
			}

			//Show the specified region
			$(this).find("[@xregion=" + defaults.state + "]").show();
			
			// in any other state, make the panel visible
			$(this).show();
		}
	});
	
	return this;
};

