Index: /CKEditor/branches/features/toolbargroup2/_source/plugins/toolbar/plugin.js
===================================================================
--- /CKEditor/branches/features/toolbargroup2/_source/plugins/toolbar/plugin.js	(revision 6716)
+++ /CKEditor/branches/features/toolbargroup2/_source/plugins/toolbar/plugin.js	(revision 6717)
@@ -181,5 +181,7 @@
 						for ( var r = 0 ; r < toolbar.length ; r++ )
 						{
-							var row = toolbar[ r ];
+							var toolbarId,
+								toolbarObj = 0,
+								row = toolbar[ r ];
 
 							// It's better to check if the row object is really
@@ -191,7 +193,4 @@
 								continue;
 
-							var toolbarId = CKEDITOR.tools.getNextId(),
-								toolbarObj = { id : toolbarId, items : [] };
-
 							if ( groupStarted )
 							{
@@ -206,17 +205,4 @@
 							}
 
-							output.push( '<span id="', toolbarId, '" class="cke_toolbar" role="toolbar"><span class="cke_toolbar_start"></span>' );
-
-							// Add the toolbar to the "editor.toolbox.toolbars"
-							// array.
-							var index = toolbars.push( toolbarObj ) - 1;
-
-							// Create the next/previous reference.
-							if ( index > 0 )
-							{
-								toolbarObj.previous = toolbars[ index - 1 ];
-								toolbarObj.previous.next = toolbarObj;
-							}
-
 							// Create all items defined for this toolbar.
 							for ( var i = 0 ; i < row.length ; i++ )
@@ -232,4 +218,28 @@
 								if ( item )
 								{
+									// Initialize the toolbar first, if needed.
+									if ( !toolbarObj )
+									{
+										// Create the basic toolbar object.
+										toolbarId = CKEDITOR.tools.getNextId();
+										toolbarObj = { id : toolbarId, items : [] };
+
+										// Output the toolbar opener.
+										output.push( '<span id="', toolbarId, '" class="cke_toolbar ',
+											( item.canGroup ? 'cke_toolbar_grouped' : 'cke_toolbar_ungrouped' ),
+											'" role="toolbar"><span class="cke_toolbar_start"></span>' );
+
+										// Add the toolbar to the "editor.toolbox.toolbars"
+										// array.
+										var index = toolbars.push( toolbarObj ) - 1;
+
+										// Create the next/previous reference.
+										if ( index > 0 )
+										{
+											toolbarObj.previous = toolbars[ index - 1 ];
+											toolbarObj.previous.next = toolbarObj;
+										}
+									}
+
 									if ( item.canGroup )
 									{
@@ -276,5 +286,6 @@
 							}
 
-							output.push( '<span class="cke_toolbar_end"></span></span>' );
+							if ( toolbarObj )
+								output.push( '<span class="cke_toolbar_end"></span></span>' );
 						}
 
