Index: /CKEditor/branches/prototype/_source/core/config.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/config.js	(revision 2489)
+++ /CKEditor/branches/prototype/_source/core/config.js	(revision 2490)
@@ -159,5 +159,5 @@
 	 * config.plugins = 'elementspath,toolbar,wysiwygarea';
 	 */
-	plugins : 'basicstyles,button,dialog,dialogui,elementspath,htmldataprocessor,keystrokes,sourcearea,tab,toolbar,wysiwygarea',
+	plugins : 'basicstyles,button,dialog,elementspath,htmldataprocessor,keystrokes,sourcearea,tab,toolbar,wysiwygarea',
 
 	/**
Index: /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2489)
+++ /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2490)
@@ -20,5 +20,8 @@
  */
 
-CKEDITOR.plugins.add( 'dialog' );
+CKEDITOR.plugins.add( 'dialog',
+	{
+		requires : [ 'dialogui' ]
+	});
 
 CKEDITOR.DIALOG_RESIZE_NONE = 0;
@@ -64,5 +67,6 @@
 
 	// Initialize the parts map.
-	var element = this._.element.getFirst();
+	var element = this._.element.getFirst(),
+		i;
 	this._.parts = {
 		'tl' : [0,0],
@@ -79,7 +83,7 @@
 		'bridge' : [1,1,2],
 		'contents' : [1,1,3],
-		'buttons' : [1,1,4]
+		'footer' : [1,1,4]
 	};
-	for ( var i in this._.parts )
+	for ( i in this._.parts )
 		this._.parts[i] = element.getChild( this._.parts[i] );
 
@@ -96,5 +100,5 @@
 
 	// Insert the tabs and contents.
-	for ( var i = 0 ; i < definition.contents.length ; i++ )
+	for ( i = 0 ; i < definition.contents.length ; i++ )
 		this.addPage( definition.contents[i] );
 
@@ -115,6 +119,17 @@
 			}, this );
 
+	// Insert buttons.
+	var buttonsHtml = [];
+	CKEDITOR.dialog._.uiElementBuilders.hbox.build( this,
+			{
+				type : 'hbox',
+				className : 'cke_dialog_footer_buttons',
+				widths : [],
+				children : definition.buttons
+			}, buttonsHtml );
+	this._.parts.footer.setHtml( buttonsHtml.join( '' ) );
+
 	CKEDITOR.skins.load( editor.config.skin, 'dialog' );
-}
+};
 
 CKEDITOR.dialog.prototype = 
@@ -131,5 +146,5 @@
 				height : Math.max( height || 0, 0 ) + 'px'
 			} );
-		}
+		};
 
 		// Dialog parts dimensions.
@@ -146,5 +161,5 @@
 			setSize( this, null, width, height );
 			this._.size = { width : width, height : height };
-		}
+		};
 	})(),
 
@@ -206,5 +221,5 @@
 			page,
 			tab,
-			titleHtml = contents.title ? 'title="' + CKEDITOR.tools.htmlEncode( contents.title ) + '" ' : '';
+			titleHtml = contents.title ? 'title="' + CKEDITOR.tools.htmlEncode( contents.title ) + '" ' : '',
 			elements = contents.elements;
 
@@ -269,12 +284,30 @@
 CKEDITOR.tools.extend( CKEDITOR.dialog,
 	{
-		add: function( name, callback )
+		add : function( name, callback )
 		{
 			this._.dialogDefinitions[name] = callback;
 		},
 
-		okButton : null,
-
-		cancelButton : null,
+		okButton : 
+		{
+			type : 'button',
+			label : 'OK',
+			style : 'width: 60px',
+			onClick : function( evt )
+			{
+				evt.data.dialog.hide();
+			}
+		},
+
+		cancelButton :
+		{
+			type : 'button',
+			label : 'Cancel',
+			style : 'width: 60px',
+			onClick : function( evt )
+			{
+				evt.data.dialog.hide();
+			}
+		},
 
 		addUIElement : function( typeName, builder )
@@ -295,6 +328,5 @@
 		buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ],
 		onOk : function(){ alert( 'ok called' ); },
-		onCancel : function(){ alert( 'cancel caled' ); },
-		onLoad : function(){ alert( 'onload called' ); }
+		onCancel : function(){ alert( 'cancel caled' ); }
 	},
 
@@ -418,6 +450,5 @@
 										type : 'button',
 										label : 'Click Me',
-										title : 'Click me plz!',
-										onClick : function() { alert( 'Clicked!' ); } 
+										title : 'Click me plz!'
 									},
 
@@ -448,5 +479,6 @@
 			attributes = ( attributesArg && attributesArg.call ? attributesArg( elementDefinition ) : attributesArg ) || {},
 			innerHTML = ( contentsArg && contentsArg.call ? contentsArg( dialog, elementDefinition ) : contentsArg ) || '',
-			id = this.id = attributes.id || elementDefinition.id || CKEDITOR.tools.getNextNumber() + '_uiElement';
+			id = this.id = attributes.id || elementDefinition.id || CKEDITOR.tools.getNextNumber() + '_uiElement',
+			i;
 
 		// Set the id, a unique id is required for getElement() to work.
@@ -461,5 +493,5 @@
 			classes[ elementDefinition.className ] = 1;
 		var attributeClasses = ( attributes['class'] && attributes['class'].split ) ? attributes['class'].split( ' ' ) : [];
-		for ( var i = 0 ; i < attributeClasses.length ; i++ )
+		for ( i = 0 ; i < attributeClasses.length ; i++ )
 		{
 			if ( attributeClasses[i] )
@@ -467,5 +499,5 @@
 		}
 		var finalClasses = [];
-		for ( var i in classes )
+		for ( i in classes )
 			finalClasses.push( i );
 		attributes['class'] = finalClasses.join( ' ' );
@@ -476,12 +508,17 @@
 
 		// Write the inline CSS styles.
-		var styleStr = [];
-		for ( var i in styles )
+		var styleStr = ( elementDefinition.style || '' ).split( ';' );
+		for ( i in styles )
 			styleStr.push( i + ':' + styles[i] );
+		for ( i = styleStr.length - 1 ; i >= 0 ; i-- )
+		{
+			if ( styleStr[i] === '' )
+				styleStr.splice( i, 1 );
+		}
 		if ( styleStr.length > 0 )
 			attributes.style = ( attributes.style || '' ) + styleStr.join( '; ' );
 
 		// Write the attributes.
-		for ( var i in attributes )
+		for ( i in attributes )
 			html.push( i + '="' + CKEDITOR.tools.htmlEncode( attributes[i] ) + '" ');
 
@@ -497,5 +534,5 @@
 	},
 
-	hbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition, widths, height )
+	hbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition )
 	{
 		if ( arguments.length < 4 )
@@ -505,15 +542,18 @@
 			this._ = {};
 
-		var children = this._.children = childObjList;
+		var children = this._.children = childObjList,
+			widths = elementDefinition && elementDefinition.widths || null,
+			height = elementDefinition && elementDefinition.height || null,
+			i;
 		var innerHTML = function()
 		{
 			var html = [ '<tbody><tr class="cke_dialog_ui_hbox">' ];
-			for ( var i = 0 ; i < childHtmlList.length ; i++ )
+			for ( i = 0 ; i < childHtmlList.length ; i++ )
 			{
 				var className = 'cke_dialog_ui_hbox_child',
 					styles = [];
-				if ( i == 0 )
+				if ( i === 0 )
 					className = 'cke_dialog_ui_hbox_first';
-				else if ( i == childHtmlList.length - 1 )
+				if ( i == childHtmlList.length - 1 )
 					className = 'cke_dialog_ui_hbox_last';
 				html.push( '<td class="', className, '" ' );
@@ -533,9 +573,9 @@
 			html.push( '</tr></tbody>' );
 			return html.join( '' );
-		}
+		};
 		CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type : 'hbox' }, htmlList, 'table', null, null, innerHTML );
 	},
 
-	vbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition, width, heights )
+	vbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition )
 	{
 		if (arguments.length < 3 )
@@ -545,5 +585,7 @@
 			this._ = {};
 
-		var children = this._.children = childObjList;
+		var children = this._.children = childObjList,
+			width = elementDefinition && elementDefinition.width || null,
+			heights = elementDefinition && elementDefinition.heights || null;
 		var innerHTML = function()
 		{
@@ -562,5 +604,5 @@
 			}
 			return html.join( '' );
-		}
+		};
 		CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type : 'vbox' }, htmlList, 'div', null, null, innerHTML );
 	}
Index: /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js	(revision 2489)
+++ /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js	(revision 2490)
@@ -19,5 +19,4 @@
  * == END LICENSE ==
  */
-
 CKEDITOR.plugins.add( 'dialogui' );
 
@@ -42,5 +41,5 @@
 					];
 				return html.join( '' );
-			}
+			};
 			CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'div', null, null, innerHTML );
 		},
@@ -56,5 +55,6 @@
 				id = this._.inputId = attributes.id || elementDefinition.id, 
 				styles = ( stylesArg && stylesArg.call ? stylesArg( elementDefinition ) : stylesArg ) || {},
-				inputContents = ( contentsArg && contentsArg.call ? contentsArg( dialog, elementDefinition) : contentsArg ) || '';
+				inputContents = ( contentsArg && contentsArg.call ? contentsArg( dialog, elementDefinition) : contentsArg ) || '',
+				i;
 
 			// Set the id for the inner input element.
@@ -74,5 +74,5 @@
 				classes[ elementDefinition.className ] = 1;
 			var attributeClasses = ( attributes['class'] && attributes['class'].split ) ? attributes['class'].split( ' ' ) : [];
-			for ( var i = 0 ; i < attributeClasses.length ; i++ )
+			for ( i = 0 ; i < attributeClasses.length ; i++ )
 			{
 				if ( attributeClasses[i] )
@@ -80,5 +80,5 @@
 			}
 			var finalClasses = [];
-			for ( var i in classes )
+			for ( i in classes )
 				finalClasses.push( i );
 			attributes['class'] = finalClasses.join( ' ' );
@@ -90,5 +90,5 @@
 			// Write the inline CSS styles.
 			var styleStr = [];
-			for ( var i in styles )
+			for ( i in styles )
 				styleStr.push( i + ':' + styles[i] );
 			if ( styleStr.length > 0 )
@@ -102,5 +102,5 @@
 				html.push( '>', inputContents, '</input>' );
 				return html.join( '' );
-			}
+			};
 			CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
 		},
@@ -129,5 +129,5 @@
 				html.push( ' ', CKEDITOR.tools.htmlEncode( elementDefinition.label ) );
 				return html.join( '' );
-			}
+			};
 
 			CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'label', null, null, innerHTML );
@@ -178,5 +178,5 @@
 				new CKEDITOR.ui.dialog.hbox( dialog, [], inputHtmlList, html );
 				return html.join( '' );
-			}
+			};
 
 			CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
@@ -195,5 +195,5 @@
 				return [ '<tbody><tr><td class="cke_dialog_ui_button_txt">', CKEDITOR.tools.htmlEncode( elementDefinition.label ),
 					   '</td></tr></tbody>' ].join( '' );
-			}
+			};
 
 			// Add OnClick event to this input.
@@ -208,5 +208,20 @@
 						if ( !eventInfo.data.buttonHandlerRegistered )
 						{
-							dialog.getElement().on( 'mouseup', function( evt )
+							dialog.getElement().on( 'mousedown', function( evt )
+								{
+									var target = evt.data.getTarget();
+
+									// If we aren't inside an inactive button, bail out.
+									if ( target.getName() != 'td' || target.$.className.search( 'cke_dialog_ui_button_txt' ) == -1 )
+										return;
+
+									// Change styles to indicate the button is being clicked.
+									target.addClass( 'cke_dialog_ui_button_active' );
+
+									// Store the currently active button.
+									CKEDITOR.ui.dialog.button._.activeButton = target;
+								});
+
+							CKEDITOR.document.on( 'mouseup', function( evt )
 								{
 									var target = evt.data.getTarget();
@@ -222,29 +237,15 @@
 									// active button is the same as target.
 									if ( CKEDITOR.ui.dialog.button._.activeButton.$ == target.$ )
-										me.fire( 'click' );
+										me.fire( 'click', { dialog : dialog } );
 
 									// Clear active button flag.
-									CKEDITOR.ui.dialog.button.activeButton = null;
+									CKEDITOR.ui.dialog.button._.activeButton = null;
 								});
 
-							dialog.getElement().on( 'mousedown', function( evt )
-								{
-									var target = evt.data.getTarget();
-
-									// If we aren't inside an inactive button, bail out.
-									if ( target.getName() != 'td' || target.$.className.search( 'cke_dialog_ui_button_txt' ) == -1 )
-										return;
-
-									// Change styles to indicate the button is being clicked.
-									target.addClass( 'cke_dialog_ui_button_active' );
-
-									// Store the currently active button.
-									CKEDITOR.ui.dialog.button._.activeButton = target;
-								});
 							eventInfo.data.buttonHandlerRegistered = true;
 						}
 
 						this.getElement().unselectable();
-					}, this);
+					}, this );
 
 			CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'table', null, null, innerHTML );
Index: /CKEditor/branches/prototype/_source/skins/default/dialog.css
===================================================================
--- /CKEditor/branches/prototype/_source/skins/default/dialog.css	(revision 2489)
+++ /CKEditor/branches/prototype/_source/skins/default/dialog.css	(revision 2490)
@@ -193,5 +193,5 @@
 }
 
-.cke_skin_default .cke_dialog_buttons
+.cke_skin_default .cke_dialog_footer
 {
 	position: absolute;
@@ -312,2 +312,10 @@
 	font-weight: bold;
 }
+
+.cke_skin_default .cke_dialog_footer_buttons
+{
+	width: auto;
+	position: absolute;
+	right: 10px;
+	top: 7px;
+}
Index: /CKEditor/branches/prototype/_source/themes/default/theme.js
===================================================================
--- /CKEditor/branches/prototype/_source/themes/default/theme.js	(revision 2489)
+++ /CKEditor/branches/prototype/_source/themes/default/theme.js	(revision 2490)
@@ -118,5 +118,5 @@
 							'<div id="cke_dialog_tabs_bridge_%d" class="cke_dialog_tabs_bridge"></div>',
 							'<div id="cke_dialog_contents_%d" class="cke_dialog_contents"></div>',
-							'<div id="cke_dialog_buttons_%d" class="cke_dialog_buttons"></div>',
+							'<div id="cke_dialog_footer_%d" class="cke_dialog_footer"></div>',
 						'</div>',
 						'<div id="cke_dialog_r_%d" class="cke_dialog_r"></div>',
