Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 4605)
+++ /CKEditor/trunk/CHANGES.html	(revision 4606)
@@ -87,4 +87,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/4725">#4725</a> : Fixed hitting 'enter' before html comment node produces an JavaScript error.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4522">#4522</a> : Fixed unable to redo when typing after insert an image with relative url.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/4594">#4594</a> : Fixed context menu goes off-screen when mouse is at right had side of screen.</li>
 	</ul>
 	<h3>
Index: /CKEditor/trunk/_source/plugins/floatpanel/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/floatpanel/plugin.js	(revision 4605)
+++ /CKEditor/trunk/_source/plugins/floatpanel/plugin.js	(revision 4606)
@@ -132,5 +132,4 @@
 						top : top + 'px',
 						left : '-3000px',
-						visibility : 'hidden',
 						opacity : '0',	// FF3 is ignoring "visibility"
 						display	: ''
@@ -192,14 +191,7 @@
 							left -= element.$.offsetWidth;
 
-						element.setStyles(
-							{
-								left : left + 'px',
-								visibility	: '',
-								opacity : '1'	// FF3 is ignoring "visibility"
-							});
-
-						if ( block.autoSize )
+						var panelLoad = CKEDITOR.tools.bind( function ()
 						{
-							function setHeight()
+							if ( block.autoSize )
 							{
 								var target = element.getFirst();
@@ -217,14 +209,38 @@
 								panel._.currentBlock.element.setStyle( 'display', 'none' ).removeStyle( 'display' );
 							}
-
-							if ( panel.isLoaded )
-								setHeight();
 							else
-								panel.onLoad = setHeight;
-						}
-						else
-							element.getFirst().removeStyle( 'height' );
-
-						// Set the IFrame focus, so the blur event gets fired.
+								element.getFirst().removeStyle( 'height' );
+
+							var panelElement = panel.element,
+								panelWindow = panelElement.getWindow(),
+								windowScroll = panelWindow.getScrollPosition(),
+								viewportSize = panelWindow.getViewPaneSize(),
+								panelSize =
+								{
+									'height' : panelElement.$.offsetHeight,
+									'width' : panelElement.$.offsetWidth
+								};
+
+							// If the menu is horizontal off, shift it toward
+							// the opposite language direction.
+							if ( rtl ? left < 0 : left + panelSize.width > viewportSize.width + windowScroll.x )
+								left += ( panelSize.width * ( rtl ? 1 : -1 ) );
+
+							// Vertical off screen is simpler.
+							if( top + panelSize.height > viewportSize.height + windowScroll.y )
+								top -= panelSize.height;
+
+							element.setStyles(
+								{
+									top : top + 'px',
+									left : left + 'px',
+									opacity : '1'
+								} );
+
+						} , this );
+
+						panel.isLoaded ? panelLoad() : panel.onLoad = panelLoad;
+
+						// Set the panel frame focus, so the blur event gets fired.
 						CKEDITOR.tools.setTimeout( function()
 							{
@@ -240,10 +256,9 @@
 									}
 								}
-								
+
 								iframe.$.contentWindow.focus();
-
 								// We need this get fired manually because of unfired focus() function.
-								if ( CKEDITOR.env.ie && !CKEDITOR.env.quirks )
-									this.allowBlur( true );
+								this.allowBlur( true );
+
 							}, 0, this);
 					}, 0, this);
