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 = 400; // 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" id="'+rte+'SaveButton" 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="prepareSubmitEdit(currentRTE)"></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')");
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')");
290 addCommand("paste","rteCommand('"+rte+"','InsertText')");
291 // insertImg(lblPaste,"paste.gif","rteCommand('"+rte+"','InsertText')");
294 addCommand("paste","rteCommand('"+rte+"','paste')");
295 // insertImg(lblPaste,"paste.gif","rteCommand('"+rte+"','paste')");
297 if(!isSafari && !isKonqueror) {
298 addCommand("pastetext","dlgLaunch('"+rte+"','text')");
299 // insertImg(lblPasteText,"pastetext.gif","dlgLaunch('"+rte+"','text')");
300 addCommand("pasteword","dlgLaunch('"+rte+"','word')");
301 // insertImg(lblPasteWord,"pasteword.gif","dlgLaunch('"+rte+"','word')");
304 addCommand("undo","rteCommand('"+rte+"','undo')");
305 // insertImg(lblUndo,"undo.gif","rteCommand('"+rte+"','undo')");
306 addCommand("redo","rteCommand('"+rte+"','redo')");
307 // insertImg(lblRedo,"redo.gif","rteCommand('"+rte+"','redo')");
308 if(!isSafari && !isKonqueror) {
310 // document.writeln('<td>');
311 // document.writeln('<select id="formatblock_'+rte+'" onchange="selectFont(\''+rte+'\', this.id);return false" style="font-size:14px;width:105px;height:20px;margin:1px;">');
312 // document.writeln(lblFormat);
313 // document.writeln('</select></td><td>');
314 // document.writeln('<select id="fontname_'+rte+'" onchange="selectFont(\''+rte+'\', this.id);return false" style="font-size:14px;width:125px;height:20px;margin:1px;">');
315 // document.writeln(lblFont);
316 // document.writeln('</select></td><td>');
317 // 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;">');
318 // document.writeln(lblSize);
319 // document.writeln('</select></td>');
321 if(tablewidth < iconWrapWidth){
322 document.writeln('<td width="100%"></td></tr></tbody></table>');
323 document.writeln('<table class="rteBk" cellpadding="0" cellspacing="0" id="Buttons2_'+rte+'" width="' + tablewidth + '">');
324 document.writeln('<tbody><tr>');
327 addCommand("bold","rteCommand('"+rte+"','bold')");
328 // insertImg(lblBold,"bold.gif","rteCommand('"+rte+"','bold')");
329 addCommand("italic","rteCommand('"+rte+"','italic')");
330 // insertImg(lblItalic,"italic.gif","rteCommand('"+rte+"','italic')");
331 addCommand("underline","rteCommand('"+rte+"','underline')");
332 // insertImg(lblUnderline,"underline.gif","rteCommand('"+rte+"','underline')");
333 //if(!isSafari && !isKonqueror) insertImg(lblStrikeThrough,"strikethrough.gif","rteCommand('"+rte+"','strikethrough')");
334 //insertImg(lblSuperscript,"superscript.gif","rteCommand('"+rte+"','superscript')");
335 //if(!isSafari && !isKonqueror){
336 //insertImg(lblSubscript,"subscript.gif","rteCommand('"+rte+"','subscript')");
338 //insertImg(lblSubscript,"subscript.gif","rteCommand('"+rte+"','StyleChange',sub)");
341 addCommand("left_just","rteCommand('"+rte+"','justifyleft')");
342 // insertImg(lblAlgnLeft,"left_just.gif","rteCommand('"+rte+"','justifyleft')");
343 addCommand("centre","rteCommand('"+rte+"','justifycenter')");
344 // insertImg(lblAlgnCenter,"centre.gif","rteCommand('"+rte+"','justifycenter')");
345 addCommand("right_just","rteCommand('"+rte+"','justifyright')");
346 // insertImg(lblAlgnRight,"right_just.gif","rteCommand('"+rte+"','justifyright')");
347 addCommand("justifyfull","rteCommand('"+rte+"','justifyfull')");
348 // insertImg(lblJustifyFull,"justifyfull.gif","rteCommand('"+rte+"','justifyfull')");
350 addCommand("numbered_list","rteCommand('"+rte+"','insertorderedlist')");
351 // insertImg(lblOL,"numbered_list.gif","rteCommand('"+rte+"','insertorderedlist')");
352 addCommand("list","rteCommand('"+rte+"','insertunorderedlist')");
353 // insertImg(lblUL,"list.gif","rteCommand('"+rte+"','insertunorderedlist')");
354 addCommand("hyperlink","dlgLaunch('"+rte+"','link')");
355 // insertImg(lblInsertLink,"hyperlink.gif","dlgLaunch('"+rte+"','link')");
359 addCommand("textcolor","dlgColorPalette('"+rte+"','forecolor')","forecolor_"+rte);
360 // insertImg(lblTextColor,"textcolor.gif","dlgColorPalette('"+rte+"','forecolor')","forecolor_"+rte);
361 addCommand("bgcolor","dlgColorPalette('"+rte+"','hilitecolor')","hilitecolor_"+rte);
362 // insertImg(lblBgColor,"bgcolor.gif","dlgColorPalette('"+rte+"','hilitecolor')","hilitecolor_"+rte);
364 addCommand("hr","rteCommand('"+rte+"','inserthorizontalrule')");
365 // insertImg(lblHR,"hr.gif","rteCommand('"+rte+"','inserthorizontalrule')");
367 addCommand("special_char","dlgLaunch('"+rte+"','char')");
368 // insertImg(lblInsertChar,"special_char.gif","dlgLaunch('"+rte+"','char')");
369 addCommand("image","dlgLaunch('"+rte+"','image')");
370 // insertImg(lblAddImage,"image.gif","dlgLaunch('"+rte+"','image')");
371 addCommand("insert_table","dlgLaunch('"+rte+"','table')");
372 // insertImg(lblInsertTable,"insert_table.gif","dlgLaunch('"+rte+"','table')");
374 addCommand("outdent","rteCommand('"+rte+"','outdent')");
375 // insertImg(lblOutdent,"outdent.gif","rteCommand('"+rte+"','outdent')");
376 addCommand("indent","rteCommand('"+rte+"','indent')");
377 // insertImg(lblIndent,"indent.gif","rteCommand('"+rte+"','indent')");
380 addCommand("replace","dlgLaunch('"+rte+"','replace')");
381 // insertImg(lblSearch,"replace.gif","dlgLaunch('"+rte+"','replace')");
383 addCommand("word_count","countWords('"+rte+"')");
384 // insertImg(lblWordCount,"word_count.gif","countWords('"+rte+"')");
386 addCommand("spellcheck","checkspell()");
387 // insertImg(lblSpellCheck,"spellcheck.gif","checkspell()");
389 document.writeln('<td width="100%"></td></tr></tbody></table>');
391 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>');
393 document.writeln('<table id="vs'+rte+'" name="vs'+rte+'" class="rteBk" cellpadding=0 cellspacing=0 border=0 width="' + tablewidth + '"><tr>');
394 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>');
395 document.writeln('<td width="100%" nowrap> </td></tr></table>');
397 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>');
398 document.writeln('<input type="hidden" id="hdn'+rte+'" name="'+rte+'" value="" style="position: absolute;left:-1000px;top:-1000px;">');
400 document.writeln('<input type="hidden" id="size'+rte+'" name="size'+rte+'" value="'+height+'" style="position: absolute;left:-1000px;top:-1000px;">');
402 document.writeln('</span>');
403 document.getElementById('hdn'+rte).value = html;
404 enableDesignMode(rte, html, rte_css, readOnly);
407 if(fullscreen && height > 90) {
408 height = (height - 75);tablewidth=tablewidth-30;
410 // CM non-designMode() UI
411 html = parseBreaks(html);
412 document.writeln('<div style="font:12px Verdana, Arial, Helvetica, sans-serif;width: ' + tablewidth + 'px;padding:15px;">');
414 document.writeln('<div style="color:gray">'+lblnon_designMode+'</div><br>');
415 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>');
416 document.writeln('<textarea name="'+rte+'" id="'+rte+'" style="width: ' + tablewidth + 'px; height: ' + height + 'px;">' + html + '</textarea>');
418 document.writeln('<textarea name="'+rte+'" id="'+rte+'" style="width: ' + tablewidth + 'px; height: ' + height + 'px;" readonly=readonly>' + html + '</textarea>');
420 if(fullscreen) document.writeln('<br><input type="submit" value="'+btnText+'" />');
421 document.writeln('</div>');
425 function insertBar() {
426 document.writeln('<td><img class="rteBar" src="'+imagesPath+'bar.gif" alt=""></td>');
429 function insertSep() {
431 document.writeln('<td><img class="rteSep" src="'+imagesPath+'blackdot.gif" alt=""></td>');
435 function insertImg(name, image, command, id){
438 td = "<td id='"+id+"'>";
440 document.writeln(td+'<img class="rteImg" src="'+imagesPath+image+'" alt="'+name+'" title="'+name+'" onClick="'+command+';return false" onmouseover="this.className=\'rteImgUp\'" onmouseout="this.className=\'rteImg\'" onmousedown="this.className=\'rteImgDn\'" onmouseup="this.className=\'rteImgUp\'"></td>');
443 function enableDesignMode(rte, html, css, readOnly) {
444 var frameHtml = "<html dir='" + lang_direction + "' lang='" + lang + "' id='" + rte + "'>\n<head>\n";
445 frameHtml += "<meta http-equiv='Content-Type' content='text/html; charset=" + encoding + "'>\n";
446 frameHtml += "<meta http-equiv='Content-Language' content='" + lang + "'>\n";
447 //to reference your stylesheet, set href property below to your stylesheet path and uncomment
449 frameHtml += "<link media=\"all\" type=\"text/css\" href=\"" + css + "\" rel=\"stylesheet\">\n";
451 frameHtml += "<style>@charset \"utf-8\"; body {background:#FFFFFF;margin:8px;padding:0px;font-family:"+defaultFont+";font-size:"+defaultSize+";}</style>\n";
453 frameHtml += "</head><body>\n"+html+"\n</body></html>";
454 if(!isSafari && !isKonqueror) var oRTE = returnRTE(rte).document;
456 if(isSafari || isKonqueror) var oRTE = frames[rte].document;
457 oRTE.open("text/html","replace");
458 oRTE.write(frameHtml);
461 oRTE.designMode = "On";
465 // Commented out the following line to confront a bug when loading multiple RTEs on one page in a MOZ browser
466 // Fix provided by "Kings". Safari may have problems with this snytax - unable to test because I don't own a MAC.(Tim Bell)
468 // if(!readOnly) document.getElementById(rte).contentDocument.designMode = "on";
469 if(!readOnly && !isKonqueror && !isSafari) {
470 document.getElementById(rte).contentDocument.designMode = "on"; //RKV
471 addLoadEvent(function() { document.getElementById(rte).contentDocument.designMode = "on"; });
472 } else if(!readOnly) {
473 if (!readOnly) document.getElementById(rte).contentDocument.designMode = "on";
477 if(isSafari || isKonqueror) var oRTE = document.getElementById(rte).contentWindow.document;
478 oRTE.open("text/html","replace");
479 oRTE.write(frameHtml);
481 if(isGecko && !readOnly) {
482 //attach a keyboard handler for gecko browsers to make keyboard shortcuts work
483 oRTE.addEventListener("keypress", geckoKeyPress, true);
486 alert(lblErrorPreload);
489 //gecko may take some time to enable design mode.
490 //Keep looping until able to set.
496 setTimeout("enableDesignMode('"+rte+"', '"+html+"', '"+css+"', "+readOnly+ "','"+(timeLeft-200)+"');", 200);
503 setTimeout('showGuidelines("'+rte+'")',300);
506 function addLoadEvent(func) {
507 var oldonload = window.onload;
508 if (typeof window.onload != 'function') {
509 window.onload = func;
511 window.onload = function() {
518 function returnRTE(rte) {
523 rtn = document.getElementById(rte).contentWindow;
528 function updateRTE(rte) {
530 dlgCleanUp(); // Closes Pop-ups
531 stripGuidelines(rte); // Removes Table Guidelines
536 function updateRTEs(){
537 var vRTEs = allRTEs.split(";");
538 for(var i=0; i<vRTEs.length; i++){
543 function parseRTE(rte) {
545 autoBRoff(rte); // sorts out autoBR
548 //check for readOnly mode
549 var readOnly = false;
550 var oRTE = returnRTE(rte);
552 if(oRTE.document.designMode != "On"){
556 if(oRTE.document.designMode != "on"){
560 if(isRichText && !readOnly){
561 //if viewing source, switch back to design view
562 if(document.getElementById("_xtSrc"+rte).innerHTML == lblModeRichText){
563 if(document.getElementById("Buttons1_"+rte)){
564 toggleHTMLSrc(rte, true);
566 toggleHTMLSrc(rte, false);
568 stripGuidelines(rte);
574 function setHiddenVal(rte){
575 //set hidden form field value for current rte
576 var oHdnField = document.getElementById('hdn'+rte);
577 //convert html output to xhtml (thanks Timothy Bell and Vyacheslav Smolin!)
578 if(oHdnField.value==null){
579 oHdnField.value = "";
581 var sRTE = returnRTE(rte).document.body;
584 oHdnField.value = getXHTML(sRTE.innerHTML);
586 oHdnField.value = sRTE.innerHTML;
589 oHdnField.value = sRTE.innerHTML;
591 // fix to replace special characters added here:
592 oHdnField.value = replaceSpecialChars(oHdnField.value);
593 //if there is no content (other than formatting) set value to nothing
594 if(stripHTML(oHdnField.value.replace(" ", " ")) == "" &&
595 oHdnField.value.toLowerCase().search("<hr") == -1 &&
596 oHdnField.value.toLowerCase().search("<img") == -1){
597 oHdnField.value = "";
601 function rteCommand(rte, command, option){
603 //function to perform command
604 var oRTE = returnRTE(rte);
607 oRTE.document.execCommand(command, false, option);
611 // setTimeout("rteCommand('" + rte + "', '" + command + "', '" + option + "');", 10);
615 function toggleHTMLSrc(rte, buttons){
617 //contributed by Bob Hutzel (thanks Bob!)
618 var cRTE = document.getElementById(rte);
619 var hRTE = document.getElementById('hdn'+rte);
620 var sRTE = document.getElementById("size"+rte);
621 var tRTE = document.getElementById("_xtSrc"+rte);
622 var iRTE = document.getElementById("imgSrc"+rte);
623 var oRTE = returnRTE(rte).document;
626 obj_height = parseInt(sRTE.value);
630 if(tRTE.innerHTML == lblModeHTML){
631 //we are checking the box
632 tRTE.innerHTML = lblModeRichText;
633 stripGuidelines(rte);
635 showHideElement("Buttons1_" + rte, "hide", true);
636 if(document.getElementById("Buttons2_"+rte)){
637 showHideElement("Buttons2_" + rte, "hide", true);
638 cRTE.style.height = obj_height+56;
640 cRTE.style.height = obj_height+28;
645 oRTE.body.innerText = hRTE.value;
647 htmlSrc = oRTE.createTextNode(hRTE.value);
648 oRTE.body.innerHTML = "";
649 oRTE.body.appendChild(htmlSrc);
651 iRTE.innerHTML = '<img src="'+imagesPath+'design.gif" alt="Switch Mode" style="margin:1px;" align=absmiddle>';
653 //we are unchecking the box
654 obj_height = parseInt(cRTE.style.height);
655 tRTE.innerHTML = lblModeHTML;
657 showHideElement("Buttons1_" + rte, "show", true);
658 if(document.getElementById("Buttons2_"+rte)){
659 showHideElement("Buttons2_" + rte, "show", true);
660 cRTE.style.height = obj_height-56;
662 cRTE.style.height = obj_height-28;
667 var output = escape(oRTE.body.innerText);
668 output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E");
669 output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E");
670 oRTE.body.innerHTML = unescape(output);
671 // Disabled due to flaw in the regular expressions, this fix
672 // does not work with the revamped's enhanced insert link dialog window.
674 // Prevent links from changing to absolute paths
676 var tagfix = unescape(output).match(/<a[^>]*href=(['"])([^\1>]*)\1[^>]*>/ig);
677 var coll = oRTE.body.all.tags('A');
678 for(i=0; i<coll.length; i++){
679 // the 2 alerts below show when we hinder the links from becoming absolute
681 coll[i].href = tagfix[i].replace(/.*href=(['"])([^\1]*)\1.*/i,"$2");
682 //alert(RegExp.$1 + " " + RegExp.$2 + " " + RegExp.$3);
684 var imgfix = unescape(output).match(/<img[^>]*src=['"][^'"]*['"][^>]*>/ig);
685 var coll2 = oRTE.body.all.tags('IMG');
686 for(i=0; i<coll2.length; i++){
687 coll2[i].src = imgfix[i].replace(/.*src=['"]([^'"]*)['"].*/i,"$1");
692 htmlSrc = oRTE.body.ownerDocument.createRange();
693 htmlSrc.selectNodeContents(oRTE.body);
694 oRTE.body.innerHTML = htmlSrc.toString();
696 oRTE.body.innerHTML = replaceSpecialChars(oRTE.body.innerHTML);
698 // (IE Only)This prevents an undo operation from displaying a pervious HTML mode
699 // This resets the undo/redo buffer.
703 iRTE.innerHTML = '<img src="'+imagesPath+'code.gif" alt="Switch Mode" style="margin:1px;" align=absmiddle>';
707 function toggleSelection(rte) {
708 var rng = setRange(rte);
709 var oRTE = returnRTE(rte).document;
713 length1 = rng.text.length;
714 var output = escape(oRTE.body.innerText);
715 output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E");
716 output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E");
717 length2 = unescape(output).length;
719 length1 = rng.toString().length;
720 var htmlSrc = oRTE.body.ownerDocument.createRange();
721 htmlSrc.selectNodeContents(oRTE.body);
722 length2 = htmlSrc.toString().length;
724 if(length1 < length2){
725 rteCommand(rte,'selectall','');
728 oRTE.designMode = "off";
729 oRTE.designMode = "on";
731 rteCommand(rte,'unselect','');
736 function dlgColorPalette(rte, command) {
737 //function to display or hide color palettes
739 //get dialog position
740 var oDialog = document.getElementById('cp' + rte);
741 var buttonElement = document.getElementById(command+"_"+rte);
742 var iLeftPos = buttonElement.offsetLeft+5;
743 var iTopPos = buttonElement.offsetTop+53;
744 if (!document.getElementById('Buttons2_'+rte)){
745 iTopPos = iTopPos-28;
747 oDialog.style.left = iLeftPos + "px";
748 oDialog.style.top = iTopPos + "px";
750 if((command == parent.command)&&(rte == currentRTE)){
751 //if current command dialog is currently open, close it
752 if(oDialog.style.visibility == "hidden"){
753 showHideElement(oDialog, 'show', false);
755 showHideElement(oDialog, 'hide', false);
758 //if opening a new dialog, close all others
759 var vRTEs = allRTEs.split(";");
760 for(var i = 0; i<vRTEs.length; i++){
761 showHideElement('cp' + vRTEs[i], 'hide', false);
763 showHideElement(oDialog, 'show', false);
765 //save current values
767 parent.command = command;
770 function dlgLaunch(rte, command) {
771 var selectedText = '';
772 //save current values
773 parent.command = command;
777 InsertChar = popUpWin(includesPath+'insert_char.htm', 'InsertChar', 50, 50, 'status=yes,');
780 InsertTable = popUpWin(includesPath + 'insert_table.htm', 'InsertTable', 50, 50, 'status=yes,');
785 InsertImg = popUpWin(includesPath + 'insert_img.htm','AddImage', 50, 50, 'status=yes,');
788 selectedText = getText(rte);
789 InsertLink = popUpWin(includesPath + 'insert_link.htm', 'InsertLink', 50, 50, 'status=yes,');
790 setFormText("0", selectedText);
793 selectedText = getText(rte);
794 dlgReplace = popUpWin(includesPath + 'replace.htm', 'dlgReplace', 50, 50, 'status=yes,');
795 setFormText("1", selectedText);
798 dlgPasteText = popUpWin(includesPath + 'paste_text.htm', 'dlgPasteText', 50, 50, 'status=yes,');
801 dlgPasteWord = popUpWin(includesPath + 'paste_word.htm', 'dlgPasteWord', 50, 50, 'status=yes,');
806 function getText(rte) {
807 //get currently highlighted text and set link text value
811 rtn = stripHTML(rng.htmlText);
813 rtn = stripHTML(rng.toString());
817 rtn = rtn.replace("'","\\\\\\'");
819 rtn = rtn.replace("'","\\'");
824 function setFormText(popup, content, timeLeft){
825 //set link text value in dialog windows
826 if(content != "undefined")
830 case "0": InsertLink.document.getElementById("linkText").value = content; break;
831 case "1": dlgReplace.document.getElementById("searchText").value = content; break;
834 //may take some time to create dialog window.
835 //Keep looping until able to set.
840 setTimeout("setFormText('"+popup+"','" + content + "','"+(timeLeft-200)+"');", 200);
846 function dlgCleanUp(){
847 var vRTEs = allRTEs.split(";");
848 for(var i = 0; i < vRTEs.length; i++){
849 showHideElement('cp' + vRTEs[i], 'hide', false);
851 if(InsertChar != null){
855 if(InsertTable != null){
859 if(InsertLink != null){
863 if(InsertImg != null){
867 if(dlgReplace != null){
871 if(dlgPasteText != null){
872 dlgPasteText.close();
875 if(dlgPasteWord != null){
876 dlgPasteWord.close();
881 function popUpWin (url, win, width, height, options) {
883 var leftPos = (screen.availWidth - width) / 2;
884 var topPos = (screen.availHeight - height) / 2;
885 options += 'width=' + width + ',height=' + height + ',left=' + leftPos + ',top=' + topPos;
886 return window.open(url, win, options);
889 function setColor(color) {
890 //function to set color
891 var rte = currentRTE;
892 var parentCommand = parent.command;
894 if(parentCommand == "hilitecolor"){
895 parentCommand = "backcolor";
897 //retrieve selected range
900 rteCommand(rte, parentCommand, color);
901 showHideElement('cp'+rte, "hide", false);
904 function addImage(rte) {
906 //function to add image
907 imagePath = prompt('Enter Image URL:', 'http://');
908 if((imagePath != null)&&(imagePath != "")){
909 rteCommand(rte, 'InsertImage', imagePath);
913 function rtePrint(rte) {
916 document.getElementById(rte).contentWindow.document.execCommand('Print');
918 document.getElementById(rte).contentWindow.print();
922 function selectFont(rte, selectname){
923 //function to handle font changes
924 var idx = document.getElementById(selectname).selectedIndex;
925 // First one is always a label
927 var selected = document.getElementById(selectname).options[idx].value;
928 var cmd = selectname.replace('_'+rte, '');
929 rteCommand(rte, cmd, selected);
930 document.getElementById(selectname).selectedIndex = 0;
934 function insertHTML(html){
935 //function to add HTML -- thanks dannyuk1982
936 var rte = currentRTE;
937 var oRTE = returnRTE(rte);
940 var oRng = oRTE.document.selection.createRange();
941 oRng.pasteHTML(html);
942 oRng.collapse(false);
945 oRTE.document.execCommand('insertHTML', false, html);
949 function replaceHTML(tmpContent, searchFor, replaceWith) {
954 while(tmpContent.toUpperCase().indexOf(searchFor.toUpperCase()) > -1) {
955 runCount = runCount+1;
956 // Get all content before the match
957 intBefore = tmpContent.toUpperCase().indexOf(searchFor.toUpperCase());
958 tmpBefore = tmpContent.substring(0, intBefore);
959 tmpOutput = tmpOutput + tmpBefore;
960 // Get the string to replace
961 tmpOutput = tmpOutput + replaceWith;
962 // Get the rest of the content after the match until
963 // the next match or the end of the content
964 intAfter = tmpContent.length - searchFor.length + 1;
965 tmpContent = tmpContent.substring(intBefore + searchFor.length);
967 return runCount+"|^|"+tmpOutput+tmpContent;
970 function replaceSpecialChars(html){
971 var specials = new Array("¢","€","£","¤","¥","©","®","™","÷","×","±","¼","½","¾","°","¹","²","³","µ","«","»","‘","’","‹","›","‚","„","“","”","¡","¦","§","¬","¯","¶","·","¸","¿","ƒ","—","–","•","…","‰","ª","º","ß","†","‡","ð","Ð","ø","Ø","þ","Þ","œ","Œ","š","Š","´","ˆ","˜","¨","à","á","â","ã","ä","å","æ","À","Á","Â","Ã","Ä","Å","Æ","ç","Ç","è","é","ê","ë","È","É","Ê","Ë","ì","í","î","ï","Ì","Í","Î","Ï","ñ","Ñ","ò","ó","ô","õ","ö","Ò","Ó","Ô","Õ","Ö","ù","ú","û","ü","Ù","Ú","Û","Ü","ý","ÿ","Ý","Ÿ");
972 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");
973 for(var i=0; i<specials.length; i++){
974 html = replaceIt(html,unicodes[i],specials[i]);
979 function SearchAndReplace(searchFor, replaceWith, matchCase, wholeWord) {
980 var cfrmMsg = lblSearchConfirm.replace("SF",searchFor).replace("RW",replaceWith);
981 var rte = currentRTE;
982 stripGuidelines(rte);
983 var oRTE = returnRTE(rte);
984 var tmpContent = oRTE.document.body.innerHTML.replace("'", "\'").replace('"', '\"');
986 if (matchCase && wholeWord) {
987 strRegex = "/(?!<[^>]*)(\\b(" + searchFor + ")\\b)(?![^<]*>)/g";
989 else if (matchCase) {
990 strRegex = "/(?!<[^>]*)(" + searchFor + ")(?![^<]*>)/g";
992 else if (wholeWord) {
993 strRegex = "/(?!<[^>]*)(\\b(" + searchFor + ")\\b)(?![^<]*>)/gi";
995 strRegex = "/(?!<[^>]*)(" + searchFor + ")(?![^<]*>)/gi";
997 var cmpRegex=eval(strRegex);
999 var tmpNext = tmpContent;
1000 var intFound = tmpNext.search(cmpRegex);
1001 while(intFound > -1) {
1002 runCount = runCount+1;
1003 tmpNext = tmpNext.substr(intFound + searchFor.length);
1004 intFound = tmpNext.search(cmpRegex);
1007 cfrmMsg = cfrmMsg.replace("[RUNCOUNT]",runCount);
1008 if(confirm(cfrmMsg)) {
1009 tmpContent=tmpContent.replace(cmpRegex,replaceWith);
1010 oRTE.document.body.innerHTML = tmpContent.replace("\'", "'").replace('\"', '"');
1012 alert(lblSearchAbort);
1014 showGuidelines(rte);
1017 showGuidelines(rte);
1018 alert("["+searchFor+"] "+lblSearchNotFound);
1022 function showHideElement(element, showHide, rePosition){
1023 //function to show or hide elements
1024 //element variable can be string or object
1025 if(document.getElementById(element)){
1026 element = document.getElementById(element);
1028 if(showHide == "show"){
1029 element.style.visibility = "visible";
1031 element.style.position = "relative";
1032 element.style.left = "auto";
1033 element.style.top = "auto";
1035 }else if(showHide == "hide"){
1036 element.style.visibility = "hidden";
1038 element.style.position = "absolute";
1039 element.style.left = "-1000px";
1040 element.style.top = "-1000px";
1045 function setRange(rte){
1046 //function to store range of current selection
1047 var oRTE = returnRTE(rte);
1049 if(document.all){ //IE
1050 selection = oRTE.document.selection;
1051 if(selection != null){
1052 rng = selection.createRange();
1055 selection = oRTE.getSelection();
1056 if(selection.rangeCount > 0) {
1057 rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
1059 rng = oRTE.document.createRange();
1065 function stripHTML(strU) {
1067 var strN = strU.replace(/(<([^>]+)>)/ig,"");
1068 //replace carriage returns and line feeds
1069 strN = strN.replace(/\r\n/g," ");
1070 strN = strN.replace(/\n/g," ");
1071 strN = strN.replace(/\r/g," ");
1076 function trim(inputString) {
1077 if (typeof inputString != "string"){
1080 inputString = inputString.replace(/^\s+|\s+$/g, "").replace(/\s{2,}/g, "");
1084 function showGuidelines(rte) {
1085 if(rte.length == 0) rte = currentRTE;
1086 var oRTE = returnRTE(rte);
1087 var tables = oRTE.document.getElementsByTagName("table");
1088 var sty = "dashed 1px "+zeroBorder;
1089 for(var i=0; i<tables.length; i++){
1090 if(tables[i].getAttribute("border") == 0){
1092 var trs = tables[i].getElementsByTagName("tr");
1093 for(var j=0; j<trs.length; j++){
1094 var tds = trs[j].getElementsByTagName("td");
1095 for(var k=0; k<tds.length; k++){
1096 if(j == 0 && k == 0){
1097 tds[k].style.border = sty;
1098 }else if(j == 0 && k != 0){
1099 tds[k].style.borderBottom = sty;
1100 tds[k].style.borderTop = sty;
1101 tds[k].style.borderRight = sty;
1102 }else if(j != 0 && k == 0) {
1103 tds[k].style.borderBottom = sty;
1104 tds[k].style.borderLeft = sty;
1105 tds[k].style.borderRight = sty;
1106 }else if(j != 0 && k != 0) {
1107 tds[k].style.borderBottom = sty;
1108 tds[k].style.borderRight = sty;
1113 tables[i].removeAttribute("border");
1114 tables[i].setAttribute("style","border: " + sty);
1115 tables[i].setAttribute("rules", "all");
1121 function stripGuidelines(rte) {
1122 var oRTE = returnRTE(rte);
1123 var tbls = oRTE.document.getElementsByTagName("table");
1124 for(var j=0; j<tbls.length; j++) {
1125 if(tbls[j].getAttribute("border") == 0 || tbls[j].getAttribute("border") == null){
1127 var tds = tbls[j].getElementsByTagName("td");
1128 for(var k=0; k<tds.length; k++) {
1129 tds[k].removeAttribute("style");
1132 tbls[j].removeAttribute("style");
1133 tbls[j].removeAttribute("rules");
1134 tbls[j].setAttribute("border","0");
1140 function findSize(obj) {
1141 if(obj.length > 0 && document.all) {
1143 } else if(obj.length > 0 && !document.all) {
1144 obj = document.getElementById(obj).contentWindow;
1148 if ( typeof( obj.window.innerWidth ) == 'number' ) {
1150 obj_width = obj.window.innerWidth;
1151 obj_height = obj.window.innerHeight;
1152 } else if( obj.document.documentElement && ( obj.document.documentElement.clientWidth || obj.document.documentElement.clientHeight ) ) {
1153 //IE 6+ in 'standards compliant mode'
1154 obj_width = document.documentElement.clientWidth;
1155 obj_height = document.documentElement.clientHeight;
1156 } else if( obj.document.body && ( obj.document.body.clientWidth || obj.document.body.clientHeight ) ) {
1158 obj_width = obj.document.body.clientWidth;
1159 obj_height = obj.document.body.clientHeight;
1163 function resizeRTE() {
1164 document.body.style.overflow = "hidden";
1165 var rte = currentRTE;
1166 var oRTE = document.getElementById(rte);
1167 var oBut1 = document.getElementById('Buttons1_'+rte);
1169 var oVS = document.getElementById('vs'+rte);
1172 if (width < minWidth){
1173 document.body.style.overflow = "auto";
1176 var height = obj_height - 83;
1177 if (document.getElementById("_xtSrc"+rte).innerHTML == lblModeRichText){
1178 height = obj_height-28;
1179 if (!document.getElementById('Buttons2_'+rte) && width < wrapWidth) {
1180 document.body.style.overflow = "auto";
1183 if (document.getElementById('Buttons2_'+rte)){
1184 document.getElementById('Buttons2_'+rte).style.width = width;
1187 if (document.getElementById('Buttons2_'+rte)) {
1188 document.getElementById('Buttons2_'+rte).style.width = width;
1190 height = obj_height - 55;
1191 if(width < wrapWidth){
1192 document.body.style.overflow = "auto";
1197 if(document.body.style.overflow == "auto" && isIE){
1200 if(document.body.style.overflow == "auto" && !isIE){
1203 oBut1.style.width = width;
1204 oVS.style.width = width;
1205 oRTE.style.width = width-2;
1206 oRTE.style.height = height;
1208 oRTE.contentDocument.designMode = "on";
1212 function replaceIt(string,text,by) {
1213 // CM 19/10/04 custom replace function
1214 var strLength = string.length, _xtLength = text.length;
1215 if ((strLength == 0) || (_xtLength == 0)){
1218 var i = string.indexOf(text);
1219 if ((!i) && (text != string.substring(0,_xtLength))){
1225 var newstr = string.substring(0,i) + by;
1226 if(i+_xtLength < strLength){
1227 newstr += replaceIt(string.substring(i+_xtLength,strLength),text,by);
1232 function countWords(rte){
1234 var words = document.getElementById("hdn"+rte).value;
1235 var str = stripHTML(words);
1236 var chars = trim(words);
1237 chars = chars.length;
1238 chars = maxchar - chars;
1239 str = str+" a "; // word added to avoid error
1240 str = trim(str.replace(/ /gi,' ').replace(/([\n\r\t])/g,' ').replace(/&(.*);/g,' '));
1242 for(x=0;x<str.length;x++){
1243 if(str.charAt(x)==" " && str.charAt(x-1)!=" "){
1247 if(str.charAt(str.length-1) != " "){
1250 count = count - 1; // extra word removed
1253 alarm = "\n\n"+lblCountCharWarn;
1255 alert(lblCountTotal+": "+count+ "\n\n"+lblCountChar+": "+chars+alarm);
1258 //********************
1259 // Non-designMode() Functions
1260 //********************
1261 function autoBRon(rte) {
1262 // CM 19/10/04 used for non RTE browsers to deal with auto <BR> (and clean up other muck)
1263 var oRTE = document.forms[0].elements[rte];
1264 oRTE.value=parseBreaks(oRTE.value);
1265 oRTE.value=replaceIt(oRTE.value,''','\'');
1268 function autoBRoff(rte) {
1269 // CM 19/10/04 used for non RTE browsers to deal with auto <BR> (auto carried out when the form is submitted)
1270 var oRTE = document.forms[0].elements[rte];
1271 oRTE.value=replaceIt(oRTE.value,'\n','<br />');
1272 oRTE.value=replaceIt(oRTE.value,'\'',''');
1275 function parseBreaks(argIn) {
1276 // CM 19/10/04 used for non RTE browsers to deal with auto <BR> (and clean up other muck)
1277 argIn=replaceIt(argIn,'<br>','\n');
1278 argIn=replaceIt(argIn,'<BR>','\n');
1279 argIn=replaceIt(argIn,'<br/>','\n');
1280 argIn=replaceIt(argIn,'<br />','\n');
1281 argIn=replaceIt(argIn,'\t',' ');
1282 argIn=replaceIt(argIn,'\n ','\n');
1283 argIn=replaceIt(argIn,' <p>','<p>');
1284 argIn=replaceIt(argIn,'</p><p>','\n\n');
1285 argIn=replaceIt(argIn,''','\'');
1286 argIn = trim(argIn);
1290 //********************
1291 //Gecko-Only Functions
1292 //********************
1293 function geckoKeyPress(evt) {
1294 //function to add bold, italic, and underline shortcut commands to gecko RTEs
1295 //contributed by Anti Veeranna (thanks Anti!)
1296 var rte = evt.target.id;
1298 var key = String.fromCharCode(evt.charCode).toLowerCase();
1301 case 'b': cmd = "bold"; break;
1302 case 'i': cmd = "italic"; break;
1303 case 'u': cmd = "underline"; break;
1306 rteCommand(rte, cmd, null);
1307 // stop the event bubble
1308 evt.preventDefault();
1309 evt.stopPropagation();
1317 function checkspell() {
1319 //function to perform spell check
1321 var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
1322 tmpis.CheckAllLinkedDocuments(document);
1325 if(exception.number==-2146827859) {
1326 if(confirm("ieSpell not detected. Click Ok to go to download page.")){
1327 window.open("http://www.iespell.com/download.php","DownLoad");
1330 alert("Error Loading ieSpell: Exception " + exception.number);
1338 function enableRTEvalidation(rteName) {
1339 document.getElementById(rteName+'SaveButton').onclick = function(event){
1341 field = document.getElementById('hdn'+rteName);
1342 if(field.value != null && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)) {
1343 event.preventDefault();