1 ////////////////////////////////////////////////////////////////////////////////
3 // Richtext Editor: Fork (RTEF) VERSION: 0.002
5 // For the latest release visit http://richtext.cabspace.com
6 // For support visit http://cabspace.com/forums/?mforum=richtext
8 ////////////////////////////////////////////////////////////////////////////////
10 ////////////////////////////////////////////////////////////////////////////////
14 // Copyright (c) 2006 Timothy Bell
16 // Permission is hereby granted, free of charge, to any person obtaining a copy
17 // of this software and associated documentation files (the "Software"), to deal
18 // in the Software without restriction, including without limitation the rights
19 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20 // copies of the Software, and to permit persons to whom the Software is
21 // furnished to do so, subject to the following conditions:
23 // The above copyright notice and this permission notice shall be included in
24 // all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 ////////////////////////////////////////////////////////////////////////////////
37 var ctxpath = "/siman/";
38 var minWidth = 450; // minumum width
39 var wrapWidth = 1245; //width at which all icons will appear on one bar
40 var maxchar = 64000; // maximum number of characters per save
41 var lang = "en"; //xhtml language
42 var lang_direction = "ltr"; //language direction : ltr = left-to-right, rtl = right-to-left
43 var encoding = "utf-8"; //xhtml encoding
44 var zeroBorder = "#c0c0c0"; //guideline color - see showGuidelines()
45 var btnText = "submit"; //Button value for non-designMode() & fullsceen rte
46 var resize_fullsrcreen = true;
47 // (resize_fullsrcreen) limited in that: 1)won't auto wrap icons. 2)won't
48 // shrink to less than (wrapWidth)px if screen was initized over (wrapWidth)px;
50 var keep_absolute = true; // !!!Disabled - see line 456 for details!!!!!
51 // By default IE will try to convery all hyperlinks to absolute paths. By
52 // setting this value to "false" it will retain the relative path.
63 //Init Variables & Attributes
64 var ua = navigator.userAgent.toLowerCase();
65 var isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1))? true:false;
66 var isIE7 = ((isIE) && (ua.indexOf("msie 7.") != -1))? true:false;
67 var isGecko = (ua.indexOf("gecko") != -1)? true:false;
68 var isSafari = (ua.indexOf("safari") != -1)? true:false;
69 var safariVersion = parseFloat(ua.substring(ua.lastIndexOf("safari/") + 7));
70 var isKonqueror = (ua.indexOf("konqueror") != -1)? true:false;
79 var generateXHTML = true;
80 var isRichText = false;
81 //check to see if designMode mode is available
82 //Safari/Konqueror think they are designMode capable even though they are not
83 //if(document.getElementById && document.designMode && !isSafari && !isKonqueror){
84 if(document.getElementById && document.designMode) {
86 } else if ((isSafari && safariVersion >= 312) || isKonqueror) {
87 //Safari 1.3+ is capable of designMode, Safari 1.3 = webkit build 312
90 //for testing standard textarea, uncomment the following line
93 var replacements = new Array (
94 new RegExp(String.fromCharCode(145),'g'), "'",
95 new RegExp(String.fromCharCode(146),'g'), "'",
96 new RegExp("'"), "'",
97 //convert all types of double quotes
98 new RegExp(String.fromCharCode(147),'g'), "\"",
99 new RegExp(String.fromCharCode(148),'g'), "\"",
100 new RegExp("\""), """, //doesn't work
101 //replace carriage returns & line feeds
102 new RegExp("[\r\n]",'g'), " ");
104 function rteSafe(html) {
106 for (i=0; i<replacements.length; i = i+2) {
107 html = html.replace(replacements[i], replacements[i+1]);
113 var nbcommand = 0; // For not duplicating separators when no command between
114 var defaultFont = "Times New Roman, Times, serif";
115 var defaultSize = "13px";
116 var activeCommand = { // Strait-forward HashMap
117 put : function(foo, bar) {this[foo] = bar;},
118 get : function(foo) {return this[foo];}
121 function initTextInput() {
122 activeCommand.put("cut", lblCut);
123 activeCommand.put("copy", lblCopy);
124 activeCommand.put("paste", lblPaste);
125 activeCommand.put("undo", lblUndo);
126 activeCommand.put("redo", lblRedo);
127 activeCommand.put("bold", lblBold);
128 activeCommand.put("italic", lblItalic);
129 activeCommand.put("underline", lblUnderline);
130 activeCommand.put("list", lblUL);
131 activeCommand.put("numbered_list", lblOL);
132 activeCommand.put("indent", lblIndent);
133 activeCommand.put("outdent", lblOutdent);
134 activeCommand.put("replace", lblSearch);
135 activeCommand.put("hyperlink", lblInsertLink);
138 defaultFont = "Arial, Helvetica, sans-serif";
139 initRTE(ctxpath + "rtef/images/", ctxpath + "rtef/", "", true);
142 function initTextEditor() {
143 activeCommand.put("save", lblSave);
144 // activeCommand.put("print", lblPrint);
145 activeCommand.put("cut", lblCut);
146 activeCommand.put("copy", lblCopy);
147 activeCommand.put("paste", lblPaste);
148 activeCommand.put("undo", lblUndo);
149 activeCommand.put("redo", lblRedo);
150 activeCommand.put("bold", lblBold);
151 activeCommand.put("italic", lblItalic);
152 activeCommand.put("underline", lblUnderline);
153 activeCommand.put("list", lblUL);
154 activeCommand.put("numbered_list", lblOL);
155 activeCommand.put("indent", lblIndent);
156 activeCommand.put("outdent", lblOutdent);
157 activeCommand.put("replace", lblSearch);
158 activeCommand.put("hyperlink", lblInsertLink);
161 defaultFont = "Arial, Helvetica, sans-serif";
162 initRTE(ctxpath + "rtef/images/", ctxpath + "rtef/", "", true);
165 function addCommand(name, action) {
166 var label = activeCommand.get(name);
168 insertImg(label, name + ".gif", action);
173 function displayTextEditor(inputname, initialtext, width, height) {
174 writeRichText(inputname, rteSafe(initialtext), '', width, height, true, false, false);
178 function initRTE(imgPath, incPath, css, genXHTML){
179 // CM 05/04/05 check args for compatibility with old RTE implementations
180 if (arguments.length == 3) {
181 genXHTML = generateXHTML;
184 imagesPath = imgPath;
185 includesPath = incPath;
187 generateXHTML = genXHTML;
189 document.writeln('<style type="text/css">@import "' + includesPath + 'rte.css";</style>');
192 minWidth = minWidth-48;
193 wrapWidth = wrapWidth-102;
197 function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscreen) {
199 if(allRTEs.length > 0){
203 // CM 06/04/05 stops single quotes from messing everything up
204 html=replaceIt(html,'\'',''');
205 // CM 05/04/05 a bit of juggling for compatibility with old RTE implementations
206 if (arguments.length == 6) {
214 var iconWrapWidth = wrapWidth;
220 readOnly = false; // fullscreen is not readOnly and must show buttons
222 // resize rte on resize if the option resize_fullsrcreen = true.
223 if(isRichText && resize_fullsrcreen) {
224 window.onresize = resizeRTE;
226 document.body.style.margin = "0px";
227 document.body.style.overflow = "hidden";
228 //adjust maximum table widths
231 if(width < iconWrapWidth) {
232 height = (obj_height - 83);
234 height = (obj_height - 55);
236 if (width < minWidth) {
237 document.body.style.overflow = "auto";
239 height = obj_height-22;
241 height = obj_height-24;
248 iconWrapWidth = iconWrapWidth-25;
249 //adjust minimum table widths
250 if(buttons && (width < minWidth)) {
256 tablewidth = width + 4;
266 document.writeln('<span class="rteDiv">');
268 document.writeln('<table class="rteBk" cellpadding=0 cellspacing=0 id="Buttons1_'+rte+'" width="' + tablewidth + '">');
269 document.writeln('<tbody><tr>');
271 if(fullscreen || activeCommand.get("save") != null){
272 document.writeln('<td><input type="image" class="rteImg" src="'+imagesPath+'save.gif" alt="'+lblSave+'" title="'+lblSave+'" onmouseover="this.className=\'rteImgUp\'" onmouseout="this.className=\'rteImg\'" onmousedown="this.className=\'rteImgDn\'" onmouseup="this.className=\'rteImgUp\'" onClick="submitEdit()"></td>');
275 if(!isSafari && !isKonqueror) {
276 addCommand("print","rtePrint('"+rte+"')");
277 // insertImg(lblPrint,"print.gif","rtePrint('"+rte+"')");
279 addCommand("selectall","toggleSelection('"+rte+"')");
280 // insertImg(lblSelectAll,"selectall.gif","toggleSelection('"+rte+"')");
281 addCommand("unformat","rteCommand('"+rte+"','removeformat')");
282 // insertImg(lblUnformat,"unformat.gif","rteCommand('"+rte+"','removeformat')");
285 if(isIE || isSafari || isKonqueror) {
286 addCommand("cut","rteCommand('"+rte+"','cut')");
287 // insertImg(lblCut,"cut.gif","rteCommand('"+rte+"','cut')");
288 addCommand("copy","rteCommand('"+rte+"','copy')");
289 // insertImg(lblCopy,"copy.gif","rteCommand('"+rte+"','copy')");
291 if(isSafari || isKonqueror) {
292 addCommand("paste","rteCommand('"+rte+"','InsertText')");
293 // insertImg(lblPaste,"paste.gif","rteCommand('"+rte+"','InsertText')");
296 addCommand("paste","rteCommand('"+rte+"','paste')");
297 // insertImg(lblPaste,"paste.gif","rteCommand('"+rte+"','paste')");
299 if(!isSafari && !isKonqueror) {
300 addCommand("pastetext","dlgLaunch('"+rte+"','text')");
301 // insertImg(lblPasteText,"pastetext.gif","dlgLaunch('"+rte+"','text')");
302 addCommand("pasteword","dlgLaunch('"+rte+"','word')");
303 // insertImg(lblPasteWord,"pasteword.gif","dlgLaunch('"+rte+"','word')");
306 addCommand("undo","rteCommand('"+rte+"','undo')");
307 // insertImg(lblUndo,"undo.gif","rteCommand('"+rte+"','undo')");
308 addCommand("redo","rteCommand('"+rte+"','redo')");
309 // insertImg(lblRedo,"redo.gif","rteCommand('"+rte+"','redo')");
310 if(!isSafari && !isKonqueror) {
312 // document.writeln('<td>');
313 // document.writeln('<select id="formatblock_'+rte+'" onchange="selectFont(\''+rte+'\', this.id);return false" style="font-size:14px;width:105px;height:20px;margin:1px;">');
314 // document.writeln(lblFormat);
315 // document.writeln('</select></td><td>');
316 // document.writeln('<select id="fontname_'+rte+'" onchange="selectFont(\''+rte+'\', this.id);return false" style="font-size:14px;width:125px;height:20px;margin:1px;">');
317 // document.writeln(lblFont);
318 // document.writeln('</select></td><td>');
319 // document.writeln('<select unselectable="on" id="fontsize_'+rte+'" onchange="selectFont(\''+rte+'\', this.id);return false" style="font-size:14px;width:75px;height:20px;margin:1px;">');
320 // document.writeln(lblSize);
321 // document.writeln('</select></td>');
323 if(tablewidth < iconWrapWidth){
324 document.writeln('<td width="100%"></td></tr></tbody></table>');
325 document.writeln('<table class="rteBk" cellpadding="0" cellspacing="0" id="Buttons2_'+rte+'" width="' + tablewidth + '">');
326 document.writeln('<tbody><tr>');
329 addCommand("bold","rteCommand('"+rte+"','bold')");
330 // insertImg(lblBold,"bold.gif","rteCommand('"+rte+"','bold')");
331 addCommand("italic","rteCommand('"+rte+"','italic')");
332 // insertImg(lblItalic,"italic.gif","rteCommand('"+rte+"','italic')");
333 addCommand("underline","rteCommand('"+rte+"','underline')");
334 // insertImg(lblUnderline,"underline.gif","rteCommand('"+rte+"','underline')");
335 //if(!isSafari && !isKonqueror) insertImg(lblStrikeThrough,"strikethrough.gif","rteCommand('"+rte+"','strikethrough')");
336 //insertImg(lblSuperscript,"superscript.gif","rteCommand('"+rte+"','superscript')");
337 //if(!isSafari && !isKonqueror){
338 //insertImg(lblSubscript,"subscript.gif","rteCommand('"+rte+"','subscript')");
340 //insertImg(lblSubscript,"subscript.gif","rteCommand('"+rte+"','StyleChange',sub)");
343 addCommand("left_just","rteCommand('"+rte+"','justifyleft')");
344 // insertImg(lblAlgnLeft,"left_just.gif","rteCommand('"+rte+"','justifyleft')");
345 addCommand("centre","rteCommand('"+rte+"','justifycenter')");
346 // insertImg(lblAlgnCenter,"centre.gif","rteCommand('"+rte+"','justifycenter')");
347 addCommand("right_just","rteCommand('"+rte+"','justifyright')");
348 // insertImg(lblAlgnRight,"right_just.gif","rteCommand('"+rte+"','justifyright')");
349 addCommand("justifyfull","rteCommand('"+rte+"','justifyfull')");
350 // insertImg(lblJustifyFull,"justifyfull.gif","rteCommand('"+rte+"','justifyfull')");
351 if(!isSafari && !isKonqueror) {
353 addCommand("numbered_list","rteCommand('"+rte+"','insertorderedlist')");
354 // insertImg(lblOL,"numbered_list.gif","rteCommand('"+rte+"','insertorderedlist')");
355 addCommand("list","rteCommand('"+rte+"','insertunorderedlist')");
356 // insertImg(lblUL,"list.gif","rteCommand('"+rte+"','insertunorderedlist')");
357 addCommand("outdent","rteCommand('"+rte+"','outdent')");
358 // insertImg(lblOutdent,"outdent.gif","rteCommand('"+rte+"','outdent')");
359 addCommand("indent","rteCommand('"+rte+"','indent')");
360 // insertImg(lblIndent,"indent.gif","rteCommand('"+rte+"','indent')");
362 addCommand("textcolor","dlgColorPalette('"+rte+"','forecolor')","forecolor_"+rte);
363 // insertImg(lblTextColor,"textcolor.gif","dlgColorPalette('"+rte+"','forecolor')","forecolor_"+rte);
364 addCommand("bgcolor","dlgColorPalette('"+rte+"','hilitecolor')","hilitecolor_"+rte);
365 // insertImg(lblBgColor,"bgcolor.gif","dlgColorPalette('"+rte+"','hilitecolor')","hilitecolor_"+rte);
367 addCommand("hr","rteCommand('"+rte+"','inserthorizontalrule')");
368 // insertImg(lblHR,"hr.gif","rteCommand('"+rte+"','inserthorizontalrule')");
370 addCommand("special_char","dlgLaunch('"+rte+"','char')");
371 // insertImg(lblInsertChar,"special_char.gif","dlgLaunch('"+rte+"','char')");
372 addCommand("hyperlink","dlgLaunch('"+rte+"','link')");
373 // insertImg(lblInsertLink,"hyperlink.gif","dlgLaunch('"+rte+"','link')");
374 addCommand("image","dlgLaunch('"+rte+"','image')");
375 // insertImg(lblAddImage,"image.gif","dlgLaunch('"+rte+"','image')");
376 addCommand("insert_table","dlgLaunch('"+rte+"','table')");
377 // insertImg(lblInsertTable,"insert_table.gif","dlgLaunch('"+rte+"','table')");
380 if(!isSafari && !isKonqueror) {
381 addCommand("replace","dlgLaunch('"+rte+"','replace')");
382 // insertImg(lblSearch,"replace.gif","dlgLaunch('"+rte+"','replace')");
384 addCommand("word_count","countWords('"+rte+"')");
385 // insertImg(lblWordCount,"word_count.gif","countWords('"+rte+"')");
387 addCommand("spellcheck","checkspell()");
388 // insertImg(lblSpellCheck,"spellcheck.gif","checkspell()");
390 document.writeln('<td width="100%"></td></tr></tbody></table>');
392 document.writeln('<iframe id="'+rte+'" width="' + (tablewidth - 2) + 'px" height="' + height + 'px" frameborder=0 style="border: 1px solid #d2d2d2" src="' + includesPath + 'blank.htm" onfocus="dlgCleanUp();"></iframe>');
394 document.writeln('<table id="vs'+rte+'" name="vs'+rte+'" class="rteBk" cellpadding=0 cellspacing=0 border=0 width="' + tablewidth + '"><tr>');
395 document.writeln('<td onclick="toggleHTMLSrc(\''+rte+'\', ' + buttons + ');" nowrap><img class="rteBar" src="'+imagesPath+'bar.gif" alt="" align=absmiddle><span id="imgSrc'+rte+'"><img src="'+imagesPath+'code.gif" alt="" title="" style="margin:1px;" align=absmiddle></span><span id="_xtSrc'+rte+'" style="font-family:tahoma,sans-serif;font-size:12px;color:#0000ff;CURSOR: default;">'+lblModeHTML+'</span></td>');
396 document.writeln('<td width="100%" nowrap> </td></tr></table>');
398 document.writeln('<iframe width="142" height="98" id="cp'+rte+'" src="' + includesPath + 'palette.htm" scrolling="no" frameborder=0 style="margin:0;border:0;visibility:hidden;position:absolute;border:1px solid #cdcdcd;top:-1000px;left:-1000px"></iframe>');
399 document.writeln('<input type="hidden" id="hdn'+rte+'" name="'+rte+'" value="" style="position: absolute;left:-1000px;top:-1000px;">');
401 document.writeln('<input type="hidden" id="size'+rte+'" name="size'+rte+'" value="'+height+'" style="position: absolute;left:-1000px;top:-1000px;">');
403 document.writeln('</span>');
404 document.getElementById('hdn'+rte).value = html;
405 enableDesignMode(rte, html, rte_css, readOnly);
408 if(fullscreen && height > 90) {
409 height = (height - 75);tablewidth=tablewidth-30;
411 // CM non-designMode() UI
412 html = parseBreaks(html);
413 document.writeln('<div style="font:12px Verdana, Arial, Helvetica, sans-serif;width: ' + tablewidth + 'px;padding:15px;">');
415 document.writeln('<div style="color:gray">'+lblnon_designMode+'</div><br>');
416 document.writeln('<input type="radio" name="' + rte + '_autobr" value="1" checked="checked" onclick="autoBRon(\'' + rte + '\');" /> '+lblAutoBR+'<input type="radio" name="' + rte + '_autobr" value="0" onclick="autoBRoff(\'' + rte + '\');" />'+lblRawHTML+'<br>');
417 document.writeln('<textarea name="'+rte+'" id="'+rte+'" style="width: ' + tablewidth + 'px; height: ' + height + 'px;">' + html + '</textarea>');
419 document.writeln('<textarea name="'+rte+'" id="'+rte+'" style="width: ' + tablewidth + 'px; height: ' + height + 'px;" readonly=readonly>' + html + '</textarea>');
421 if(fullscreen) document.writeln('<br><input type="submit" value="'+btnText+'" />');
422 document.writeln('</div>');
426 function insertBar() {
427 document.writeln('<td><img class="rteBar" src="'+imagesPath+'bar.gif" alt=""></td>');
430 function insertSep() {
432 document.writeln('<td><img class="rteSep" src="'+imagesPath+'blackdot.gif" alt=""></td>');
436 function insertImg(name, image, command, id){
439 td = "<td id='"+id+"'>";
441 document.writeln(td+'<img class="rteImg" src="'+imagesPath+image+'" alt="'+name+'" title="'+name+'" onMouseDown="'+command+';return false" onmouseover="this.className=\'rteImgUp\'" onmouseout="this.className=\'rteImg\'" onmousedown="this.className=\'rteImgDn\'" onmouseup="this.className=\'rteImgUp\'"></td>');
444 function enableDesignMode(rte, html, css, readOnly) {
445 var frameHtml = "<html dir='" + lang_direction + "' lang='" + lang + "' id='" + rte + "'>\n<head>\n";
446 frameHtml += "<meta http-equiv='Content-Type' content='text/html; charset=" + encoding + "'>\n";
447 frameHtml += "<meta http-equiv='Content-Language' content='" + lang + "'>\n";
448 //to reference your stylesheet, set href property below to your stylesheet path and uncomment
450 frameHtml += "<link media=\"all\" type=\"text/css\" href=\"" + css + "\" rel=\"stylesheet\">\n";
452 frameHtml += "<style>@charset \"utf-8\"; body {background:#FFFFFF;margin:8px;padding:0px;font-family:"+defaultFont+";font-size:"+defaultSize+";}</style>\n";
454 frameHtml += "</head><body>\n"+html+"\n</body></html>";
455 if(!isSafari && !isKonqueror) var oRTE = returnRTE(rte).document;
457 if(isSafari || isKonqueror) var oRTE = frames[rte].document;
458 oRTE.open("text/html","replace");
459 oRTE.write(frameHtml);
462 oRTE.designMode = "On";
466 // Commented out the following line to confront a bug when loading multiple RTEs on one page in a MOZ browser
467 // Fix provided by "Kings". Safari may have problems with this snytax - unable to test because I don't own a MAC.(Tim Bell)
469 // if(!readOnly) document.getElementById(rte).contentDocument.designMode = "on";
470 if(!readOnly && !isKonqueror && !isSafari) {
471 document.getElementById(rte).contentDocument.designMode = "on"; //RKV
472 addLoadEvent(function() { document.getElementById(rte).contentDocument.designMode = "on"; });
473 } else if(!readOnly) {
474 if (!readOnly) document.getElementById(rte).contentDocument.designMode = "on";
478 if(isSafari || isKonqueror) var oRTE = document.getElementById(rte).contentWindow.document;
479 oRTE.open("text/html","replace");
480 oRTE.write(frameHtml);
482 if(isGecko && !readOnly) {
483 //attach a keyboard handler for gecko browsers to make keyboard shortcuts work
484 oRTE.addEventListener("keypress", geckoKeyPress, true);
485 oRTE.addEventListener("focus", function (){dlgCleanUp();}, false);
488 alert(lblErrorPreload);
491 //gecko may take some time to enable design mode.
492 //Keep looping until able to set.
494 setTimeout("enableDesignMode('"+rte+"', '"+html+"', '"+css+"', "+readOnly+");", 200);
500 setTimeout('showGuidelines("'+rte+'")',300);
503 function addLoadEvent(func) {
504 var oldonload = window.onload;
505 if (typeof window.onload != 'function') {
506 window.onload = func;
508 window.onload = function() {
515 function returnRTE(rte) {
520 rtn = document.getElementById(rte).contentWindow;
525 function updateRTE(rte) {
527 dlgCleanUp(); // Closes Pop-ups
528 stripGuidelines(rte); // Removes Table Guidelines
533 function updateRTEs(){
534 var vRTEs = allRTEs.split(";");
535 for(var i=0; i<vRTEs.length; i++){
540 function parseRTE(rte) {
542 autoBRoff(rte); // sorts out autoBR
545 //check for readOnly mode
546 var readOnly = false;
547 var oRTE = returnRTE(rte);
549 if(oRTE.document.designMode != "On"){
553 if(oRTE.document.designMode != "on"){
557 if(isRichText && !readOnly){
558 //if viewing source, switch back to design view
559 if(document.getElementById("_xtSrc"+rte).innerHTML == lblModeRichText){
560 if(document.getElementById("Buttons1_"+rte)){
561 toggleHTMLSrc(rte, true);
563 toggleHTMLSrc(rte, false);
565 stripGuidelines(rte);
571 function setHiddenVal(rte){
572 //set hidden form field value for current rte
573 var oHdnField = document.getElementById('hdn'+rte);
574 //convert html output to xhtml (thanks Timothy Bell and Vyacheslav Smolin!)
575 if(oHdnField.value==null){
576 oHdnField.value = "";
578 var sRTE = returnRTE(rte).document.body;
581 oHdnField.value = getXHTML(sRTE.innerHTML);
583 oHdnField.value = sRTE.innerHTML;
586 oHdnField.value = sRTE.innerHTML;
588 // fix to replace special characters added here:
589 oHdnField.value = replaceSpecialChars(oHdnField.value);
590 //if there is no content (other than formatting) set value to nothing
591 if(stripHTML(oHdnField.value.replace(" ", " ")) == "" &&
592 oHdnField.value.toLowerCase().search("<hr") == -1 &&
593 oHdnField.value.toLowerCase().search("<img") == -1){
594 oHdnField.value = "";
598 function rteCommand(rte, command, option){
600 //function to perform command
601 var oRTE = returnRTE(rte);
604 oRTE.document.execCommand(command, false, option);
608 // setTimeout("rteCommand('" + rte + "', '" + command + "', '" + option + "');", 10);
612 function toggleHTMLSrc(rte, buttons){
614 //contributed by Bob Hutzel (thanks Bob!)
615 var cRTE = document.getElementById(rte);
616 var hRTE = document.getElementById('hdn'+rte);
617 var sRTE = document.getElementById("size"+rte);
618 var tRTE = document.getElementById("_xtSrc"+rte);
619 var iRTE = document.getElementById("imgSrc"+rte);
620 var oRTE = returnRTE(rte).document;
623 obj_height = parseInt(sRTE.value);
627 if(tRTE.innerHTML == lblModeHTML){
628 //we are checking the box
629 tRTE.innerHTML = lblModeRichText;
630 stripGuidelines(rte);
632 showHideElement("Buttons1_" + rte, "hide", true);
633 if(document.getElementById("Buttons2_"+rte)){
634 showHideElement("Buttons2_" + rte, "hide", true);
635 cRTE.style.height = obj_height+56;
637 cRTE.style.height = obj_height+28;
642 oRTE.body.innerText = hRTE.value;
644 htmlSrc = oRTE.createTextNode(hRTE.value);
645 oRTE.body.innerHTML = "";
646 oRTE.body.appendChild(htmlSrc);
648 iRTE.innerHTML = '<img src="'+imagesPath+'design.gif" alt="Switch Mode" style="margin:1px;" align=absmiddle>';
650 //we are unchecking the box
651 obj_height = parseInt(cRTE.style.height);
652 tRTE.innerHTML = lblModeHTML;
654 showHideElement("Buttons1_" + rte, "show", true);
655 if(document.getElementById("Buttons2_"+rte)){
656 showHideElement("Buttons2_" + rte, "show", true);
657 cRTE.style.height = obj_height-56;
659 cRTE.style.height = obj_height-28;
664 var output = escape(oRTE.body.innerText);
665 output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E");
666 output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E");
667 oRTE.body.innerHTML = unescape(output);
668 // Disabled due to flaw in the regular expressions, this fix
669 // does not work with the revamped's enhanced insert link dialog window.
671 // Prevent links from changing to absolute paths
673 var tagfix = unescape(output).match(/<a[^>]*href=(['"])([^\1>]*)\1[^>]*>/ig);
674 var coll = oRTE.body.all.tags('A');
675 for(i=0; i<coll.length; i++){
676 // the 2 alerts below show when we hinder the links from becoming absolute
678 coll[i].href = tagfix[i].replace(/.*href=(['"])([^\1]*)\1.*/i,"$2");
679 //alert(RegExp.$1 + " " + RegExp.$2 + " " + RegExp.$3);
681 var imgfix = unescape(output).match(/<img[^>]*src=['"][^'"]*['"][^>]*>/ig);
682 var coll2 = oRTE.body.all.tags('IMG');
683 for(i=0; i<coll2.length; i++){
684 coll2[i].src = imgfix[i].replace(/.*src=['"]([^'"]*)['"].*/i,"$1");
689 htmlSrc = oRTE.body.ownerDocument.createRange();
690 htmlSrc.selectNodeContents(oRTE.body);
691 oRTE.body.innerHTML = htmlSrc.toString();
693 oRTE.body.innerHTML = replaceSpecialChars(oRTE.body.innerHTML);
695 // (IE Only)This prevents an undo operation from displaying a pervious HTML mode
696 // This resets the undo/redo buffer.
700 iRTE.innerHTML = '<img src="'+imagesPath+'code.gif" alt="Switch Mode" style="margin:1px;" align=absmiddle>';
704 function toggleSelection(rte) {
705 var rng = setRange(rte);
706 var oRTE = returnRTE(rte).document;
710 length1 = rng.text.length;
711 var output = escape(oRTE.body.innerText);
712 output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E");
713 output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E");
714 length2 = unescape(output).length;
716 length1 = rng.toString().length;
717 var htmlSrc = oRTE.body.ownerDocument.createRange();
718 htmlSrc.selectNodeContents(oRTE.body);
719 length2 = htmlSrc.toString().length;
721 if(length1 < length2){
722 rteCommand(rte,'selectall','');
725 oRTE.designMode = "off";
726 oRTE.designMode = "on";
728 rteCommand(rte,'unselect','');
733 function dlgColorPalette(rte, command) {
734 //function to display or hide color palettes
736 //get dialog position
737 var oDialog = document.getElementById('cp' + rte);
738 var buttonElement = document.getElementById(command+"_"+rte);
739 var iLeftPos = buttonElement.offsetLeft+5;
740 var iTopPos = buttonElement.offsetTop+53;
741 if (!document.getElementById('Buttons2_'+rte)){
742 iTopPos = iTopPos-28;
744 oDialog.style.left = iLeftPos + "px";
745 oDialog.style.top = iTopPos + "px";
747 if((command == parent.command)&&(rte == currentRTE)){
748 //if current command dialog is currently open, close it
749 if(oDialog.style.visibility == "hidden"){
750 showHideElement(oDialog, 'show', false);
752 showHideElement(oDialog, 'hide', false);
755 //if opening a new dialog, close all others
756 var vRTEs = allRTEs.split(";");
757 for(var i = 0; i<vRTEs.length; i++){
758 showHideElement('cp' + vRTEs[i], 'hide', false);
760 showHideElement(oDialog, 'show', false);
762 //save current values
764 parent.command = command;
767 function dlgLaunch(rte, command) {
768 var selectedText = '';
769 //save current values
770 parent.command = command;
774 InsertChar = popUpWin(includesPath+'insert_char.htm', 'InsertChar', 50, 50, 'status=yes,');
777 InsertTable = popUpWin(includesPath + 'insert_table.htm', 'InsertTable', 50, 50, 'status=yes,');
782 InsertImg = popUpWin(includesPath + 'insert_img.htm','AddImage', 50, 50, 'status=yes,');
785 selectedText = getText(rte);
786 InsertLink = popUpWin(includesPath + 'insert_link.htm', 'InsertLink', 50, 50, 'status=yes,');
787 setFormText("0", selectedText);
790 selectedText = getText(rte);
791 dlgReplace = popUpWin(includesPath + 'replace.htm', 'dlgReplace', 50, 50, 'status=yes,');
792 setFormText("1", selectedText);
795 dlgPasteText = popUpWin(includesPath + 'paste_text.htm', 'dlgPasteText', 50, 50, 'status=yes,');
798 dlgPasteWord = popUpWin(includesPath + 'paste_word.htm', 'dlgPasteWord', 50, 50, 'status=yes,');
803 function getText(rte) {
804 //get currently highlighted text and set link text value
808 rtn = stripHTML(rng.htmlText);
810 rtn = stripHTML(rng.toString());
814 rtn = rtn.replace("'","\\\\\\'");
816 rtn = rtn.replace("'","\\'");
821 function setFormText(popup, content){
822 //set link text value in dialog windows
823 if(content != "undefined")
827 case "0": InsertLink.document.getElementById("linkText").value = content; break;
828 case "1": dlgReplace.document.getElementById("searchText").value = content; break;
831 //may take some time to create dialog window.
832 //Keep looping until able to set.
833 setTimeout("setFormText('"+popup+"','" + content + "');", 10);
838 function dlgCleanUp(){
839 var vRTEs = allRTEs.split(";");
840 for(var i = 0; i < vRTEs.length; i++){
841 showHideElement('cp' + vRTEs[i], 'hide', false);
843 if(InsertChar != null){
847 if(InsertTable != null){
851 if(InsertLink != null){
855 if(InsertImg != null){
859 if(dlgReplace != null){
863 if(dlgPasteText != null){
864 dlgPasteText.close();
867 if(dlgPasteWord != null){
868 dlgPasteWord.close();
873 function popUpWin (url, win, width, height, options) {
875 var leftPos = (screen.availWidth - width) / 2;
876 var topPos = (screen.availHeight - height) / 2;
877 options += 'width=' + width + ',height=' + height + ',left=' + leftPos + ',top=' + topPos;
878 return window.open(url, win, options);
881 function setColor(color) {
882 //function to set color
883 var rte = currentRTE;
884 var parentCommand = parent.command;
886 if(parentCommand == "hilitecolor"){
887 parentCommand = "backcolor";
889 //retrieve selected range
892 rteCommand(rte, parentCommand, color);
893 showHideElement('cp'+rte, "hide", false);
896 function addImage(rte) {
898 //function to add image
899 imagePath = prompt('Enter Image URL:', 'http://');
900 if((imagePath != null)&&(imagePath != "")){
901 rteCommand(rte, 'InsertImage', imagePath);
905 function rtePrint(rte) {
908 document.getElementById(rte).contentWindow.document.execCommand('Print');
910 document.getElementById(rte).contentWindow.print();
914 function selectFont(rte, selectname){
915 //function to handle font changes
916 var idx = document.getElementById(selectname).selectedIndex;
917 // First one is always a label
919 var selected = document.getElementById(selectname).options[idx].value;
920 var cmd = selectname.replace('_'+rte, '');
921 rteCommand(rte, cmd, selected);
922 document.getElementById(selectname).selectedIndex = 0;
926 function insertHTML(html){
927 //function to add HTML -- thanks dannyuk1982
928 var rte = currentRTE;
929 var oRTE = returnRTE(rte);
932 var oRng = oRTE.document.selection.createRange();
933 oRng.pasteHTML(html);
934 oRng.collapse(false);
937 oRTE.document.execCommand('insertHTML', false, html);
941 function replaceHTML(tmpContent, searchFor, replaceWith) {
946 while(tmpContent.toUpperCase().indexOf(searchFor.toUpperCase()) > -1) {
947 runCount = runCount+1;
948 // Get all content before the match
949 intBefore = tmpContent.toUpperCase().indexOf(searchFor.toUpperCase());
950 tmpBefore = tmpContent.substring(0, intBefore);
951 tmpOutput = tmpOutput + tmpBefore;
952 // Get the string to replace
953 tmpOutput = tmpOutput + replaceWith;
954 // Get the rest of the content after the match until
955 // the next match or the end of the content
956 intAfter = tmpContent.length - searchFor.length + 1;
957 tmpContent = tmpContent.substring(intBefore + searchFor.length);
959 return runCount+"|^|"+tmpOutput+tmpContent;
962 function replaceSpecialChars(html){
963 var specials = new Array("¢","€","£","¤","¥","©","®","™","÷","×","±","¼","½","¾","°","¹","²","³","µ","«","»","‘","’","‹","›","‚","„","“","”","¡","¦","§","¬","¯","¶","·","¸","¿","ƒ","—","–","•","…","‰","ª","º","ß","†","‡","ð","Ð","ø","Ø","þ","Þ","œ","Œ","š","Š","´","ˆ","˜","¨","à","á","â","ã","ä","å","æ","À","Á","Â","Ã","Ä","Å","Æ","ç","Ç","è","é","ê","ë","È","É","Ê","Ë","ì","í","î","ï","Ì","Í","Î","Ï","ñ","Ñ","ò","ó","ô","õ","ö","Ò","Ó","Ô","Õ","Ö","ù","ú","û","ü","Ù","Ú","Û","Ü","ý","ÿ","Ý","Ÿ");
964 var unicodes = new Array("\u00a2","\u20ac","\u00a3","\u00a4","\u00a5","\u00a9","\u00ae","\u2122","\u00f7","\u00d7","\u00b1","\u00bc","\u00bd","\u00be","\u00b0","\u00b9","\u00b2","\u00b3","\u00b5","\u00ab","\u00bb","\u2018","\u2019","\u2039","\u203a","\u201a","\u201e","\u201c","\u201d","\u00a1","\u00a6","\u00a7","\u00ac","\u00af","\u00b6","\u00b7","\u00b8","\u00bf","\u0192","\u2014","\u2013","\u2022","\u2026","\u2030","\u00aa","\u00ba","\u00df","\u2020","\u2021","\u00f0","\u00d0","\u00f8","\u00d8","\u00fe","\u00de","\u0153","\u0152","\u0161","\u0160","\u00b4","\u02c6","\u02dc","\u00a8","\u00e0","\u00e1","\u00e2","\u00e3","\u00e4","\u00e5","\u00e6","\u00c0","\u00c1","\u00c2","\u00c3","\u00c4","\u00c5","\u00c6","\u00e7","\u00c7","\u00e8","\u00e9","\u00ea","\u00eb","\u00c8","\u00c9","\u00ca","\u00cb","\u00ec","\u00ed","\u00ee","\u00ef","\u00cc","\u00cd","\u00ce","\u00cf","\u00f1","\u00d1","\u00f2","\u00f3","\u00f4","\u00f5","\u00f6","\u00d2","\u00d3","\u00d4","\u00d5","\u00d6","\u00f9","\u00fa","\u00fb","\u00fc","\u00d9","\u00da","\u00db","\u00dc","\u00fd","\u00ff","\u00dd","\u0178");
965 for(var i=0; i<specials.length; i++){
966 html = replaceIt(html,unicodes[i],specials[i]);
971 function SearchAndReplace(searchFor, replaceWith, matchCase, wholeWord) {
972 var cfrmMsg = lblSearchConfirm.replace("SF",searchFor).replace("RW",replaceWith);
973 var rte = currentRTE;
974 stripGuidelines(rte);
975 var oRTE = returnRTE(rte);
976 var tmpContent = oRTE.document.body.innerHTML.replace("'", "\'").replace('"', '\"');
978 if (matchCase && wholeWord) {
979 strRegex = "/(?!<[^>]*)(\\b(" + searchFor + ")\\b)(?![^<]*>)/g";
981 else if (matchCase) {
982 strRegex = "/(?!<[^>]*)(" + searchFor + ")(?![^<]*>)/g";
984 else if (wholeWord) {
985 strRegex = "/(?!<[^>]*)(\\b(" + searchFor + ")\\b)(?![^<]*>)/gi";
987 strRegex = "/(?!<[^>]*)(" + searchFor + ")(?![^<]*>)/gi";
989 var cmpRegex=eval(strRegex);
991 var tmpNext = tmpContent;
992 var intFound = tmpNext.search(cmpRegex);
993 while(intFound > -1) {
994 runCount = runCount+1;
995 tmpNext = tmpNext.substr(intFound + searchFor.length);
996 intFound = tmpNext.search(cmpRegex);
999 cfrmMsg = cfrmMsg.replace("[RUNCOUNT]",runCount);
1000 if(confirm(cfrmMsg)) {
1001 tmpContent=tmpContent.replace(cmpRegex,replaceWith);
1002 oRTE.document.body.innerHTML = tmpContent.replace("\'", "'").replace('\"', '"');
1004 alert(lblSearchAbort);
1006 showGuidelines(rte);
1009 showGuidelines(rte);
1010 alert("["+searchFor+"] "+lblSearchNotFound);
1014 function showHideElement(element, showHide, rePosition){
1015 //function to show or hide elements
1016 //element variable can be string or object
1017 if(document.getElementById(element)){
1018 element = document.getElementById(element);
1020 if(showHide == "show"){
1021 element.style.visibility = "visible";
1023 element.style.position = "relative";
1024 element.style.left = "auto";
1025 element.style.top = "auto";
1027 }else if(showHide == "hide"){
1028 element.style.visibility = "hidden";
1030 element.style.position = "absolute";
1031 element.style.left = "-1000px";
1032 element.style.top = "-1000px";
1037 function setRange(rte){
1038 //function to store range of current selection
1039 var oRTE = returnRTE(rte);
1042 selection = oRTE.document.selection;
1043 if(selection != null){
1044 rng = selection.createRange();
1047 selection = oRTE.getSelection();
1048 rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
1053 function stripHTML(strU) {
1055 var strN = strU.replace(/(<([^>]+)>)/ig,"");
1056 //replace carriage returns and line feeds
1057 strN = strN.replace(/\r\n/g," ");
1058 strN = strN.replace(/\n/g," ");
1059 strN = strN.replace(/\r/g," ");
1064 function trim(inputString) {
1065 if (typeof inputString != "string"){
1068 inputString = inputString.replace(/^\s+|\s+$/g, "").replace(/\s{2,}/g, "");
1072 function showGuidelines(rte) {
1073 if(rte.length == 0) rte = currentRTE;
1074 var oRTE = returnRTE(rte);
1075 var tables = oRTE.document.getElementsByTagName("table");
1076 var sty = "dashed 1px "+zeroBorder;
1077 for(var i=0; i<tables.length; i++){
1078 if(tables[i].getAttribute("border") == 0){
1080 var trs = tables[i].getElementsByTagName("tr");
1081 for(var j=0; j<trs.length; j++){
1082 var tds = trs[j].getElementsByTagName("td");
1083 for(var k=0; k<tds.length; k++){
1084 if(j == 0 && k == 0){
1085 tds[k].style.border = sty;
1086 }else if(j == 0 && k != 0){
1087 tds[k].style.borderBottom = sty;
1088 tds[k].style.borderTop = sty;
1089 tds[k].style.borderRight = sty;
1090 }else if(j != 0 && k == 0) {
1091 tds[k].style.borderBottom = sty;
1092 tds[k].style.borderLeft = sty;
1093 tds[k].style.borderRight = sty;
1094 }else if(j != 0 && k != 0) {
1095 tds[k].style.borderBottom = sty;
1096 tds[k].style.borderRight = sty;
1101 tables[i].removeAttribute("border");
1102 tables[i].setAttribute("style","border: " + sty);
1103 tables[i].setAttribute("rules", "all");
1109 function stripGuidelines(rte) {
1110 var oRTE = returnRTE(rte);
1111 var tbls = oRTE.document.getElementsByTagName("table");
1112 for(var j=0; j<tbls.length; j++) {
1113 if(tbls[j].getAttribute("border") == 0 || tbls[j].getAttribute("border") == null){
1115 var tds = tbls[j].getElementsByTagName("td");
1116 for(var k=0; k<tds.length; k++) {
1117 tds[k].removeAttribute("style");
1120 tbls[j].removeAttribute("style");
1121 tbls[j].removeAttribute("rules");
1122 tbls[j].setAttribute("border","0");
1128 function findSize(obj) {
1129 if(obj.length > 0 && document.all) {
1131 } else if(obj.length > 0 && !document.all) {
1132 obj = document.getElementById(obj).contentWindow;
1136 if ( typeof( obj.window.innerWidth ) == 'number' ) {
1138 obj_width = obj.window.innerWidth;
1139 obj_height = obj.window.innerHeight;
1140 } else if( obj.document.documentElement && ( obj.document.documentElement.clientWidth || obj.document.documentElement.clientHeight ) ) {
1141 //IE 6+ in 'standards compliant mode'
1142 obj_width = document.documentElement.clientWidth;
1143 obj_height = document.documentElement.clientHeight;
1144 } else if( obj.document.body && ( obj.document.body.clientWidth || obj.document.body.clientHeight ) ) {
1146 obj_width = obj.document.body.clientWidth;
1147 obj_height = obj.document.body.clientHeight;
1151 function resizeRTE() {
1152 document.body.style.overflow = "hidden";
1153 var rte = currentRTE;
1154 var oRTE = document.getElementById(rte);
1155 var oBut1 = document.getElementById('Buttons1_'+rte);
1157 var oVS = document.getElementById('vs'+rte);
1160 if (width < minWidth){
1161 document.body.style.overflow = "auto";
1164 var height = obj_height - 83;
1165 if (document.getElementById("_xtSrc"+rte).innerHTML == lblModeRichText){
1166 height = obj_height-28;
1167 if (!document.getElementById('Buttons2_'+rte) && width < wrapWidth) {
1168 document.body.style.overflow = "auto";
1171 if (document.getElementById('Buttons2_'+rte)){
1172 document.getElementById('Buttons2_'+rte).style.width = width;
1175 if (document.getElementById('Buttons2_'+rte)) {
1176 document.getElementById('Buttons2_'+rte).style.width = width;
1178 height = obj_height - 55;
1179 if(width < wrapWidth){
1180 document.body.style.overflow = "auto";
1185 if(document.body.style.overflow == "auto" && isIE){
1188 if(document.body.style.overflow == "auto" && !isIE){
1191 oBut1.style.width = width;
1192 oVS.style.width = width;
1193 oRTE.style.width = width-2;
1194 oRTE.style.height = height;
1196 oRTE.contentDocument.designMode = "on";
1200 function replaceIt(string,text,by) {
1201 // CM 19/10/04 custom replace function
1202 var strLength = string.length, _xtLength = text.length;
1203 if ((strLength == 0) || (_xtLength == 0)){
1206 var i = string.indexOf(text);
1207 if ((!i) && (text != string.substring(0,_xtLength))){
1213 var newstr = string.substring(0,i) + by;
1214 if(i+_xtLength < strLength){
1215 newstr += replaceIt(string.substring(i+_xtLength,strLength),text,by);
1220 function countWords(rte){
1222 var words = document.getElementById("hdn"+rte).value;
1223 var str = stripHTML(words);
1224 var chars = trim(words);
1225 chars = chars.length;
1226 chars = maxchar - chars;
1227 str = str+" a "; // word added to avoid error
1228 str = trim(str.replace(/ /gi,' ').replace(/([\n\r\t])/g,' ').replace(/&(.*);/g,' '));
1230 for(x=0;x<str.length;x++){
1231 if(str.charAt(x)==" " && str.charAt(x-1)!=" "){
1235 if(str.charAt(str.length-1) != " "){
1238 count = count - 1; // extra word removed
1241 alarm = "\n\n"+lblCountCharWarn;
1243 alert(lblCountTotal+": "+count+ "\n\n"+lblCountChar+": "+chars+alarm);
1246 //********************
1247 // Non-designMode() Functions
1248 //********************
1249 function autoBRon(rte) {
1250 // CM 19/10/04 used for non RTE browsers to deal with auto <BR> (and clean up other muck)
1251 var oRTE = document.forms[0].elements[rte];
1252 oRTE.value=parseBreaks(oRTE.value);
1253 oRTE.value=replaceIt(oRTE.value,''','\'');
1256 function autoBRoff(rte) {
1257 // CM 19/10/04 used for non RTE browsers to deal with auto <BR> (auto carried out when the form is submitted)
1258 var oRTE = document.forms[0].elements[rte];
1259 oRTE.value=replaceIt(oRTE.value,'\n','<br />');
1260 oRTE.value=replaceIt(oRTE.value,'\'',''');
1263 function parseBreaks(argIn) {
1264 // CM 19/10/04 used for non RTE browsers to deal with auto <BR> (and clean up other muck)
1265 argIn=replaceIt(argIn,'<br>','\n');
1266 argIn=replaceIt(argIn,'<BR>','\n');
1267 argIn=replaceIt(argIn,'<br/>','\n');
1268 argIn=replaceIt(argIn,'<br />','\n');
1269 argIn=replaceIt(argIn,'\t',' ');
1270 argIn=replaceIt(argIn,'\n ','\n');
1271 argIn=replaceIt(argIn,' <p>','<p>');
1272 argIn=replaceIt(argIn,'</p><p>','\n\n');
1273 argIn=replaceIt(argIn,''','\'');
1274 argIn = trim(argIn);
1278 //********************
1279 //Gecko-Only Functions
1280 //********************
1281 function geckoKeyPress(evt) {
1282 //function to add bold, italic, and underline shortcut commands to gecko RTEs
1283 //contributed by Anti Veeranna (thanks Anti!)
1284 var rte = evt.target.id;
1286 var key = String.fromCharCode(evt.charCode).toLowerCase();
1289 case 'b': cmd = "bold"; break;
1290 case 'i': cmd = "italic"; break;
1291 case 'u': cmd = "underline"; break;
1294 rteCommand(rte, cmd, null);
1295 // stop the event bubble
1296 evt.preventDefault();
1297 evt.stopPropagation();
1305 function checkspell() {
1307 //function to perform spell check
1309 var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
1310 tmpis.CheckAllLinkedDocuments(document);
1313 if(exception.number==-2146827859) {
1314 if(confirm("ieSpell not detected. Click Ok to go to download page.")){
1315 window.open("http://www.iespell.com/download.php","DownLoad");
1318 alert("Error Loading ieSpell: Exception " + exception.number);