(function($) {
	$.widget("ui.box", {

		_create: function() {
			var box = this.element;
			box
				.addClass("ui-widget ui-widget-content ui-corner-all")
				.css("padding", ".2em");

			var content = $('<div>&nbsp;</div>')
				.addClass("ui-widget-content ui-corner-bottom")
				.css('padding', '.5em 1em')
				.css('border', '0')
				.html(box.html());

			box.html(content);

			if (!box.attr('title') && !content.children("#title").html()) {
				return;
			}
			
			var titlebar = $('<div></div>')
				.addClass("ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-top")
				.css('padding', '.3em')
				.html(box.attr('title'))
				.prependTo(box);

			if (content.children("#title")) {
				titlebar.prepend(content.children("#title"));
			}
		}

	});
})(jQuery);
