var spell_formname,spell_fieldname;function spellCheck(formName,fieldName){var spellform=document.forms.spell_form;spell_formname=formName;spell_fieldname=fieldName;var regexpWordMatch=/(?:<[^>]+>)|(?:\[[^ ][^\]]*\])|(?:&[^; ]+;)|(?:[^0-9\s\]\[{};:"\\|,<.>\/?`~!@#$%^&*()_+=]+)/g;var aWordCharacters=['-','\''];var aWords=new Array(),aResult=new Array();var sText=document.forms[formName][fieldName].value;var bInCode=false;var iOffset1,iOffset2;while((aResult=regexpWordMatch.exec(sText))&&typeof(aResult)!='undefined'){iOffset1=0;iOffset2=aResult[0].length-1;while(in_array(aResult[0].charAt(iOffset1),aWordCharacters)&&iOffset1<iOffset2)iOffset1++;while(in_array(aResult[0].charAt(iOffset2),aWordCharacters)&&iOffset1<iOffset2)iOffset2--;if(iOffset1==iOffset2)continue;if(aResult[0].substr(0, 5).toLowerCase()=='[code')bInCode=true;else if(bInCode&&aResult[0].substr(0, 7).toLowerCase()=='[/code]')bInCode=false;else if(!bInCode&&!in_array(aResult[0].charAt(0),['[','<'])&&aResult[0].toUpperCase()!=aResult[0])aWords[aWords.length]=aResult[0].substr(iOffset1,iOffset2-iOffset1+1)+'|'+(iOffset1+sText.substr(0,aResult.index).length)+'|'+(iOffset2+sText.substr(0,aResult.index).length);}openSpellWin(640,480);spellform.spellstring.value = aWords.join('\n');spellform.target='spellWindow';spellform.submit();return true;}var wordindex=-1,offsetindex=0;var ignoredWords=[];function misp(word,start,end,suggestions){this.word=word;this.start=start;this.end=end;this.suggestions=suggestions;}function replaceWord(){var strstart='';var strend;if(misps[wordindex].start!=0)strstart=mispstr.slice(0,misps[wordindex].start+offsetindex);strend=mispstr.slice(misps[wordindex].end+1+offsetindex);mispstr=strstart+document.forms.spellingForm.changeto.value+strend;offsetindex+=document.forms.spellingForm.changeto.value.length-misps[wordindex].word.length;misps[wordindex].word=document.forms.spellingForm.changeto.value;nextWord(false);}function replaceAll(){var strend;var idx;var origword;var localoffsetindex=offsetindex;origword=misps[wordindex].word;for(idx=wordindex;idx<misps.length;idx++){misps[idx].start+=localoffsetindex;misps[idx].end+=localoffsetindex;}localoffsetindex=0;for(idx=0;idx<misps.length;idx++){if(misps[idx].word==origword){var strstart='';if(misps[idx].start!=0)strstart=mispstr.slice(0,misps[idx].start+localoffsetindex);strend=mispstr.slice(misps[idx].end+1+localoffsetindex);mispstr=strstart+document.forms.spellingForm.changeto.value+strend;localoffsetindex+=document.forms.spellingForm.changeto.value.length-misps[idx].word.length;}misps[idx].start+=localoffsetindex;misps[idx].end+=localoffsetindex;}ignoredWords[origword]=true;offsetindex=0;nextWord(false);}function highlightWord(){var strstart='';var strend;if(misps[wordindex].start!=0)strstart=mispstr.slice(0,misps[wordindex].start+offsetindex);strend=mispstr.slice(misps[wordindex].end+1+offsetindex);var divptr,newValue;divptr=document.getElementById('spellview');newValue=htmlspecialchars(strstart)+'<span class="alert" id="h1">'+misps[wordindex].word+'</span>'+htmlspecialchars(strend);setInnerHTML(divptr,newValue.replace(/_\|_/g,'<br />'));var spellview_height=typeof(document.getElementById("spellview").currentStyle)!='undefined'?parseInt(document.getElementById('spellview').currentStyle.height):document.getElementById('spellview').offsetHeight;var word_position=document.getElementById('h1').offsetTop;var current_position=document.getElementById('spellview').scrollTop;if (spellview_height<=(word_position+current_position))document.getElementById('spellview').scrollTop=word_position+current_position-spellview_height+32;}function nextWord(ignoreall){if(ignoreall)ignoredWords[misps[wordindex].word]=true;if(wordindex>=0){misps[wordindex].start+=offsetindex;misps[wordindex].end+=offsetindex;}wordindex++;if(misps.length<=wordindex){var divptr;divptr=document.getElementById('spellview');setInnerHTML(divptr,htmlspecialchars(mispstr).replace(/_\|_/g,'<br />'));while(document.forms.spellingForm.suggestions.options.length>0)document.forms.spellingForm.suggestions.options[0]=null;alert(txt['done']);document.getElementById('change').disabled=true;document.getElementById('changeall').disabled=true;document.getElementById('ignore').disabled=true;document.getElementById('ignoreall').disabled=true;mispstr=mispstr.replace(/_\|_/g,"\n");window.opener.document.forms[spell_formname][spell_fieldname].value=mispstr;window.opener.document.forms[spell_formname][spell_fieldname].focus();window.close();return true;}if(typeof(ignoredWords[misps[wordindex].word])!='undefined'){nextWord(false);return false;}while(document.forms.spellingForm.suggestions.options.length>0)document.forms.spellingForm.suggestions.options[0]=null;if(misps[wordindex].suggestions.length){for(var sugidx=0;sugidx<misps[wordindex].suggestions.length;sugidx++){var newopt=new Option(misps[wordindex].suggestions[sugidx],misps[wordindex].suggestions[sugidx]);document.forms.spellingForm.suggestions.options[sugidx]=newopt;if(sugidx==0){newopt.selected=true;document.forms.spellingForm.changeto.value=newopt.value;document.forms.spellingForm.changeto.select();}}}if(document.forms.spellingForm.suggestions.options.length==0)document.forms.spellingForm.changeto.value='';highlightWord();return false;}function htmlspecialchars(thetext){thetext=thetext.replace(/\</g,'&lt;');thetext=thetext.replace(/\>/g,'&gt;');thetext=thetext.replace(/\n/g,'<br />');thetext=thetext.replace(/\ \ /g,' &nbsp;');return thetext;}function openSpellWin(width,height){window.open('','spellWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height);}

