$.ui.component.subclass('ui.panel', {
	_init: function() {
		var self = this, 
			options = this.options, 
			panel = this.panel = self.element, 
			panelHeader = this.panelHeader = panel.find(' > .' + options.headerClass), 
			panelBody = this.panelBody = panel.find('> .' + options.bodyClass), 
			panelBodyFieldSet = this.panelBodyFieldSet = panelBody.find('.' + options.bodyFieldSetClass), 
			panelBodyFieldSetContent = this.panelBodyFieldSetContent = panelBodyFieldSet.find('.' + options.bodyFieldSetContentClass), 
			panelBodyButtonSet = this.panelBodyButtonSet = panelBody.find('.' + options.bodyButtonSetClass), 
			panelFooter = this.panelFooter = panel.find('> .' + options.footerClass);
		this.create();
	}, 
	hide: function(event) {
		if (this.options.dialog) this.panel.dialog('close');
		this.panel.hide();
	}, 
	show: function(event) {
		if (this.options.dialog) this.panel.dialog('open');
		this.panel.show();
	}, 
	close: function() {
		this.hide();
	}, 
	create: function(event) {
		this.createHeader();
		this.createBody();
		if (this.options.dialog) panel.dialog();
	}, 
	destroy: function(event) {
		if (this.options.dialog) this.panel.dialog('destroy');
		this.destroyBody();
		this.destroyHeader();
	}, 
	getBodyObject: function(selector) {
		return this.panelBody.find(selector);
	}, 
	// Header
	createHeader: function() {
		var self = this;
		this.panelHeader.find('.close').each(function() {
			$(this).unbind('click');
			$(this).bind('click', function() {self.close();});
		});
	}, 
	destroyHeader: function() {
		this.panelHeader.find('.close').each(function() {$(this).unbind('click');});
	}, 
	// Body
	createBody: function() {
		this.createFieldSet();
		this.createButtonSet();
	}, 
	destroyBody: function() {
		this.destroyButtonSet();
		this.destroyFieldSet();
	}, 
	// FieldSet
	createFieldSet: function() {}, 
	destroyFieldSet: function() {}, 
	recreateFieldSet: function(content) {
		this.destroyFieldSet();
		this.panelBodyFieldSetContent.html(content);
		this.createFieldSet();
	}, 
	// Button Set
	createButtonSet: function() {
		var self = this;
		this.panelBodyButtonSet.find('.close').each(function() {
			$(this).bind('click', function() {self.close(); return false;});
		});
	}, 
	destroyButtonSet: function() {
		this.panelBodyButtonSet.find('.close').each(function() {$(this).unbind('click');});
	}
});
$.ui.panel.defaults.extend(
	{
		headerClass: 'panel-header', 
		bodyClass: 'panel-body', 
		bodyFieldSetClass: 'panel-body-fieldset', 
		bodyFieldSetContentClass: 'panel-body-fieldset-content', 
		bodyButtonSetClass: 'panel-body-buttonset', 
		footerClass: 'panel-footer', 
		dialog: false
	}
);