Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 6252)
+++ /CKEditor/trunk/CHANGES.html	(revision 6253)
@@ -46,4 +46,5 @@
 	<ul>
 		<li><a href="http://dev.ckeditor.com/ticket/5855">#5855</a> : Updating multiple times a full URL in a link generates wrong href.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/6166">#6166</a> : Error on maximize command when the toolbar button is not shown.</li>
 	</ul>
 	<h3>
Index: /CKEditor/trunk/_source/plugins/maximize/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/maximize/plugin.js	(revision 6252)
+++ /CKEditor/trunk/_source/plugins/maximize/plugin.js	(revision 6253)
@@ -284,10 +284,14 @@
 						// Toggle button label.
 						var button = this.uiItems[ 0 ];
-						var label = ( this.state == CKEDITOR.TRISTATE_OFF )
-							? lang.maximize : lang.minimize;
-						var buttonNode = editor.element.getDocument().getById( button._.id );
-						buttonNode.getChild( 1 ).setHtml( label );
-						buttonNode.setAttribute( 'title', label );
-						buttonNode.setAttribute( 'href', 'javascript:void("' + label + '");' );
+						// Only try to change the button if it exists (#6166)
+						if( button )
+						{
+							var label = ( this.state == CKEDITOR.TRISTATE_OFF )
+								? lang.maximize : lang.minimize;
+							var buttonNode = editor.element.getDocument().getById( button._.id );
+							buttonNode.getChild( 1 ).setHtml( label );
+							buttonNode.setAttribute( 'title', label );
+							buttonNode.setAttribute( 'href', 'javascript:void("' + label + '");' );
+						}
 
 						// Restore selection and scroll position in editing area.
