tinyMCEPopup.requireLangPack();var SearchReplaceDialog={init:function(d){var f=document.forms[0],e=tinyMCEPopup.getWindowArg("mode");this.switchMode(e);f[e+"_panel_searchstring"].value=tinyMCEPopup.getWindowArg("search_string");f[e+"_panel_searchstring"].focus()},switchMode:function(e){var f,d=this.lastMode;if(d!=e){f=document.forms[0];if(d){f[e+"_panel_searchstring"].value=f[d+"_panel_searchstring"].value;f[e+"_panel_backwardsu"].checked=f[d+"_panel_backwardsu"].checked;f[e+"_panel_backwardsd"].checked=f[d+"_panel_backwardsd"].checked;f[e+"_panel_casesensitivebox"].checked=f[d+"_panel_casesensitivebox"].checked}mcTabs.displayTab(e+"_tab",e+"_panel");document.getElementById("replaceBtn").style.display=(e=="replace")?"inline":"none";document.getElementById("replaceAllBtn").style.display=(e=="replace")?"inline":"none";this.lastMode=e}},searchNext:function(m){var w=tinyMCEPopup.editor,u=w.selection,A=u.getRng(),v,y=this.lastMode,B,r,b=0,f=w.getWin(),a=w.windowManager,s=0;v=document.forms[0];B=v[y+"_panel_searchstring"].value;r=v[y+"_panel_backwardsu"].checked;ca=v[y+"_panel_casesensitivebox"].checked;rs=v.replace_panel_replacestring.value;if(B==""){return}function x(){A=u.getRng().cloneRange();w.getDoc().execCommand("SelectAll",false,null);u.setRng(A)}function z(){if(tinymce.isIE){w.selection.getRng().duplicate().pasteHTML(rs)}else{w.getDoc().execCommand("InsertHTML",false,rs)}}if(ca){b=b|4}switch(m){case"all":w.execCommand("SelectAll");w.selection.collapse(true);if(tinymce.isIE){while(A.findText(B,r?-1:1,b)){A.scrollIntoView();A.select();z();s=1;if(r){A.moveEnd("character",-(rs.length))}}tinyMCEPopup.storeSelection()}else{while(f.find(B,ca,r,false,false,false,false)){z();s=1}}if(s){tinyMCEPopup.alert(w.getLang("searchreplace_dlg.allreplaced"))}else{tinyMCEPopup.alert(w.getLang("searchreplace_dlg.notfound"))}return;case"current":if(!w.selection.isCollapsed()){z()}break}u.collapse(r);A=u.getRng();if(!B){return}if(tinymce.isIE){if(A.findText(B,r?-1:1,b)){A.scrollIntoView();A.select()}else{tinyMCEPopup.alert(w.getLang("searchreplace_dlg.notfound"))}tinyMCEPopup.storeSelection()}else{if(!f.find(B,ca,r,false,false,false,false)){tinyMCEPopup.alert(w.getLang("searchreplace_dlg.notfound"))}else{x()}}}};tinyMCEPopup.onInit.add(SearchReplaceDialog.init,SearchReplaceDialog);