Index: /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckstyle.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckstyle.js	(revision 1268)
+++ /FCKeditor/branches/features/floating_dialog/editor/_source/classes/fckstyle.js	(revision 1269)
@@ -112,5 +112,5 @@
 		}
 
-		this.ApplyToRange( range, selectIt ) ;
+		return this.ApplyToRange( range, selectIt ) ;
 	},
 
@@ -276,5 +276,5 @@
 				range.SelectBookmark( bookmark ) ;
 
-			return ;
+			return bookmark ;
 		}
 
@@ -401,4 +401,6 @@
 		if ( selectIt )
 			range.SelectBookmark( bookmark ) ;
+
+		return bookmark ;
 	},
 
@@ -968,4 +970,6 @@
 		if ( selectIt )
 			range.SelectBookmark( bookmark ) ;
+
+		return bookmark ;
 	},
 
Index: /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html
===================================================================
--- /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html	(revision 1268)
+++ /FCKeditor/branches/features/floating_dialog/editor/dialog/fck_replace.html	(revision 1269)
@@ -52,4 +52,33 @@
 }
 
+// Place a range at the start of document.
+// This will be the starting point of our search.
+var GlobalRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
+GlobalRange.SetStart( oEditor.FCK.EditorDocument.body, 1 ) ;
+GlobalRange.SetEnd( oEditor.FCK.EditorDocument.body, 1 ) ;
+GlobalRange.Collapse( true ) ;
+
+var HighlightRange = null ;
+function Highlight()
+{
+	if ( HighlightRange )
+		ClearHighlight() ;
+	var bookmark = oEditor.FCKStyles.GetStyle( '_FCK_FindAndReplaceHighlight' ).ApplyToRange( GlobalRange.Clone() ) ;
+	HighlightRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
+	HighlightRange.MoveToBookmark( bookmark ) ;
+	GlobalRange = HighlightRange.Clone() ;
+}
+
+function ClearHighlight()
+{
+	if ( HighlightRange )
+	{
+		var bookmark = oEditor.FCKStyles.GetStyle( '_FCK_FindAndReplaceHighlight' ).RemoveFromRange( HighlightRange ) ;
+		var dummyRange = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
+		dummyRange.MoveToBookmark( bookmark ) ;
+		HighlightRange = null ;
+	}
+}
+
 function OnLoad()
 {
@@ -57,12 +86,4 @@
 	oEditor.FCKLanguageManager.TranslatePage( document ) ;
 
-	// Place the cursor at the start of document.
-	// This will be the starting point of our search.
-	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	range.SetStart( oEditor.FCK.EditorDocument.body, 1 ) ;
-	range.SetEnd( oEditor.FCK.EditorDocument.body, 1 ) ;
-	range.Collapse( true ) ;
-	range.Select() ;
-
 	// Show the appropriate tab at startup.
 	if ( dialogArguments.CustomValue == 'Find' )
@@ -73,4 +94,6 @@
 	else
 		dialog.SetSelectedTab( 'Replace' ) ;
+
+	SelectField( 'txtFind' + dialogArguments.CustomValue ) ;
 }
 
@@ -81,13 +104,4 @@
 			document.getElementById('btnFind').disabled =
 				( document.getElementById(idMap["FindText"]).value.length == 0 ) ;
-}
-
-function GetSelection()
-{
-	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-
-	dialog.EnsureSelection() ;
-	range.MoveToSelection() ;
-	return range.CreateBookmark2() ;
 }
 
@@ -266,5 +280,5 @@
 	// Start from the end of the current selection.
 	var matcher = new KmpMatch( GetSearchString(), ! GetCheckCase() ) ;
-	var cursor = GetSelection().End ;
+	var cursor = GlobalRange.CreateBookmark2().End ;
 	var matchState = KMP_NOMATCH ;
 	var matchBookmark = null ;
@@ -346,11 +360,10 @@
 	}
 
-	// If we've found a match, select the match.
+	// If we've found a match, highlight the match.
 	if ( matchState == KMP_MATCHED )
 	{
-		var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-		range.MoveToBookmark2( matchBookmark ) ;
-		range.Select() ;
-		var focus = range._Range.endContainer ;
+		GlobalRange.MoveToBookmark2( matchBookmark ) ;
+		Highlight() ;
+		var focus = GlobalRange._Range.endContainer ;
 		while ( focus && focus.nodeType != 1 )
 			focus = focus.parentNode ;
@@ -372,32 +385,27 @@
 function Find()
 {
-	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	dialog.EnsureSelection() ;
-	range.MoveToSelection() ;
-	range.Collapse( false ) ;
-	range.Select() ;
-
 	if ( ! _Find() )
+	{
+		ClearHighlight() ;
 		alert( FCKLang.DlgFindNotFoundMsg ) ;
+	}
 }
 
 function Replace()
 {
-	var selection = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-	dialog.EnsureSelection() ;
-	selection.MoveToSelection() ;
-
-	if ( selection.CheckIsCollapsed() )
+	if ( GlobalRange.CheckIsCollapsed() )
 	{
 		if (! _Find() )
+		{
+			ClearHighlight() ;
 			alert( FCKLang.DlgFindNotFoundMsg ) ;
+		}
 	}
 	else
 	{
 		oEditor.FCKUndo.SaveUndoStep() ;
-		selection.DeleteContents() ;
-		selection.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
-		selection.Collapse( false ) ;
-		selection.Select() ;
+		GlobalRange.DeleteContents() ;
+		GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
+		GlobalRange.Collapse( false ) ;
 	}
 }
@@ -406,6 +414,4 @@
 {
 	oEditor.FCKUndo.SaveUndoStep() ;
-	var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
-
 	var replaceCount = 0 ;
 
@@ -413,15 +419,18 @@
 	{
 		dialog.EnsureSelection() ;
-		range.MoveToSelection() ;
-		range.DeleteContents() ;
-		range.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
-		range.Collapse( false ) ;
-		range.Select() ;
+		GlobalRange.DeleteContents() ;
+		GlobalRange.InsertNode( oEditor.FCK.EditorDocument.createTextNode( GetReplaceString() ) ) ;
+		GlobalRange.Collapse( false ) ;
 		replaceCount++ ;
 	}
 	if ( replaceCount == 0 )
+	{
+		ClearHighlight() ;
 		alert( FCKLang.DlgFindNotFoundMsg ) ;
+	}
 	dialog.Cancel() ;
 }
+
+window.onunload = function(){ ClearHighlight() ; }
 	</script>
 </head>
Index: /FCKeditor/branches/features/floating_dialog/fckconfig.js
===================================================================
--- /FCKeditor/branches/features/floating_dialog/fckconfig.js	(revision 1268)
+++ /FCKeditor/branches/features/floating_dialog/fckconfig.js	(revision 1269)
@@ -240,5 +240,7 @@
 	},
 	
-	'BackColor'		: { Element : 'span', Styles : { 'background-color' : '#("Color","color")' } }
+	'BackColor'		: { Element : 'span', Styles : { 'background-color' : '#("Color","color")' } },
+
+	'FindAndReplaceHighlight' : { Element : 'span', Styles : { 'background-color' : 'navy', 'color' : 'white' } }
 };
 
