tinyMCE.importPluginLanguagePack('spellchecker','en,fr,sv,nn,nb');var TinyMCE_SpellCheckerPlugin={_contextMenu:new TinyMCE_Menu(),_menu:new TinyMCE_Menu(),_counter:0,_ajaxPage:'/tinyspell.php',getInfo:function(){return{longname:'Spellchecker',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},handleEvent:function(e){var elm=tinyMCE.isMSIE?e.srcElement:e.target;var inst=tinyMCE.selectedInstance,args='';var self=TinyMCE_SpellCheckerPlugin;var cm=self._contextMenu;var p,p2,x,y,sx,sy,h,elm;if((e.type=="click"||e.type=="contextmenu")&&elm){do{if(tinyMCE.getAttrib(elm,'class')=="mceItemHiddenSpellWord"){inst.spellCheckerElm=elm;args+='id='+inst.editorId+"|"+(++self._counter);args+='&cmd=suggest&check='+encodeURIComponent(elm.innerHTML);args+='&lang='+escape(inst.spellCheckerLang);elm=inst.spellCheckerElm;p=tinyMCE.getAbsPosition(inst.iframeElement);p2=tinyMCE.getAbsPosition(elm);h=parseInt(elm.offsetHeight);sx=inst.getBody().scrollLeft;sy=inst.getBody().scrollTop;x=p.absLeft+p2.absLeft-sx;y=p.absTop+p2.absTop-sy+h;cm.clear();cm.addTitle(tinyMCE.getLang('lang_spellchecker_wait','',true));cm.show();cm.moveTo(x,y);inst.selection.selectNode(elm,false,false);self._sendAjax(self.baseURL+self._ajaxPage,self._ajaxResponse,'post',args);tinyMCE.cancelEvent(e);return false;}}while((elm=elm.parentNode));}return true;},initInstance:function(inst){var self=TinyMCE_SpellCheckerPlugin,m=self._menu,cm=self._contextMenu,e;tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/plugins/spellchecker/css/content.css");if(!tinyMCE.hasMenu('spellcheckercontextmenu')){tinyMCE.importCSS(document,tinyMCE.baseURL+"/plugins/spellchecker/css/spellchecker.css");cm.init({drop_menu:false});tinyMCE.addMenu('spellcheckercontextmenu',cm);}if(!tinyMCE.hasMenu('spellcheckermenu')){m.init({});tinyMCE.addMenu('spellcheckermenu',m);}inst.spellCheckerLang='en';self._buildSettingsMenu(inst,null);e=self._getBlockBoxLayer(inst).create('div','mceBlockBox',document.getElementById(inst.editorId+'_parent'));self._getMsgBoxLayer(inst).create('div','mceMsgBox',document.getElementById(inst.editorId+'_parent'));},_getMsgBoxLayer:function(inst){if(!inst.spellCheckerMsgBoxL)inst.spellCheckerMsgBoxL=new TinyMCE_Layer(inst.editorId+'_spellcheckerMsgBox',false);return inst.spellCheckerMsgBoxL;},_getBlockBoxLayer:function(inst){if(!inst.spellCheckerBoxL)inst.spellCheckerBoxL=new TinyMCE_Layer(inst.editorId+'_spellcheckerBlockBox',false);return inst.spellCheckerBoxL;},_buildSettingsMenu:function(inst,lang){var i,ar=tinyMCE.getParam('spellchecker_languages','+English=en').split(','),p;var self=TinyMCE_SpellCheckerPlugin,m=self._menu,c;m.clear();m.addTitle(tinyMCE.getLang('lang_spellchecker_langs','',true));for(i=0;i';h+='';h+='';h+='';}else{if(tinyMCE.isMSIE&&!tinyMCE.isOpera)h+='';else h+='';h+='';h+='';h+='';h+='';}return h;},_menuButtonEvent:function(e,o){if(o.className=='mceMenuButtonFocus')return;if(e=='over')o.className=o.className+' mceMenuHover';else o.className=o.className.replace(/\s.*$/,'');},_toggleMenu:function(editor_id,id){var self=TinyMCE_SpellCheckerPlugin;var e=document.getElementById(editor_id+'_spellchecker');var inst=tinyMCE.getInstanceById(editor_id);if(self._menu.isVisible()){tinyMCE.hideMenus();return;}tinyMCE.lastMenuBtnClass=e.className.replace(/\s.*$/,'');tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButtonFocus');self._menu.moveRelativeTo(e,'bl');self._menu.moveBy(tinyMCE.isMSIE&&!tinyMCE.isOpera?0:1,-1);if(tinyMCE.isOpera)self._menu.moveBy(0,-2);self._onMenuEvent(inst,self._menu,'show');self._menu.show();tinyMCE.lastSelectedMenuBtn=editor_id+'_spellchecker';},_onMenuEvent:function(inst,m,n){TinyMCE_SpellCheckerPlugin._buildSettingsMenu(inst,inst.spellCheckerLang);},execCommand:function(editor_id,element,command,user_interface,value){var inst=tinyMCE.getInstanceById(editor_id),self=TinyMCE_SpellCheckerPlugin,args='',co,bb,mb,nl,i,e;switch(command){case"mceSpellCheck":if(!inst.spellcheckerOn){inst.spellCheckerBookmark=inst.selection.getBookmark();args+='id='+inst.editorId+"|"+(++self._counter);args+='&cmd=spell&check='+encodeURIComponent(self._getWordList(inst.getBody())).replace(/\'/g,'%27');args+='&lang='+escape(inst.spellCheckerLang);co=document.getElementById(inst.editorId+'_parent').firstChild;bb=self._getBlockBoxLayer(inst);bb.moveRelativeTo(co,'tl');bb.resizeTo(co.offsetWidth,co.offsetHeight);bb.show();mb=self._getMsgBoxLayer(inst);e=mb.getElement();e.innerHTML=''+tinyMCE.getLang('lang_spellchecker_swait','',true)+'';mb.show();mb.moveRelativeTo(co,'cc');if(tinyMCE.isMSIE&&!tinyMCE.isOpera){nl=co.getElementsByTagName('select');for(i=0;i?@[\]^_{|}\u201d\u201c');for(i=0;i0)wl[wl.length]=nl[i];}return wl.join(' ');},_removeWords:function(doc,word){var i,c,nl=doc.getElementsByTagName("span");var self=TinyMCE_SpellCheckerPlugin;var inst=tinyMCE.selectedInstance,b=inst?inst.selection.getBookmark():null;word=typeof(word)=='undefined'?null:word;for(i=nl.length-1;i>=0;i--){c=tinyMCE.getAttrib(nl[i],'class');if((c=='mceItemHiddenSpellWord'||c=='mceItemHidden')&&(word==null||nl[i].innerHTML==word))self._removeWord(nl[i]);}if(b)inst.selection.moveToBookmark(b);},_checkDone:function(inst){var self=TinyMCE_SpellCheckerPlugin;var w=self._countWords(inst);if(w==0){self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');}},_countWords:function(inst){var i,w=0,nl=inst.getDoc().getElementsByTagName("span"),c;var self=TinyMCE_SpellCheckerPlugin;for(i=nl.length-1;i>=0;i--){c=tinyMCE.getAttrib(nl[i],'class');if(c=='mceItemHiddenSpellWord')w++;}return w;},_removeWord:function(e){if(e!=null)tinyMCE.setOuterHTML(e,e.innerHTML);},_markWords:function(doc,n,wl){var i,nv,nn,nl=tinyMCE.getNodeTree(n,new Array(),3);var r1,r2,r3,r4,r5,w='';var re=TinyMCE_SpellCheckerPlugin._getWordSeparators();for(i=0;i0)w+=wl[i]+((i==wl.length-1)?'':'|');}for(i=0;i$1$2');nv=nv.replace(r3,'$1$2');nn=doc.createElement('span');nn.className="mceItemHidden";nn.innerHTML=nv;nl[i].parentNode.replaceChild(nn,nl[i]);}}},_buildMenu:function(sg,max){var i,self=TinyMCE_SpellCheckerPlugin,cm=self._contextMenu;cm.clear();if(sg!=null){cm.addTitle(tinyMCE.getLang('lang_spellchecker_sug','',true));for(i=0;i