<!--
    var isRichText = false;
    var rng;
    var currentRTE;
    var allRTEs = "";

    var isIE;
    var isGecko;
    var isSafari;
    var isKonqueror;

    var adminPath;
    var imagesPath;
    var includesPath;
    var cssFile;

    function initRTE(imgPath, incPath, admPath, css) {
        //set browser vars
        var ua = navigator.userAgent.toLowerCase();
        
        isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)); 
        isGecko = (ua.indexOf("gecko") != -1);
        isSafari = (ua.indexOf("safari") != -1);
        isKonqueror = (ua.indexOf("konqueror") != -1);
        
        //check to see if designMode mode is available
        if (document.getElementById && document.designMode && !isSafari && !isKonqueror) {
            isRichText = true;
        }
        
        if (isIE) {
            document.onmouseover = raiseButton;
            document.onmouseout  = normalButton;
            document.onmousedown = lowerButton;
            document.onmouseup   = raiseButton;
        }
        
        //set paths vars
        imagesPath = imgPath;
        includesPath = incPath;
        adminPath = admPath;
        
        cssFile = css;
    }

    function writeRichText(rte, html, width, height, buttons, readOnly) {
        /** IB debug */
        //ibAlert("inside writeRichText: "+ html);
        
        if (isRichText) {
            if(allRTEs.length>0) {
                allRTEs += ";";
            }
            
            allRTEs += rte;
            
            writeRTE(rte, html, width, height, buttons, readOnly);
        }
        else {
            writeDefault(rte, html, width, height, buttons, readOnly);
        }
    }
    
    function writeRichTextLimited(rte, html, width, height, buttons, readOnly) {
        if (isRichText) {
            if(allRTEs.length>0) {
                allRTEs += ";";
            }
            
            allRTEs += rte;
            
            writeRTELimited(rte, html, width, height, buttons, readOnly);
        }
        else {
            //writeDefault(rte, html, width, height, buttons, readOnly);
        }
    }

    function writeDefault(rte, html, width, height, buttons, readOnly) {
        if (!readOnly) {
            document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;" class="textarea_rte">' + html + 'sds</textarea>');
        } else {
            document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;" class="textarea_rte" readonly>' + html + 'dddddd</textarea>');
        }
    }

    function raiseButton(e) {
        //IE-Only Function
        var el = window.event.srcElement;
        
        className = el.className;
        if (className == 'rteImage' || className == 'rteImageLowered') {
            el.className = 'rteImageRaised';
        }
    }

    function normalButton(e) {
        //IE-Only Function
        var el = window.event.srcElement;
        
        className = el.className;
        if (className == 'rteImageRaised' || className == 'rteImageLowered') {
            el.className = 'rteImage';
        }
    }

    function lowerButton(e) {
        //IE-Only Function
        var el = window.event.srcElement;
        
        className = el.className;
        if (className == 'rteImage' || className == 'rteImageRaised') {
            el.className = 'rteImageLowered';
        }
    }
    
    function writeRTELimited(rte, html, width, height, buttons, readOnly) {
        if (readOnly) buttons = false;
        
        /** IB debug */
        //ibAlert("inside writeHTML: "+ html);
        
        document.writeln('<div class="rteDiv" align="center" width="'+ parseInt(parseInt(width) + 6) +'px" height="'+ parseInt(parseInt(height) + 6) +'px">');
        
        if(buttons == true) {
            document.writeln('<table class="rteBack" cellpadding="0" cellspacing="3" id="Buttons2_' + rte + '" width="' + width + '">');
            document.writeln('  <tr>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'cut.gif" alt="Cut" title="Cut" onClick="FormatText(\'' + rte + '\', \'cut\')"></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'copy.gif" alt="Copy" title="Copy" onClick="FormatText(\'' + rte + '\', \'copy\')"></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'paste.gif" alt="Paste" title="Paste" onClick="FormatText(\'' + rte + '\', \'paste\')"></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'undo.gif" alt="Undo" title="Undo" onClick="FormatText(\'' + rte + '\', \'undo\')"></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'redo.gif" alt="Redo" title="Redo" onClick="FormatText(\'' + rte + '\', \'redo\')"></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'left_just.gif"" alt="Align Left" title="Align Left" onClick="FormatText(\'' + rte + '\', \'justifyleft\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'centre.gif" alt="Center" title="Center" onClick="FormatText(\'' + rte + '\', \'justifycenter\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'right_just.gif" alt="Align Right" title="Align Right" onClick="FormatText(\'' + rte + '\', \'justifyright\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'justifyfull.gif" alt="Justify Full" title="Justify Full" onclick="FormatText(\'' + rte + '\', \'justifyfull\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'hyperlink.gif" alt="Insert Link" title="Insert Link" onClick="FormatText(\'' + rte + '\', \'createlink\')"/></td>');
            document.writeln('  </tr>');
            document.writeln('  <tr>');
            document.writeln('      <td align="center"><img id="bold" class="rteImage" src="' + imagesPath + 'fet.gif" alt="Bold" title="Bold" onClick="FormatText(\'' + rte + '\', \'bold\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'kursiv.gif" alt="Italic" title="Italic" onClick="FormatText(\'' + rte + '\', \'italic\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'understruken.gif" alt="Underline" title="Underline" onClick="FormatText(\'' + rte + '\', \'underline\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1"" border="0" alt=""></td>');
            document.writeln('      <td align="center"><div id="forecolor_' + rte + '"><img class="rteImage" src="' + imagesPath + 'textcolor.gif" width="25" height="24" alt="Text Color" title="Text Color" onClick="FormatText(\'' + rte + '\', \'forecolor\', \'\')"/></div></td>');
            document.writeln('      <td align="center"><div id="hilitecolor_' + rte + '"><img class="rteImage" src="' + imagesPath + 'bgcolor.gif" width="25" height="24" alt="Background Color" title="Background Color" onClick="FormatText(\'' + rte + '\', \'hilitecolor\', \'\')"/></div></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'numbered_list.gif" alt="Ordered List" title="Ordered List" onClick="FormatText(\'' + rte + '\', \'insertorderedlist\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'list.gif"" alt="Unordered List" title="Unordered List" onClick="FormatText(\'' + rte + '\', \'insertunorderedlist\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'outdent.gif" alt="Outdent" title="Outdent" onClick="FormatText(\'' + rte + '\', \'outdent\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'indent.gif" alt="Indent" title="Indent" onClick="FormatText(\'' + rte + '\', \'indent\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'hr.gif" alt="Horizontal Rule" title="Horizontal Rule" onClick="FormatText(\'' + rte + '\', \'inserthorizontalrule\', \'\')"/></td>');
            document.writeln('  </tr>');
            
            document.writeln('</table>');
        }
        
        document.writeln('<iframe frameborder="0" framespacing="0" class="iframe_rte" id="'+ rte +'" name="'+ rte +'" width="'+ width +'px" height="'+ height +'px" src="'+ adminPath +'blank.htm"></iframe>');
        
        if(!readOnly) {
            document.writeln('<table cellspacing="0" cellpadding="0">');
            document.writeln('    <tr>');
            document.writeln('        <td align="left">');
            document.writeln('            &nbsp;<input type="hidden" id="chkSrc'+ rte +'"/>');
            document.writeln('        </td>');
            document.writeln('    </tr>');
            document.writeln('</table>');
        }
        
        document.writeln('<iframe frameborder="1" framespacing="0" width="154" height="104" id="cp' + rte + '" src="'+ imagesPath +'palette.htm" marginwidth="0" marginheight="0" scrolling="no" style="visibility:hidden; display: none; position: absolute;"></iframe>');
        document.writeln('<input type="hidden" id="hdn' + rte + '" name="' + rte + '" value="">');
        document.writeln('</div>');
    
        document.getElementById('hdn' + rte).value = html;
    
        /** IB debug */
        //ibAlert("before enableDesignMode: "+ html);
        
        enableDesignMode(rte, html, readOnly);
    }
    
    function writeRTE(rte, html, width, height, buttons, readOnly) {
        if (readOnly) buttons = false;
        
        /** IB debug */
        //ibAlert("inside writeHTML: "+ html);
        
        document.writeln('<div class="rteDiv" align="center" width="'+ parseInt(parseInt(width) + 6) +'px" height="'+ parseInt(parseInt(height) + 6) +'px">');
        
        if(buttons == true) {
            document.writeln('<table class="rteBack" cellpadding="0" cellspacing="3" id="Buttons1_' + rte + '" width="' + width + '">');
            document.writeln('  <tr>');
            document.writeln('      <td align="left">');
            document.writeln('          <select class="select_rte" unselectable="on" id="formatblock_' + rte + '" onchange="Select(\'' + rte + '\', this.id);">');
            document.writeln('              <option>Style / Stil</option>');
            document.writeln('              <option></option>');
            document.writeln('              <option style="background-color: #f1f1f1;" value="<p>">•&nbsp;Normal&nbsp;</option>');
            document.writeln('              <option value="<h1>">•&nbsp;Heading&nbsp;1&nbsp;&nbsp;</option>');
            document.writeln('              <option style="background-color: #f1f1f1;" value="<h2>">•&nbsp;Heading&nbsp;2&nbsp;</option>');
            document.writeln('              <option value="<h3>">•&nbsp;Heading&nbsp;3&nbsp;</option>');
            document.writeln('              <option style="background-color: #f1f1f1;" value="<h4>">•&nbsp;Heading&nbsp;4&nbsp;</option>');
            document.writeln('              <option value="<h5>">•&nbsp;Heading&nbsp;5&nbsp;</option>');
            document.writeln('              <option></option>');
            document.writeln('          </select>');
            document.writeln('      </td>');
            document.writeln('      <td align="left">');
            document.writeln('          <select class="select_rte" unselectable="on" id="fontname_' + rte + '" onchange="Select(\'' + rte + '\', this.id)">');
            document.writeln('              <option>Font / Teckensnitt</option>');
            document.writeln('              <option></option>');
            document.writeln('              <option style="background-color: #f1f1f1;" value="Verdana, Arial, Helvetica, Sans-Serif">•&nbsp;Arial&nbsp;</option>');
            document.writeln('              <option value="Courier New, Courier, mono">•&nbsp;Courier New&nbsp;</option>');
            document.writeln('              <option style="background-color: #f1f1f1;" value="Times New Roman, Times, serif">•&nbsp;Times New Roman&nbsp;</option>');
            document.writeln('              <option value="Verdana, Arial, Helvetica, Sans-Serif">•&nbsp;Verdana&nbsp;</option>');
            document.writeln('              <option></option>');
            document.writeln('          </select>');
            document.writeln('      </td>');
            document.writeln('      <td align="left">');
            document.writeln('          <select class="select_rte" unselectable="on" id="fontsize_' + rte + '" onchange="Select(\'' + rte + '\', this.id);">');
            document.writeln('              <option>Size / Storlek</option>');
            document.writeln('              <option></option>');
            document.writeln('              <option style="background-color: #f1f1f1;" value="1">•&nbsp;10&nbsp;</option>');
            document.writeln('              <option value="2">•&nbsp;11&nbsp;</option>');
            document.writeln('              <option style="background-color: #f1f1f1;" value="3">•&nbsp;12&nbsp;</option>');
            document.writeln('              <option></option>');
            document.writeln('          </select>');
            document.writeln('      </td>');
            document.writeln('      <td width="100%">');
            document.writeln('      </td>');
            document.writeln('  </tr>');
            document.writeln('</table>');
            
            document.writeln('<table class="rteBack" cellpadding="0" cellspacing="3" id="Buttons2_' + rte + '" width="' + width + '">');
            document.writeln('  <tr>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'cut.gif" alt="Cut / Klipp ut" onClick="FormatText(\'' + rte + '\', \'cut\')"></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'copy.gif" alt="Copy / Kopiera" onClick="FormatText(\'' + rte + '\', \'copy\')"></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'paste.gif" alt="Paste / Klistra in" onClick="FormatText(\'' + rte + '\', \'paste\')"></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'undo.gif" alt="Undo / &Aring;ngra" onClick="FormatText(\'' + rte + '\', \'undo\')"></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'redo.gif" alt="Redo / G&ouml;r om" onClick="FormatText(\'' + rte + '\', \'redo\')"></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'left_just.gif"" alt="Align Left / V&auml;nsterst&auml;ll" onClick="FormatText(\'' + rte + '\', \'justifyleft\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'centre.gif" alt="Center / Centrera" onClick="FormatText(\'' + rte + '\', \'justifycenter\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'right_just.gif" alt="Align Right / H&ouml;gerst&auml;ll" onClick="FormatText(\'' + rte + '\', \'justifyright\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'justifyfull.gif" alt="Justify Full / Fulljustera" onclick="FormatText(\'' + rte + '\', \'justifyfull\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'hyperlink.gif" alt="Insert link / Infoga l&auml;nk" onClick="FormatText(\'' + rte + '\', \'createlink\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'image.gif" alt="Insert Image / Infoga bild" onClick="AddImage(\'' + rte + '\')"/></td>');
            document.writeln('      <td></td>');
            document.writeln('  </tr>');
            document.writeln('  <tr>');
            document.writeln('      <td align="center"><img id="bold" class="rteImage" src="' + imagesPath + 'fet.gif" alt="Bold / Fetstil" onClick="FormatText(\'' + rte + '\', \'bold\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'kursiv.gif" alt="Italic / Kursiv" onClick="FormatText(\'' + rte + '\', \'italic\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'understruken.gif" alt="Underline / Understruken" onClick="FormatText(\'' + rte + '\', \'underline\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1"" border="0" alt=""></td>');
            document.writeln('      <td align="center"><div id="forecolor_' + rte + '"><img class="rteImage" src="' + imagesPath + 'textcolor.gif" width="25" height="24" alt="Text Color / Textf&auml;rg" onClick="FormatText(\'' + rte + '\', \'forecolor\', \'\')"/></div></td>');
            document.writeln('      <td align="center"><div id="hilitecolor_' + rte + '"><img class="rteImage" src="' + imagesPath + 'bgcolor.gif" width="25" height="24" alt="Background Color / Bakgrundsf&auml;rg" onClick="FormatText(\'' + rte + '\', \'hilitecolor\', \'\')"/></div></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'numbered_list.gif" alt="Ordered List / Sorterad lista" onClick="FormatText(\'' + rte + '\', \'insertorderedlist\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'list.gif"" alt="Unordered List / Osorterad lista" onClick="FormatText(\'' + rte + '\', \'insertunorderedlist\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'outdent.gif" alt="Outdent / Utdrag" onClick="FormatText(\'' + rte + '\', \'outdent\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'indent.gif" alt="Indent / Indrag" onClick="FormatText(\'' + rte + '\', \'indent\', \'\')"/></td>');
            document.writeln('      <td align="center"><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" border="0" alt=""></td>');
            document.writeln('      <td align="center"><img class="rteImage" src="' + imagesPath + 'hr.gif" alt="Horizontal Rule / Horisontell linje" onClick="FormatText(\'' + rte + '\', \'inserthorizontalrule\', \'\')"/></td>');
            document.writeln('  </tr>');
            
            document.writeln('</table>');
        }
        
        document.writeln('<iframe frameborder="0" framespacing="0" class="iframe_rte" id="'+ rte +'" name="'+ rte +'" width="'+ width +'px" height="'+ height +'px" src="'+ adminPath +'blank.htm"></iframe>');
        
        if(!readOnly) {
            document.writeln('<table cellspacing="3" cellpadding="3">');
            document.writeln('    <tr>');
            document.writeln('        <td align="left">');
            document.writeln('            <img alt="" src="'+ adminPath +'images/html_f2.gif" align="left"/>');
            document.writeln('            <input type="checkbox" id="chkSrc'+ rte +'" onclick="javascript:toggleHTMLSrc(\''+ rte +'\');" align="left"/>');
            document.writeln('        </td>');
            document.writeln('    </tr>');
            document.writeln('</table>');
        }
        
        document.writeln('<iframe frameborder="1" framespacing="0" width="154" height="104" id="cp' + rte + '" src="'+ imagesPath +'palette.htm" marginwidth="0" marginheight="0" scrolling="no" style="visibility:hidden; display: none; position: absolute;"></iframe>');
        document.writeln('<input type="hidden" id="hdn' + rte + '" name="' + rte + '" value="">');
        document.writeln('</div>');
    
        document.getElementById('hdn' + rte).value = html;
    
        /** IB debug */
        //ibAlert("before enableDesignMode: "+ html);
        
        enableDesignMode(rte, html, readOnly);
    }
    
    function enableDesignMode(rte, html, readOnly) {
        var frameHtml = "<html>\n";
        
        frameHtml += "<head>\n";
        frameHtml += "    <base href=\""+ document.location.href.substring(0, document.location.href.indexOf("admin/")) +"\">\n";
        frameHtml += "    <link rel=\"stylesheet\" type=\"text/css\" src=\""+ cssFile +"\"/>\n";
        frameHtml += "</head>\n";
        frameHtml += "<body style=\"font-family: Verdana; font-size: 10px; margin: 1px 1px 1px 1px; padding: 1px 1px 1px 1px;\">\n";
        frameHtml += html + "\n";
        frameHtml += "</body>\n";
        frameHtml += "</html>";
        
        /** IB debug: */
        //ibAlert("inside enableDesignMode: "+ html);
        
        if (document.all) {
            var oRTE = frames[rte].document;
            
            oRTE.open();
                oRTE.write(frameHtml);
            oRTE.close();
            
            if(!readOnly) {
                oRTE.designMode = "On";
            }
        }
        else {
            try {
                if(!readOnly) {
                    document.getElementById(rte).contentDocument.designMode = "on";
                }
                
                try {
                    var oRTE = document.getElementById(rte).contentWindow.document;
                    
                    oRTE.open();
                        oRTE.write(frameHtml);
                    oRTE.close();
                    
                    if (isGecko && !readOnly) {
                        //attach a keyboard handler for gecko browsers to make keyboard shortcuts work
                        oRTE.addEventListener("keypress", kb_handler, true);
                    }
                }
                catch (e) {
                    ibAlert("Error preloading content.");
                }
            }
            catch (e) {
                //gecko may take some time to enable design mode.
                //Keep looping until able to set.
                if (isGecko) {
                    setTimeout("enableDesignMode('" + rte + "', '" + html + "', " + readOnly + ");", 10);
                }
                else {
                    return false;
                }
            }
        }
    }

    function updateRTEs() {
        var vRTEs = allRTEs.split(";");
        for (var i = 0; i < vRTEs.length; i++) {
            updateRTE(vRTEs[i]);
        }
    }

    function updateRTE(rte) {
        if (!isRichText) return;
        
        //set message value
        var oHdnMessage = document.getElementById('hdn' + rte);
        var oRTE = document.getElementById(rte);
        var readOnly = false;
        
        //check for readOnly mode
        if (document.all) {
            if (frames[rte].document.designMode != "On") readOnly = true;
        } else {
            if (document.getElementById(rte).contentDocument.designMode != "on") readOnly = true;
        }
        
        if (isRichText && !readOnly) {
            //if viewing source, switch back to design view
            if (document.getElementById("chkSrc" + rte).checked) {
                document.getElementById("chkSrc" + rte).checked = false;
                toggleHTMLSrc(rte);
            }
            
            if (oHdnMessage.value == null) oHdnMessage.value = "";
            if (document.all) {
                oHdnMessage.value = frames[rte].document.body.innerHTML;
            } else {
                oHdnMessage.value = oRTE.contentWindow.document.body.innerHTML;
            }
            
            //if there is no content (other than formatting) set value to nothing
            if (stripHTML(oHdnMessage.value.replace("&nbsp;", " ")) == "" 
                && oHdnMessage.value.toLowerCase().search("<hr") == -1
                && oHdnMessage.value.toLowerCase().search("<img") == -1) oHdnMessage.value = "";
            //fix for gecko
            if (escape(oHdnMessage.value) == "%3Cbr%3E%0D%0A%0D%0A%0D%0A") oHdnMessage.value = "";
        }
        
        //IB add XHTML conformance
        oHdnMessage.value = IB_formatXhtml(oHdnMessage.value);
    }

    function toggleHTMLSrc(rte) {
        var oRTE;
        
        if (document.all) {
            oRTE = frames[rte].document;
        }
        else {
            oRTE = document.getElementById(rte).contentWindow.document;
        }
        
        /** IB debug: */
        //ibAlert(oRTE.body.innerHTML);
                
        if (document.getElementById("chkSrc" + rte).checked) {
            document.getElementById("Buttons1_" + rte).style.visibility = "hidden";
            document.getElementById("Buttons2_" + rte).style.visibility = "hidden";
            
            if (document.all) {
                oRTE.body.innerText = oRTE.body.innerHTML;
            }
            else {
                var htmlSrc = oRTE.createTextNode(oRTE.body.innerHTML);
                
                oRTE.body.innerHTML = "";
                oRTE.body.appendChild(htmlSrc);
            }
        }
        else {
            document.getElementById("Buttons1_" + rte).style.visibility = "visible";
            document.getElementById("Buttons2_" + rte).style.visibility = "visible";
            
            if (document.all) {
                //fix for IE
                var output = escape(oRTE.body.innerText);
                
                output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E");
                output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E");
                
                oRTE.body.innerHTML = unescape(output);
            } else {
                var htmlSrc = oRTE.body.ownerDocument.createRange();
                htmlSrc.selectNodeContents(oRTE.body);
                oRTE.body.innerHTML = htmlSrc.toString();
            }
        }
    }

    //Function to format text in the text box
    function FormatText(rte, command, option) {
        var oRTE;
        
        if (document.all) {
            oRTE = frames[rte];
            
            //get current selected range
            var selection = oRTE.document.selection; 
            if (selection != null) {
                rng = selection.createRange();
            }
        }
        else {
            oRTE = document.getElementById(rte).contentWindow;
            
            //get currently selected range
            var selection = oRTE.getSelection();
            rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
        }
        
        try {
            if((command == "forecolor") || (command == "hilitecolor")) {
                //save current values
                parent.command = command;
                currentRTE = rte;
                
                //position and show color palette
                buttonElement = document.getElementById(command + '_' + rte);
                
                var iLeftPos = getOffsetLeft(buttonElement);
                var iTopPos = getOffsetTop(buttonElement) + (buttonElement.offsetHeight + 4);
                
                document.getElementById('cp' + rte).style.left = (iLeftPos) + "px";
                document.getElementById('cp' + rte).style.top = (iTopPos) + "px";
                
                if(document.getElementById('cp' + rte).style.visibility == "hidden") {
                    document.getElementById('cp' + rte).style.visibility = "visible";
                    document.getElementById('cp' + rte).style.display = "inline";
                }
                else {
                    document.getElementById('cp' + rte).style.visibility = "hidden";
                    document.getElementById('cp' + rte).style.display = "none";
                }
            }
            else if(command == "createlink") {
                var szUrl = prompt("  ftp://* | http://* | mms://*  ", document.location.href.substring(0, document.location.href.indexOf("/admin/")) +"/documents/system/upload/");
                
                if((szUrl != null) && (szUrl != "")) {
                    szUrl = szUrl.replace(/\'/g, "");
                    szUrl = szUrl.replace(/\"/g, "");
                    
                    oRTE.focus();
                        
                    if(szUrl.toLowerCase().indexOf("ftp://")==0 || szUrl.toLowerCase().indexOf("http://")==0 || szUrl.toLowerCase().indexOf("mms://")==0) {
                        try {
                            oRTE.document.execCommand("CreateLink", false, "javascript:openNewWin('"+ szUrl +"');");
                        }
                        catch(e) {
                            //do nothing
                        }
                      
                    }
                    else {
                        try {
                            oRTE.document.execCommand("CreateLink", false, szUrl);
                        }
                        catch(e) {
                            //do nothing
                        }
                    }
                    
                    oRTE.focus();
                }
            }
            else {
                oRTE.focus();
                oRTE.document.execCommand(command, false, option);
                
                oRTE.focus();
            }
        }
        catch(e) {
            ibAlert(e);
        }
    }

    //Function to set color
    function setColor(color) {
        var rte = currentRTE;
        var oRTE;
        if (document.all) {
            oRTE = frames[rte];
        } else {
            oRTE = document.getElementById(rte).contentWindow;
        }
        
        var parentCommand = parent.command;
        if (document.all) {
            //retrieve selected range
            var sel = oRTE.document.selection; 
            if (parentCommand == "hilitecolor") parentCommand = "backcolor";
            if (sel != null) {
                var newRng = sel.createRange();
                newRng = rng;
                newRng.select();
            }
        }
        oRTE.focus();
        oRTE.document.execCommand(parentCommand, false, color);
        oRTE.focus();
        document.getElementById('cp' + rte).style.visibility = "hidden";
        document.getElementById('cp' + rte).style.display = "none";
    }

    //Function to add image
    function AddImage(rte) {
        var oRTE;
        if (document.all) {
            oRTE = frames[rte];
            
            //get current selected range
            var selection = oRTE.document.selection; 
            if (selection != null) {
                rng = selection.createRange();
            }
        } else {
            oRTE = document.getElementById(rte).contentWindow;
            
            //get currently selected range
            var selection = oRTE.getSelection();
            rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
        }
        
        /*imagePath = prompt("Complete Web Image Name Reference \n *.jpeg | *.jpg | *.gif | *.png ", "http://");
        
        if ((imagePath != null) && (imagePath != "")) {
            oRTE.focus();
            oRTE.document.execCommand('InsertImage', false, imagePath);
            oRTE.focus();
        }*/
        
        var imagePath = prompt("  *.gif | *.jpg | *.png  ", document.location.href.substring(0, document.location.href.indexOf("/admin/")) +"/images/system/upload/");
        
        if((imagePath != null) && (imagePath != "") && (imagePath.toLowerCase().indexOf("http://")>=0)) {
            imagePath = imagePath.replace(/\'/g, "");
            imagePath = imagePath.replace(/\"/g, "");
            
            if(imagePath.toLowerCase().indexOf(".gif")>0 || imagePath.toLowerCase().indexOf(".jpg")>0 || imagePath.toLowerCase().indexOf(".png")>0) {
                oRTE.focus();
                
                try {
                    oRTE.document.execCommand('InsertImage', false, imagePath.toLowerCase());
                }
                catch(e) {
                    //do nothing
                }
                
                oRTE.focus();
            }
        }
    }

    //function to perform spell check
    function checkspell() {
        try {
            var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
            tmpis.CheckAllLinkedDocuments(document);
        }
        catch(exception) {
            if(exception.number==-2146827859) {
                if (ibConfirm("ieSpell not detected.  Click Ok to go to download page."))
                    window.open("http://www.iespell.com/download.php","DownLoad");
            } else {
                ibAlert("Error Loading ieSpell: Exception " + exception.number);
            }
        }
    }

    // Ernst de Moor: Fix the amount of digging parents up, in case the RTE editor itself is displayed in a div.
    // KJR 11/12/2004 Changed to position palette based on parent div, so palette will always appear in proper location regardless of nested divs
    function getOffsetTop(elm) {
        var mOffsetTop = elm.offsetTop;
        var mOffsetParent = elm.offsetParent;
        var parents_up = 2; //the positioning div is 2 elements up the tree
        
        while(parents_up > 0) {
            mOffsetTop += mOffsetParent.offsetTop;
            mOffsetParent = mOffsetParent.offsetParent;
            parents_up--;
        }
        
        return mOffsetTop;
    }

    // Ernst de Moor: Fix the amount of digging parents up, in case the RTE editor itself is displayed in a div.
    // KJR 11/12/2004 Changed to position palette based on parent div, so palette will always appear in proper location regardless of nested divs
    function getOffsetLeft(elm) {
        var mOffsetLeft = elm.offsetLeft;
        var mOffsetParent = elm.offsetParent;
        var parents_up = 2;
        
        while(parents_up > 0) {
            mOffsetLeft += mOffsetParent.offsetLeft;
            mOffsetParent = mOffsetParent.offsetParent;
            parents_up--;
        }
        
        return mOffsetLeft;
    }

    function Select(rte, selectname) {
        var oRTE;
        if (document.all) {
            oRTE = frames[rte];
            
            //get current selected range
            var selection = oRTE.document.selection; 
            if (selection != null) {
                rng = selection.createRange();
            }
        } else {
            oRTE = document.getElementById(rte).contentWindow;
            
            //get currently selected range
            var selection = oRTE.getSelection();
            rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
        }
        
        var idx = document.getElementById(selectname).selectedIndex;
        // First one is always a label
        if (idx != 0) {
            var selected = document.getElementById(selectname).options[idx].value;
            var cmd = selectname.replace('_' + rte, '');
            oRTE.focus();
            oRTE.document.execCommand(cmd, false, selected);
            oRTE.focus();
            document.getElementById(selectname).selectedIndex = 0;
        }
    }

    function kb_handler(evt) {
        var rte = evt.target.id;
        
        if (evt.ctrlKey) {
            var key = String.fromCharCode(evt.charCode).toLowerCase();
            var cmd = '';
            switch (key) {
                case 'b': cmd = "bold"; break;
                case 'i': cmd = "italic"; break;
                case 'u': cmd = "underline"; break;
            };

            if (cmd) {
                FormatText(rte, cmd, true);
                //evt.target.ownerDocument.execCommand(cmd, false, true);
                // stop the event bubble
                evt.preventDefault();
                evt.stopPropagation();
            }
        }
    }

    function docChanged (evt) {
        ibAlert('changed');
    }

    function stripHTML(oldString) {
        var newString = oldString.replace(/(<([^>]+)>)/ig,"");
        
        //replace carriage returns and line feeds
        newString = newString.replace(/\r\n/g," ");
        newString = newString.replace(/\n/g," ");
        newString = newString.replace(/\r/g," ");
        
        //trim string
        newString = trim(newString);
        
        return newString;
    }

    function trim(inputString) {
    // Removes leading and trailing spaces from the passed string. Also removes
    // consecutive spaces and replaces it with one space. If something besides
    // a string is passed in (null, custom object, etc.) then return the input.
    if (typeof inputString != "string") return inputString;
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
        
    while (ch == " ") { // Check for spaces at the beginning of the string
        retValue = retValue.substring(1, retValue.length);
        ch = retValue.substring(0, 1);
    }
    ch = retValue.substring(retValue.length - 1, retValue.length);
        
    while (ch == " ") { // Check for spaces at the end of the string
        retValue = retValue.substring(0, retValue.length - 1);
        ch = retValue.substring(retValue.length - 1, retValue.length);
    }
        
        // Note that there are two spaces in the string - look for multiple spaces within the string
    while (retValue.indexOf("  ") != -1) {
            // Again, there are two spaces in each of the strings
        retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ") + 1, retValue.length);
    }
    return retValue; // Return the trimmed string back to the user
    }

    function IB_formatXhtml(str) {
        if(str!="") {
            str = str.replace(/<BLOCKQUOTE/g, "<blockquote");
            str = str.replace(/<\/BLOCKQUOTE>/g, "<\/blockquote>");
            
            str = str.replace(/MARGIN-LEFT:/g, "margin-left:");
            str = str.replace(/MARGIN-TOP:/g, "margin-top:");
            str = str.replace(/MARGIN-RIGHT:/g, "margin-right:");
            str = str.replace(/MARGIN-BOTTOM:/g, "margin-bottom:");
            
            str = str.replace(/PADDING-LEFT:/g, "padding-left:");
            str = str.replace(/PADDING-TOP:/g, "padding-top:");
            str = str.replace(/PADDING-RIGHT:/g, "padding-right:");
            str = str.replace(/PADDING-BOTTOM:/g, "padding-bottom:");
            
            str = str.replace(/BACKGROUND-COLOR:/g, "background-color:");
            str = str.replace(/COLOR:/g, "color:");
            
            str = str.replace(/<TEXTAREA/g, "<textarea");
            str = str.replace(/<\/TEXTAREA>/g, "<\/textarea>");
            
            str = str.replace(/WIDTH:/g, "width:");
            str = str.replace(/HEIGHT:/g, "height:");
            
            str = str.replace(/STRONG>/g, "b>");
            
            str = str.replace(/<IMG/g, "<img");
            str = str.replace(/<INPUT/g, "<input");
            
            str = str.replace(/<FORM/g, "<form");
            str = str.replace(/<\/FORM>/g, "<\/form>");
            
            str = str.replace(/<FONT/g, "<font");
            str = str.replace(/<\/FONT>/g, "<\/font>");
            
            str = str.replace(/<SPAN/g, "<span");
            str = str.replace(/<\/SPAN>/g, "<\/span>");
            
            str = str.replace(/<DIV/g, "<div");
            str = str.replace(/<\/DIV>/g, "<\/div>");
            
            str = str.replace(/<LAYER/g, "<layer");
            str = str.replace(/<\/LAYER>/g, "<\/layer>");
            
            str = str.replace(/<ILAYER/g, "<ilayer");
            str = str.replace(/<\/ILAYER>/g, "<\/ilayer>");
            
            str = str.replace(/<A HREF/g, "<a href");
            
            str = str.replace(/<HR>/g, "<hr/>");
            
            str = str.replace(/<BR>/g, "<br/>");
            str = str.replace(/<BR\/>/g, "<br/>");
            
            str = str.replace(/<UL/g, "<ul");
            str = str.replace(/<\/UL>/g, "<\/ul>");
            
            str = str.replace(/<OL/g, "<ol");
            str = str.replace(/<\/OL>/g, "<\/ol>");
            
            str = str.replace(/<LI/g, "<li");
            str = str.replace(/<\/LI>/g, "<\/li>");
            
            str = str.replace(/<P/g, "<p");
            str = str.replace(/<\/P>/g, "<\/p>");
            
            str = str.replace(/<EM>/g, "<em>");
            str = str.replace(/<\/EM>/g, "<\/em>");
            
            str = str.replace(/<B/g, "<b");
            str = str.replace(/<\/B>/g, "<\/b>");
            
            str = str.replace(/<I/g, "<i");
            str = str.replace(/<\/I>/g, "<\/i>");
            
            str = str.replace(/<U/g, "<u");
            str = str.replace(/<\/U>/g, "<\/u>");
            
            str = str.replace(/<A/g, "<a");
            str = str.replace(/<\/A>/g, "<\/a>");
            
            str = str.replace(/<H5 align=\"left\"/g, "<h5");
            str = str.replace(/<H5 align=\"center\"/g, "<h5");
            str = str.replace(/<H5 align=\"right\"/g, "<h5");
            
            str = str.replace(/<H4 align=\"left\"/g, "<h4");
            str = str.replace(/<H4 align=\"center\"/g, "<h4");
            str = str.replace(/<H4 align=\"right\"/g, "<h4");
            
            str = str.replace(/<H3 align=\"left\"/g, "<h3");
            str = str.replace(/<H3 align=\"center\"/g, "<h3");
            str = str.replace(/<H3 align=\"right\"/g, "<h3");
            
            str = str.replace(/<H2 align=\"left\"/g, "<h2");
            str = str.replace(/<H2 align=\"center\"/g, "<h2");
            str = str.replace(/<H2 align=\"right\"/g, "<h2");
                        
            str = str.replace(/<H1 align=\"left\"/g, "<h1");
            str = str.replace(/<H1 align=\"center\"/g, "<h1");
            str = str.replace(/<H1 align=\"right\"/g, "<h1");
                        
            str = str.replace(/<H5>/g, "<h5>");
            str = str.replace(/<H4>/g, "<h4>");
            str = str.replace(/<H3>/g, "<h3>");
            str = str.replace(/<H2>/g, "<h2>");
            str = str.replace(/<H1>/g, "<h1>");

            str = str.replace(/<\/H5>/g, "</h5>");
            str = str.replace(/<\/H4>/g, "</h4>");
            str = str.replace(/<\/H3>/g, "</h3>");
            str = str.replace(/<\/H2>/g, "</h2>");
            str = str.replace(/<\/H1>/g, "</h1>");
            
            str = str.replace(/\=top/g, "\=\"top\"");
            str = str.replace(/\=middle/g, "\=\"middle\"");
            str = str.replace(/\=bottom/g, "\=\"bottom\"");
            str = str.replace(/\=center/g, "\=\"center\"");
            str = str.replace(/\=right/g, "\=\"right\"");
            str = str.replace(/\=left/g, "\=\"left\"");
            str = str.replace(/\=0 /g, "\=\"0\" ");
            str = str.replace(/\=1 /g, "\=\"1\" ");
            str = str.replace(/\=2 /g, "\=\"2\" ");
            str = str.replace(/\=3 /g, "\=\"3\" ");
            str = str.replace(/\=4 /g, "\=\"4\" ");
            str = str.replace(/\=5 /g, "\=\"5\" ");
            str = str.replace(/\=0>/g, "\=\"0\">");
            str = str.replace(/\=1>/g, "\=\"1\">");
            str = str.replace(/\=2>/g, "\=\"2\">");
            str = str.replace(/\=3>/g, "\=\"3\">");
            str = str.replace(/\=4>/g, "\=\"4\">");
            str = str.replace(/\=5>/g, "\=\"5\">");
            str = str.replace(/\=0\/>/g, "\=\"0\"/>");
            str = str.replace(/\=1\/>/g, "\=\"1\"/>");
            str = str.replace(/\=2\/>/g, "\=\"2\"/>");
            str = str.replace(/\=3\/>/g, "\=\"3\"/>");
            str = str.replace(/\=4\/>/g, "\=\"4\"/>");
            str = str.replace(/\=5\/>/g, "\=\"5\"/>");
            str = str.replace(/\=0>/g, "\=\"0\">");
            str = str.replace(/\=1>/g, "\=\"1\">");
            str = str.replace(/\=2>/g, "\=\"2\">");
            str = str.replace(/\=3>/g, "\=\"3\">");
            str = str.replace(/\=4>/g, "\=\"4\">");
            str = str.replace(/\=5>/g, "\=\"5\">");
            str = str.replace(/ dir\=ltr/g, " dir\=\"ltr\"");
            str = str.replace(/ dir\=rtl/g, " dir\=\"rtl\"");

            str = str.replace(/ height\=0/g, " height\=\"0");
            str = str.replace(/ height\=1/g, " height\=\"1");
            str = str.replace(/ height\=2/g, " height\=\"2");
            str = str.replace(/ height\=3/g, " height\=\"3");
            str = str.replace(/ height\=4/g, " height\=\"4");
            str = str.replace(/ height\=5/g, " height\=\"5");
            str = str.replace(/ height\=6/g, " height\=\"6");
            str = str.replace(/ height\=7/g, " height\=\"7");
            str = str.replace(/ height\=8/g, " height\=\"8");
            str = str.replace(/ height\=9/g, " height\=\"9");

            str = str.replace(/ width\=0/g, " width\=\"0");
            str = str.replace(/ width\=1/g, " width\=\"1");
            str = str.replace(/ width\=2/g, " width\=\"2");
            str = str.replace(/ width\=3/g, " width\=\"3");
            str = str.replace(/ width\=4/g, " width\=\"4");
            str = str.replace(/ width\=5/g, " width\=\"5");
            str = str.replace(/ width\=6/g, " width\=\"6");
            str = str.replace(/ width\=7/g, " width\=\"7");
            str = str.replace(/ width\=8/g, " width\=\"8");
            str = str.replace(/ width\=9/g, " width\=\"9");

            str = str.replace(/0\/>/g, "0\"\/>");
            str = str.replace(/1\/>/g, "1\"\/>");
            str = str.replace(/2\/>/g, "2\"\/>");
            str = str.replace(/3\/>/g, "3\"\/>");
            str = str.replace(/4\/>/g, "4\"\/>");
            str = str.replace(/5\/>/g, "5\"\/>");
            str = str.replace(/6\/>/g, "6\"\/>");
            str = str.replace(/7\/>/g, "7\"\/>");
            str = str.replace(/8\/>/g, "8\"\/>");
            str = str.replace(/9\/>/g, "9\"\/>");

            str = str.replace(/0>/g, "0\">");
            str = str.replace(/1>/g, "1\">");
            str = str.replace(/2>/g, "2\">");
            str = str.replace(/3>/g, "3\">");
            str = str.replace(/4>/g, "4\">");
            str = str.replace(/5>/g, "5\">");
            str = str.replace(/6>/g, "6\">");
            str = str.replace(/7>/g, "7\">");
            str = str.replace(/8>/g, "8\">");
            str = str.replace(/9>/g, "9\">");

            //if errors from above...
            str = str.replace(/h1\">/g, "h1>");
            str = str.replace(/h2\">/g, "h2>");
            str = str.replace(/h3\">/g, "h3>");
            str = str.replace(/h4\">/g, "h4>");
            str = str.replace(/h5\">/g, "h5>");

            str = str.replace(/0 alt\=/g, "0\" alt\=");
            str = str.replace(/1 alt\=/g, "1\" alt\=");
            str = str.replace(/2 alt\=/g, "2\" alt\=");
            str = str.replace(/3 alt\=/g, "3\" alt\=");
            str = str.replace(/4 alt\=/g, "4\" alt\=");
            str = str.replace(/5 alt\=/g, "5\" alt\=");
            str = str.replace(/6 alt\=/g, "6\" alt\=");
            str = str.replace(/7 alt\=/g, "7\" alt\=");
            str = str.replace(/8 alt\=/g, "8\" alt\=");
            str = str.replace(/9 alt\=/g, "9\" alt\=");

            str = str.replace(/0 src\=/g, "0\" src\=");
            str = str.replace(/1 src\=/g, "1\" src\=");
            str = str.replace(/2 src\=/g, "2\" src\=");
            str = str.replace(/3 src\=/g, "3\" src\=");
            str = str.replace(/4 src\=/g, "4\" src\=");
            str = str.replace(/5 src\=/g, "5\" src\=");
            str = str.replace(/6 src\=/g, "6\" src\=");
            str = str.replace(/7 src\=/g, "7\" src\=");
            str = str.replace(/8 src\=/g, "8\" src\=");
            str = str.replace(/9 src\=/g, "9\" src\=");
            
            str = str.replace(/0\"\">/g, "0\">");
            str = str.replace(/1\"\">/g, "1\">");
            str = str.replace(/2\"\">/g, "2\">");
            str = str.replace(/3\"\">/g, "3\">");
            str = str.replace(/4\"\">/g, "4\">");
            str = str.replace(/5\"\">/g, "5\">");
            str = str.replace(/6\"\">/g, "6\">");
            str = str.replace(/7\"\">/g, "7\">");
            str = str.replace(/8\"\">/g, "8\">");
            str = str.replace(/9\"\">/g, "9\">");
                        
            str = str.replace(/0\"\" >/g, "0\">");
            str = str.replace(/1\"\" >/g, "1\">");
            str = str.replace(/2\"\" >/g, "2\">");
            str = str.replace(/3\"\" >/g, "3\">");
            str = str.replace(/4\"\" >/g, "4\">");
            str = str.replace(/5\"\" >/g, "5\">");
            str = str.replace(/6\"\" >/g, "6\">");
            str = str.replace(/7\"\" >/g, "7\">");
            str = str.replace(/8\"\" >/g, "8\">");
            str = str.replace(/9\"\" >/g, "9\">");
            
            str = str.replace(/0\"\"\/>/g, "0\"\/>");
            str = str.replace(/1\"\"\/>/g, "1\"\/>");
            str = str.replace(/2\"\"\/>/g, "2\"\/>");
            str = str.replace(/3\"\"\/>/g, "3\"\/>");
            str = str.replace(/4\"\"\/>/g, "4\"\/>");
            str = str.replace(/5\"\"\/>/g, "5\"\/>");
            str = str.replace(/6\"\"\/>/g, "6\"\/>");
            str = str.replace(/7\"\"\/>/g, "7\"\/>");
            str = str.replace(/8\"\"\/>/g, "8\"\/>");
            str = str.replace(/9\"\"\/>/g, "9\"\/>");
            
            str = str.replace(/0\"\"\/ >/g, "0\"\/>");
            str = str.replace(/1\"\"\/ >/g, "1\"\/>");
            str = str.replace(/2\"\"\/ >/g, "2\"\/>");
            str = str.replace(/3\"\"\/ >/g, "3\"\/>");
            str = str.replace(/4\"\"\/ >/g, "4\"\/>");
            str = str.replace(/5\"\"\/ >/g, "5\"\/>");
            str = str.replace(/6\"\"\/ >/g, "6\"\/>");
            str = str.replace(/7\"\"\/ >/g, "7\"\/>");
            str = str.replace(/8\"\"\/ >/g, "8\"\/>");
            str = str.replace(/9\"\"\/ >/g, "9\"\/>");
            
            str = str.replace(/>>/g, ">");
            str = str.replace(/<</g, "<");
            
            //leave the hr/img/input work to the saving script
        }

        return str;
    }
//-->