/*
KOIVI TTW WYSIWYG Editor Copyright (C) 2005 Justin Koivisto
Version 4.0b3
Last Modified: 4/3/2006

    This library is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2.1 of the License, or (at
    your option) any later version.

    This library is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
    License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this library; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

    Full license agreement notice can be found in the LICENSE file contained
    within this distribution package.

    Justin Koivisto
    justin.koivisto@gmail.com
    http://koivi.com
*/

/**
*   WYSIWYG_Editor
*
*   Class constructor. Configures and displays the editor object according to values passed
*   This is an implementation of OO-Javascript based on my previous editor, now with object
*   detection instead of using any kind of browser sniffing at all. Makes for larger source,
*   is easier to maintain, and any browsers that suddenly get support for this will automatically
*   work without modification to this file.
*
*   @param  instance_name   string  the name of the variable you assigned to this instance ( example: myEdt = new WYSIWYG_Editor('myEdt'); )
*                                   also used as the basis for the name and id attributes for this editor instance in the HTML (hidden input and iframe)
*   @param  content         string  a string of the content to display in the editor.
*   @param  path            string  the URI path to this directory to use for editor components (pallete, iamges, etc.)
*   @param  fwidth          int     the width in pixels of the editor interface on the screen
*   @param  fheight         int     the height in pixels of the editor interface on the screen
*   @param  styleHref       string  the URI of the stylesheet to use for the editor's content window
*   @param  spellCheckPath  string  the URI of the spellerpages install
**/
function WYSIWYG_Editor(instance_name, content, path, fwidth, fheight, styleHref, spellCheckPath, langModule){
    // for each of the passed parameters, we need to be sure they are defined, or we will use a default value

    // the name used to create the object - used to define the name of the field that contains the HTML on submission
    if(typeof(instance_name)=='undefined' || instance_name==null){
        alert("ERROR: No instance name was passed for the editor.");
        return false;
    }else{
        this.instance_name=instance_name;
    }

    // the initial HTML source content for the editor
    if(typeof(content)=='undefined' || content==null){
        this.content='';
    }else{
        this.content=content;
    }

    // define the path to use for the editor components like images
    if(typeof(path)=='undefined' || path==null){
        this.wysiwyg_path='.'; // default value
    }else{
        path.replace(/[\/\\]$/,''); // remove trailing slashes
        this.wysiwyg_path=path;
    }

    // define the pixel dimensions of the editor
    if(typeof(fwidth)=='number' && Math.round(fwidth) > 50){
        this.frame_width=Math.round(fwidth);
    }else{
        this.frame_width=525; // default width
    }
    if(typeof(fheight)=='number' && Math.round(fheight) > 50){
        this.frame_height=Math.round(fheight);
    }else{
        this.frame_height=250; // default height
    }

    // define the stylesheet to use for the editor components like images
    if(typeof(styleHref)=='undefined' || styleHref==null){
        this.stylesheet=''; // default value
    }else{
        this.stylesheet=styleHref;
    }

    if(typeof(spellCheckPath)=='undefined' || spellCheckPath==null){
        this.spell_path=''; // default value
    }else{
        // show spell check button requires Speller Pages (http://spellerpages.sourceforge.net/)
        this.spell_path=spellCheckPath;
    }
  
    if(typeof(langModule)!='object' || langModule.LANGUAGE==null){
        // this simply indicates that the language module was not sent to the constructor
        // the alert has been removed because you can still set it my using something like:
        // editor1.lang = WYSIWYG_Editor_Lang_EN;
        // after you call the constructor.
//        alert('Language module cannot be loaded');
    }else{
        // we're guessing that the passed langModule is what we are really looking for...
        this.lang = langModule;
    }

    // choose which method you are going to use... there is php, ColdFusion and
    // cgi/perl that comes with spellerpages you will need to customize that script.
    // In this instance, the PHP script has been configured to accept settings
    // via query string which is not supported by the default script provided as spellchecker.php
    this.spellCheckScript = this.spell_path+'/server-scripts/spellchecker.php?spellercss='+this.spell_path+'/spellerStyle.css&word_win_src='+this.spell_path+'/wordWindow.js';
                
    // properties that depended on the validated values above
    this.wysiwyg_content=this.instance_name+'_WYSIWYG_Editor';  // the editor IFRMAE element id
    this.wysiwyg_hidden=this.instance_name+'_content';          // the editor's hidden field to store the HTML in for the post
    this.wysiwyg_speller=this.instance_name+'_speller';         // the editor's hidden textarea to store the HTML in for the spellchecker
    this.ta_rows=Math.round(this.frame_height/15);              // number of rows for textarea for unsupported browsers
    this.ta_cols=Math.round(this.frame_width/8);                // number of cols for textarea for unsupported browsers

    // other property defaults
    this.viewMode=1;                                        // by default, set to design view
    this._X = this._Y = 0;                                  // these are used to determine mouse position when clicked

    // the folloing properties are safe to set through the object variable, for example:
    //  var editor = new WYSIWYG_Editor('editor');
    //  editor.allow_mode_toggle = false;
    // below are just the defaults that I use most of the time

    // preview popup window size defaults
    this.prevWin_width=640;
    this.prevWin_height=480;

    // insert table defaults
    this.table_border = 1;                                  // default border used when inserting tables
    this.table_cell_padding = 3;                            // default cellpadding used when inserting tables
    this.table_cell_spacing = 0;                            // default cellspacing used when inserting tables

    // tool bar display
    // row 1:
    this.allow_mode_toggle = true;                          // allow users to switch to source code mode
    this.web_toolbar1 = true;                               // buttons for add, remove hyperlinks
    this.web_toolbar2 = true;                               // buttons for ordered, unordered lists
    this.web_toolbar3 = true;                               // buttons for horizontal rule, insert table
    this.web_toolbar4 = true;                               // buttons for insert image and save (submit form)

    // row 2:
    this.font_format_toolbar1 = true;                       // buttons for font family, size, and style
    this.font_format_toolbar2 = true;                       // buttons for font color and background-color
    this.font_format_toolbar3 = true;                       // buttons for bold, italic, underline
    this.font_format_toolbar4 = true;                       // buttons for superscript, subscript
    this.alignment_toolbar1 = true;                         // buttons for left, center, right, full justify
    this.alignment_toolbar2 = true;                         // buttons for indent, outdent

    // this button is not implemented on the version for koivi.com
    // it is only currently available in WAFCMS (being developed as a
    // proprietary CMS currently). If enabled, an insert-image button
    // will appear in web_toolbar4 which calls the InsertImage method
    // See http://koivi.com/WYSIWYG-Editor/SAMPLE-image_dialog.phps
    // for an example of how this can work
    this.image_button = true;
    this.image_button = false;

    // this makes a save icon that submits the form in web_toolbar4
    this.save_button = true;
    
    // this displays the button so the users can preview the content in a pop-up window
    this.preview_button = true;

    // this displays the button so the users can print the content that is in the editor
    this.print_button = true;

    // some minor things on how the editor's drop-down lists will display
    this._select_fontFamily='sans-serif';
    this._select_fontSize='9pt';
    this._select_fontWeight='normal';
    this._select_color='#000000';
    this._select_backgroundColor='#ffffff';

    // these are used in my custom CMS
    this.web_toolbar4 = true;                               // show insert image and save buttons
    this.imagePopUp = null;                                 // used in the insertImage and addImage methods
    this.site_path = this.wysiwyg_path;                     // default to what was passed, should be set in HTML
    this.page_title = 'index';                              // default to nothing, should be set in HTML
}

/**
*   WYSIWYG_Editor::display
*
*   Display the editor interface for the user
**/
WYSIWYG_Editor.prototype.display = function (){
    this.supported=this.isSupported();
    if(this.supported){
        // the function requirements were tested in isSupported method...
        this._display_editor();
        this._load_content();
        var thedoc = document.getElementById(this.wysiwyg_content).contentWindow.document;
        thedoc.designMode='On';
        // MSIE has caching problems...
        // http://technet2.microsoft.com/WindowsServer/en/Library/8e06b837-0027-4f47-95d6-0a60579904bc1033.mspx
        thedoc = document.getElementById(this.wysiwyg_content).contentWindow.document;
        thedoc.open();
        thedoc.write('<html><head>');
        if(this.stylesheet){
            // must be done after the document has been opened
            thedoc.write('<style type="text/css">@import url('+this.stylesheet+');</style>');
        }
        thedoc.write('</head><body>');
        thedoc.write(this.content);
        thedoc.write('</body></html>');
        thedoc.close();
    }else{
        this._display_textarea();
        this._load_content();
    }
}

/**
*   WYSIWYG_Editor::_load_content
*
*   Puts the passed content into the editor or textarea (Use this one *after* displaying the editor.)
*
*   @param  content string  The string containing the properly-formatted HTML source to use
*/
WYSIWYG_Editor.prototype._load_content = function (){
    if(document.getElementById
        && document.getElementById(this.wysiwyg_hidden)
      ){
        document.getElementById(this.wysiwyg_hidden).value=this.content;
    }else{
alert(this.lang.browser_not_supported + " Method: _load_content");
        return false;
    }
}

/**
*   WYSIWYG_Editor::_display_textarea
*
*   Used to display a substitute for the wysiwyg editor HTML interface to non-supported browsers
**/
WYSIWYG_Editor.prototype._display_textarea = function (){
    if(document.write){
        document.write('<p style="background-color: yellow; color: red; padding: 3px;">'+this.lang.textarea_warning+'</p>');
        document.write('<textarea name="'+this.wysiwyg_hidden+'" id="'+this.wysiwyg_hidden+'" rows="'+this.ta_rows+'" cols="'+this.ta_cols+'"></textarea><br>');
    }else{
alert(this.lang.browser_not_supported + " Method: _display_textarea");
        return false;
    }
}

/**
*   WYSIWYG_Editor::_display_editor
*
*   Used to display the actual wysiwyg editor HTML interface to supported browsers
**/
WYSIWYG_Editor.prototype._display_editor = function (){
    if(document.write){
        document.write('  <div style="position:relative;">');
        document.write('   <textarea name="'+this.wysiwyg_hidden+'" id="'+this.wysiwyg_hidden+'" style="visibility:hidden;display:none;"></textarea>');
        document.write('   <table cellpadding="5" cellspacing="0" border="2" id="'+this.instance_name+'_table" bgcolor="#dfdfdf" width="'+this.frame_width+'">');
        document.write('    <tr>');
        document.write('     <td>');
        document.write('      <table width="100%" border="0" cellspacing="0" cellpadding="0">');
        document.write('       <tr>');
        document.write('        <td valign="top" colspan="2">');
        document.write('         <div id="'+this.instance_name+'_toolbars">');

        if(this.font_format_toolbar1){
            var count=0;
            document.write('         <div id="'+this.instance_name+'_font_format_toolbar1">');
            if(this._sfontname){
                document.write('          <select id="'+this.instance_name+'_fontFamilySelect" onChange="'+this.instance_name+'.doTextFormat(\'fontname\',this.options[this.selectedIndex].value)" style="margin:0px;">');
                document.write('           <option style="font-family:" value="">'+this.lang.font_option+'</option>');
                document.write('           <option style="font-family:cursive;" value="cursive">'+this.lang.font_cursive+'</option>');
                document.write('           <option style="font-family:fantasy;" value="fantasy">'+this.lang.font_fantasy+'</option>');
                document.write('           <option style="font-family:sans-serif;" value="sans-serif">'+this.lang.font_sansserif+'</option>');
                document.write('           <option style="font-family:serif;" value="serif">'+this.lang.font_serif+'</option>');
                document.write('           <option style="font-family:monospace;" value="monospace">'+this.lang.font_typewriter+'</option>');
                document.write('          </select>');
                count++;
                document.getElementById(this.instance_name+'_fontFamilySelect').style.width='75px';
                document.getElementById(this.instance_name+'_fontFamilySelect').style.width='75px';
                document.getElementById(this.instance_name+'_fontFamilySelect').style.width='75px';
                document.getElementById(this.instance_name+'_fontFamilySelect').style.fontSize='9pt';
                document.getElementById(this.instance_name+'_fontFamilySelect').style.fontFamily=this._select_fontFamily;
                document.getElementById(this.instance_name+'_fontFamilySelect').style.fontSize=this._select_fontSize;
                document.getElementById(this.instance_name+'_fontFamilySelect').style.color=this._select_color;
                document.getElementById(this.instance_name+'_fontFamilySelect').style.backgroundColor=this._select_backgroundColor;
            }
            if(this._sfontsize){
                document.write('          <select id="'+this.instance_name+'_fontsizeSelect" onChange="'+this.instance_name+'.doTextFormat(\'fontsize\',this.options[this.selectedIndex].value)" style="margin:0px;">');
                document.write('           <option value="">'+this.lang.size_option+'</option>');
                document.write('           <option value="-2">'+this.lang.size_xsmall+'</option>');
                document.write('           <option value="-1">'+this.lang.size_small+'</option>');
                document.write('           <option value="+0">'+this.lang.size_medium+'</option>');
                document.write('           <option value="+1">'+this.lang.size_large+'</option>');
                document.write('           <option value="+2">'+this.lang.size_xlarge+'</option>');
                document.write('          </select>');
                count++;
                document.getElementById(this.instance_name+'_fontsizeSelect').style.width='75px';
                document.getElementById(this.instance_name+'_fontsizeSelect').style.width='75px';
                document.getElementById(this.instance_name+'_fontsizeSelect').style.fontSize='9pt';
                document.getElementById(this.instance_name+'_fontsizeSelect').style.fontFamily=this._select_fontFamily;
                document.getElementById(this.instance_name+'_fontsizeSelect').style.fontSize=this._select_fontSize;
                document.getElementById(this.instance_name+'_fontsizeSelect').style.color=this._select_color;
                document.getElementById(this.instance_name+'_fontsizeSelect').style.backgroundColor=this._select_backgroundColor;
            }
            if(this._sformatblock){
                document.write('          <select id="'+this.instance_name+'_fontStyleSelect" onChange="'+this.instance_name+'.doTextFormat(\'formatblock\',this.options[this.selectedIndex].value)" style="margin:0px;">');
                document.write('           <option value="<p>">'+this.lang.format_normal+'</option>');
                document.write('           <option value="<h1>">'+this.lang.format_h1+'</option>');
                document.write('           <option value="<h2>">'+this.lang.format_h2+'</option>');
                document.write('           <option value="<h3>">'+this.lang.format_h3+'</option>');
                document.write('           <option value="<h4>">'+this.lang.format_h4+'</option>');
                document.write('           <option value="<h5>">'+this.lang.format_h5+'</option>');
                document.write('           <option value="<h6>">'+this.lang.format_h6+'</option>');
                document.write('           <option value="<address>">'+this.lang.format_address+'</option>');
                document.write('          </select>');
                count++;
                document.getElementById(this.instance_name+'_fontStyleSelect').style.width='75px';
                document.getElementById(this.instance_name+'_fontStyleSelect').style.fontSize='9pt';
                document.getElementById(this.instance_name+'_fontStyleSelect').style.fontFamily=this._select_fontFamily;
                document.getElementById(this.instance_name+'_fontStyleSelect').style.fontSize=this._select_fontSize;
                document.getElementById(this.instance_name+'_fontStyleSelect').style.color=this._select_color;
                document.getElementById(this.instance_name+'_fontStyleSelect').style.backgroundColor=this._select_backgroundColor;
            }
            document.write('         </div>');
            document.getElementById(this.instance_name+'_font_format_toolbar1').style.styleFloat='left';
            document.getElementById(this.instance_name+'_font_format_toolbar1').style.display='inline';
            document.getElementById(this.instance_name+'_font_format_toolbar1').style.margin='0px';
            if(count>0){
//                document.getElementById(this.instance_name+'_font_format_toolbar1').style.borderRight='solid #000 1px';
                document.getElementById(this.instance_name+'_font_format_toolbar1').style.paddingRight='5px';
                document.getElementById(this.instance_name+'_font_format_toolbar1').style.paddingLeft='5px';
            }
        }


        if(this.web_toolbar1){
            document.write('         <div id="'+this.instance_name+'_web_toolbar1">');
            if(this._screatelink){
                document.write('          <img alt="'+this.lang.hyperlink+'" title="'+this.lang.hyperlink+'" class="butClass" src="'+this.wysiwyg_path+'/images/link.png" onmousedown="'+this.instance_name+'.doTextFormat(\'createlink\',\'\')">');
                count++;
            }
            if(this._sunlink){
                document.write('          <img alt="'+this.lang.unlink+'" title="'+this.lang.unlink+'" class="butClass" src="'+this.wysiwyg_path+'/images/unlink.png" onmousedown="'+this.instance_name+'.doTextFormat(\'unlink\',\'\')">');
                count++;
            }
            document.write('         </div> ');
            document.getElementById(this.instance_name+'_web_toolbar1').style.styleFloat='left';
            document.getElementById(this.instance_name+'_web_toolbar1').style.display='inline';
            document.getElementById(this.instance_name+'_web_toolbar1').style.margin='0px';
            if(count>0){
//                document.getElementById(this.instance_name+'_web_toolbar1').style.borderRight='solid #000 1px';
                document.getElementById(this.instance_name+'_web_toolbar1').style.paddingRight='5px';
                document.getElementById(this.instance_name+'_web_toolbar1').style.paddingLeft='5px';
            }
        }
        if(this.web_toolbar2){
            if(this._sinsertorderedlist){
                document.write('          <img alt="'+this.lang.ordered_list+'" title="'+this.lang.ordered_list+'" class="butClass" src="'+this.wysiwyg_path+'/images/ordlist.png"  onmousedown="'+this.instance_name+'.doTextFormat(\'insertorderedlist\',\'\')">');
            }
            if(this._sinsertunorderedlist){
                document.write('          <img alt="'+this.lang.unordered_list+'" title="'+this.lang.unordered_list+'" class="butClass" src="'+this.wysiwyg_path+'/images/bullist.png" onmousedown="'+this.instance_name+'.doTextFormat(\'insertunorderedlist\',\'\')">');
            }
        }
        if(this.web_toolbar3){
            if(this._sinserthorizontalrule){
                document.write('          <img alt="'+this.lang.horizontal_rule+'" title="'+this.lang.horizontal_rule+'" class="butClass" src="'+this.wysiwyg_path+'/images/rule.png" onmousedown="'+this.instance_name+'.doTextFormat(\'inserthorizontalrule\',\'\')">');
            }
// need to play with the table thing again
            document.write('          <img alt="'+this.lang.insert_table+'" title="'+this.lang.insert_table+'" class="butClass" src="'+this.wysiwyg_path+'/images/table.png" onmousedown="'+this.instance_name+'.insertTable()">');
        }
        if(this.web_toolbar4){
            if(this.image_button)
                document.write('          <img alt="'+this.lang.insert_image+'" title="'+this.lang.insert_image+'" class="butClass" src="'+this.wysiwyg_path+'/images/image.png" onmousedown="'+this.instance_name+'.insertImage()">');
            if(this.spell_path.length > 0)
                document.write('          <img alt="'+this.lang.spell_check+'" title="'+this.lang.spell_check+'" class="butClass" src="'+this.wysiwyg_path+'/images/spelling.png" onmousedown="'+this.instance_name+'.checkSpelling()">');
            if(this.save_button)
                document.write('          <input type="image" alt="'+this.lang.save+'" title="'+this.lang.save+'" class="butClass" src="'+this.wysiwyg_path+'/images/save.png" name="'+this.instance_name+'_save">');
            if(this.preview_button)
                document.write('          <img alt="'+this.lang.preview+'" title="'+this.lang.preview+'" src="'+this.wysiwyg_path+'/images/preview.png" onmousedown="'+this.instance_name+'.preview()">');
            if(this.print_button)
                document.write('          <img alt="'+this.lang.print+'" title="'+this.lang.print+'" src="'+this.wysiwyg_path+'/images/print.png" onmousedown="'+this.instance_name+'.print()">');
        }
        document.write('<br />');
        if(this.font_format_toolbar2){
            var count=0;
            document.write('         <div id="'+this.instance_name+'_font_format_toolbar2">');
            if(this._sforecolor){
                document.write('           <img alt="'+this.lang.foreground_color+'" title="'+this.lang.foreground_color+'" class="butClass" src="'+this.wysiwyg_path+'/images/forecol.png" onmousedown="'+this.instance_name+'.doTextFormat(\'forecolor\',\'\',event)" id="'+this.instance_name+'_forecolor"><div id="'+this.instance_name+'_forecolorPallet" style="visibility:hidden;display:none;">'+this._get_pallet_html('forecolor')+'</div>');
                count++;
            }
            if(this._shilitecolor){
                document.write('           <img alt="'+this.lang.hilight_color+'" title="'+this.lang.hilight_color+'" class="butClass" src="'+this.wysiwyg_path+'/images/bgcol.png" onmousedown="'+this.instance_name+'.doTextFormat(\'hilitecolor\',\'\',event)" id="'+this.instance_name+'_hilitecolor"><div id="'+this.instance_name+'_hilitecolorPallet" style="visibility:hidden;display:none;backgound-color:#fff;color:#000;">'+this._get_pallet_html('hilitecolor')+'</div>');
                count++;
            }
            if(this._sbackcolor){
                document.write('           <img alt="'+this.lang.background_color+'" title="'+this.lang.background_color+'" class="butClass" src="'+this.wysiwyg_path+'/images/bgcol.png" onmousedown="'+this.instance_name+'.doTextFormat(\'backcolor\',\'\',event)" id="'+this.instance_name+'_backcolor"><div id="'+this.instance_name+'_backcolorPallet" style="visibility:hidden;display:none;backgound-color:#fff;color:#000;">'+this._get_pallet_html('backcolor')+'</div>');
                count++;
            }
            document.write('         </div> ');
            document.getElementById(this.instance_name+'_font_format_toolbar2').style.styleFloat='left';
            document.getElementById(this.instance_name+'_font_format_toolbar2').style.display='inline';
            document.getElementById(this.instance_name+'_font_format_toolbar2').style.margin='0px';
            if(count>0){
//                document.getElementById(this.instance_name+'_font_format_toolbar2').style.borderRight='solid #000 1px';
                document.getElementById(this.instance_name+'_font_format_toolbar2').style.paddingRight='5px';
                document.getElementById(this.instance_name+'_font_format_toolbar2').style.paddingLeft='5px';
            }
        }
        if(this.font_format_toolbar3){
            var count=0;
            document.write('         <div id="'+this.instance_name+'_font_format_toolbar3">');
            if(this._sbold){
                document.write('          <img alt="'+this.lang.bold+'" title="'+this.lang.bold+'" class="butClass" src="'+this.wysiwyg_path+'/images/bold.png" onmousedown="'+this.instance_name+'.doTextFormat(\'bold\',\'\')">');
                count++;
            }
            if(this._sitalic){
                document.write('          <img alt="'+this.lang.italic+'" title="'+this.lang.italic+'" class="butClass" src="'+this.wysiwyg_path+'/images/italic.png" onmousedown="'+this.instance_name+'.doTextFormat(\'italic\',\'\')">');
                count++;
            }
            if(this._sunderline){
                document.write('          <img alt="'+this.lang.underline+'" title="'+this.lang.underline+'" class="butClass" src="'+this.wysiwyg_path+'/images/underline.png" onmousedown="'+this.instance_name+'.doTextFormat(\'underline\',\'\')">');
                count++;
            }
            document.write('         </div> ');
            document.getElementById(this.instance_name+'_font_format_toolbar3').style.styleFloat='left';
            document.getElementById(this.instance_name+'_font_format_toolbar3').style.display='inline';
            document.getElementById(this.instance_name+'_font_format_toolbar3').style.margin='0px';
            if(count>0){
//                document.getElementById(this.instance_name+'_font_format_toolbar3').style.borderRight='solid #000 1px';
                document.getElementById(this.instance_name+'_font_format_toolbar3').style.paddingRight='5px';
                document.getElementById(this.instance_name+'_font_format_toolbar3').style.paddingLeft='5px';
            }
        }
        if(this.font_format_toolbar4){
            var count=0;
            document.write('         <div id="'+this.instance_name+'_font_format_toolbar4">');
            if(this._ssuperscript){
                document.write('          <img alt="'+this.lang.superscript+'" title="'+this.lang.superscript+'" class="butClass" src="'+this.wysiwyg_path+'/images/sup.png" onmousedown="'+this.instance_name+'.doTextFormat(\'superscript\',\'\')">');
                count++;
            }
            if(this._ssubscript){
                document.write('          <img alt="'+this.lang.subscript+'" title="'+this.lang.subscript+'" class="butClass" src="'+this.wysiwyg_path+'/images/sub.png" onmousedown="'+this.instance_name+'.doTextFormat(\'subscript\',\'\')">');
                count++;
            }
            document.write('         </div> ');
            document.getElementById(this.instance_name+'_font_format_toolbar4').style.styleFloat='left';
            document.getElementById(this.instance_name+'_font_format_toolbar4').style.display='inline';
            document.getElementById(this.instance_name+'_font_format_toolbar4').style.margin='0px';
            if(count>0){
//                document.getElementById(this.instance_name+'_font_format_toolbar4').style.borderRight='solid #000 1px';
                document.getElementById(this.instance_name+'_font_format_toolbar4').style.paddingRight='5px';
                document.getElementById(this.instance_name+'_font_format_toolbar4').style.paddingLeft='5px';
            }
        }
        if(this.alignment_toolbar1){
            var count=0;
            document.write('         <div id="'+this.instance_name+'_alignment_toolbar1">');
            if(this._sjustifyleft){
                document.write('          <img alt="'+this.lang.align_left+'" title="'+this.lang.align_left+'" class="butClass" src="'+this.wysiwyg_path+'/images/left.png" onmousedown="'+this.instance_name+'.doTextFormat(\'justifyleft\',\'\')">');
                count++;
            }
            if(this._sjustifycenter){
                document.write('          <img alt="'+this.lang.align_center+'" title="'+this.lang.align_center+'" class="butClass" src="'+this.wysiwyg_path+'/images/center.png" onmousedown="'+this.instance_name+'.doTextFormat(\'justifycenter\',\'\')">');
                count++;
            }
            if(this._sjustifyright){
                document.write('          <img alt="'+this.lang.align_right+'" title="'+this.lang.align_right+'" class="butClass" src="'+this.wysiwyg_path+'/images/right.png" onmousedown="'+this.instance_name+'.doTextFormat(\'justifyright\',\'\')">');
                count++;
            }
            if(this._sjustifyfull){
                document.write('          <img alt="'+this.lang.align_justify+'" title="'+this.lang.align_justify+'" class="butClass" src="'+this.wysiwyg_path+'/images/full.png" onmousedown="'+this.instance_name+'.doTextFormat(\'justifyfull\',\'\')">');
                count++;
            }
            document.write('         </div> ');
            document.getElementById(this.instance_name+'_alignment_toolbar1').style.styleFloat='left';
            document.getElementById(this.instance_name+'_alignment_toolbar1').style.display='inline';
            document.getElementById(this.instance_name+'_alignment_toolbar1').style.margin='0px';
            if(count>0){
//                document.getElementById(this.instance_name+'_alignment_toolbar1').style.borderRight='solid #000 1px';
                document.getElementById(this.instance_name+'_alignment_toolbar1').style.paddingRight='5px';
                document.getElementById(this.instance_name+'_alignment_toolbar1').style.paddingLeft='5px';
            }
        }
        if(this.alignment_toolbar2){
            document.write('         <div id="'+this.instance_name+'_alignment_toolbar2">');
            if(this._sindent){
                document.write('          <img alt="'+this.lang.indent+'" title="'+this.lang.indent+'" src="'+this.wysiwyg_path+'/images/indent.png" class=butClass onmousedown="'+this.instance_name+'.doTextFormat(\'indent\',\'\')">');
                count++;
            }
            if(this._soutdent){
                document.write('          <img alt="'+this.lang.outdent+'" title="'+this.lang.outdent+'" src="'+this.wysiwyg_path+'/images/outdent.png" class=butClass onmousedown="'+this.instance_name+'.doTextFormat(\'outdent\',\'\')">');
                count++;
            }
            document.write('         </div> ');
            document.getElementById(this.instance_name+'_alignment_toolbar2').style.styleFloat='left';
            document.getElementById(this.instance_name+'_alignment_toolbar2').style.display='inline';
            document.getElementById(this.instance_name+'_alignment_toolbar2').style.margin='0px';
            if(count>0){
//                document.getElementById(this.instance_name+'_alignment_toolbar2').style.borderRight='solid #000 1px';
                document.getElementById(this.instance_name+'_alignment_toolbar2').style.paddingRight='5px';
                document.getElementById(this.instance_name+'_alignment_toolbar2').style.paddingLeft='5px';
            }
        }

        document.write('         </div>');
        document.write('        </td>');
        document.write('       </tr>');
        document.write('      </table>');
//        document.write('      <iframe id="'+this.wysiwyg_content+'" style="margin-left: 3px; background-color: white; color: black; width:'+this.frame_width+'px; height:'+this.frame_height+'px;" src="' + window.location.protocol + '//' + location.host + this.wysiwyg_path+'/blank.html"></iframe>');
        document.write('      <iframe id="'+this.wysiwyg_content+'" style="margin-left: 3px; background-color: white; color: black; width:'+this.frame_width+'px; height:'+this.frame_height+'px;"></iframe>');
        document.write('      <table width="'+this.frame_width+'" border="0" cellspacing="0" cellpadding="0" bgcolor="#dfdfdf">');
        document.write('       <tr>');
        document.write('        <td>');
        document.write('        </td>');
        document.write('        <td align="'+this.lang.align_right+'">');
        if(this.allow_mode_toggle){
            document.write('         <img alt="'+this.lang.toggle_mode+'" title="'+this.lang.toggle_mode+'" class="butClass" src="'+this.wysiwyg_path+'/images/mode.png" onmousedown="'+this.instance_name+'.toggleMode()">');
        }
        document.write('        </td>');
        document.write('       </tr>');
        document.write('      </table>');
        document.write('     </td>');
        document.write('    </tr>');
        document.write('   </table>');
        document.write('   </div>');
    }else{
alert(this.lang.browser_not_supported + " Method: _display_editor");
        return false;
    }
}

/**
*   WYSIWYG_Editor::doTextFormat
*
*   Apply a text formatting command to the selected text in the editor (or starting at the current cursor position)
*
*   @param  command string  Which of the editor/browser text formatting commands to apply
**/
WYSIWYG_Editor.prototype.doTextFormat = function (command, optn, evnt){
    if( document.getElementById
        && document.getElementById(this.wysiwyg_content)
        && document.getElementById(this.wysiwyg_content).contentWindow
        && document.getElementById(this.wysiwyg_content).contentWindow.focus
        && document.getElementById(this.wysiwyg_content).contentWindow.document
        && document.getElementById(this.wysiwyg_content).contentWindow.document.queryCommandEnabled
        && document.getElementById(this.wysiwyg_content).contentWindow.document.execCommand
    ){

//if(document.getElementById(this.wysiwyg_content).contentWindow.document.queryCommandEnabled(command)){
//    alert('Safari supports document.getElementById(this.wysiwyg_content).contentWindow.document.queryCommandEnabled(\''+command+'\')');
//}else{
//    alert('Safari DOES NOT support document.getElementById(this.wysiwyg_content).contentWindow.document.queryCommandEnabled(\''+command+'\')');
//}
        if((command=='forecolor') || (command=='hilitecolor') || (command=='backcolor')){
            this.getPallet(command, optn, evnt);
        }else if(command=='createlink'){
            var szURL=prompt('Enter a URL:', '');
            if(document.getElementById(this.wysiwyg_content).contentWindow.document.queryCommandEnabled(command)){
                document.getElementById(this.wysiwyg_content).contentWindow.document.execCommand('CreateLink',false,szURL);
                return true;
            }else{
alert("Cannot set "+command+" on current selection");
                return false;
            }
        }else{
            if(document.getElementById(this.wysiwyg_content).contentWindow.document.queryCommandEnabled(command)){
                document.getElementById(this.wysiwyg_content).contentWindow.document.execCommand(command, false, optn);
                return true;
            }else{
alert("Cannot set "+command+" on current selection");
                return false;
            }
        }
        document.getElementById(this.wysiwyg_content).contentWindow.focus();
    }else{
alert(this.lang.browser_not_supported + " Method: doTextFormat");
        return false;
    }
}

/**
*   WYSIWYG_Editor::prepareSubmit
*
*   Use this in the onSubmit event for the form that the editor is displayed inside.
*   Puts the HTML content into a hidden form field for the submission
**/
WYSIWYG_Editor.prototype.prepareSubmit = function (){
    if(this.viewMode == 2){
        // be sure this is in design view before submission
        this.toggleMode();
    }
    if( document.getElementById
        && document.getElementById(this.wysiwyg_content)
        && document.getElementById(this.wysiwyg_content).contentWindow
        && document.getElementById(this.wysiwyg_content).contentWindow.document
        && document.getElementById(this.wysiwyg_content).contentWindow.document.body
        && document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML
    ){
        var htmlCode=document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML;
        document.getElementById(this.wysiwyg_hidden).value=htmlCode;
        return true;
    }else{
alert(this.lang.browser_not_supported + " Method: prepareSubmit");
        return false;
    }
}

/**
*   WYSIWYG_Editor::toggleMode
*
*   Toggles between design view and source view in the IFRAME element
**/
WYSIWYG_Editor.prototype.toggleMode = function (){
    // change the display styles
    if(document.getElementById
        && document.getElementById(this.wysiwyg_content)
        && document.getElementById(this.wysiwyg_content).contentWindow
        && document.getElementById(this.wysiwyg_content).contentWindow.document
        && document.getElementById(this.wysiwyg_content).contentWindow.document.body
        && document.getElementById(this.wysiwyg_content).contentWindow.document.body.style
        && document.getElementById(this.instance_name+'_toolbars')
        && document.getElementById(this.instance_name+'_toolbars').style
      ){
        if(this.viewMode == 2){
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.fontFamily = '';
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.fontsize = '';
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.color = '';
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.fontWeight = '';
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.backgroundColor = '';
            document.getElementById(this.instance_name+'_toolbars').style.visibility='visible';

            if( document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML
                && document.getElementById(this.wysiwyg_content).contentWindow.document.body.ownerDocument
                && document.getElementById(this.wysiwyg_content).contentWindow.document.body.ownerDocument.createRange
              ){
                // Gecko-style swapping
                var html = document.getElementById(this.wysiwyg_content).contentWindow.document.body.ownerDocument.createRange();
                html.selectNodeContents(document.getElementById(this.wysiwyg_content).contentWindow.document.body);
                document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML = html.toString();
                document.getElementById(this.wysiwyg_content).contentWindow.focus();
                this.viewMode = 1; // WYSIWYG
            }else if(document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML
                && document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerText
              ){
                // MSIE-style content swapping...
                document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML = document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerText;
                this.viewMode = 1; // WYSIWYG
            }else{
alert(this.lang.browser_not_supported + " Method: toggleMode - unknown routines");
                return false;
            }

            if(document.getElementById(this.wysiwyg_content).contentWindow.focus){
                document.getElementById(this.wysiwyg_content).contentWindow.focus();
            }
        }else{
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.fontFamily = 'monospace';
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.fontsize = '10pt';
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.color = '#000';
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.backgroundColor = '#fff';
            document.getElementById(this.wysiwyg_content).contentWindow.document.body.style.fontWeight = 'normal';
            document.getElementById(this.instance_name+'_toolbars').style.visibility='hidden';

            if( document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML
                && document.getElementById(this.wysiwyg_content).contentWindow.document.body.ownerDocument
                && document.getElementById(this.wysiwyg_content).contentWindow.document.body.ownerDocument.createRange
              ){
                // Gecko-style swapping
                var html = document.createTextNode(document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML);
                document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML = '';
                document.getElementById(this.wysiwyg_content).contentWindow.document.body.appendChild(html);
                document.getElementById(this.wysiwyg_content).contentWindow.focus();
                this.viewMode = 2; // Code
            }else if(document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML
                && document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerText
              ){
                // MSIE-style content swapping...
                document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerText = document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML;
                this.viewMode = 2; // Code
            }else{
alert(this.lang.browser_not_supported + " Method: toggleMode - unknown routines");
                return false;
            }
            
            if(document.getElementById(this.wysiwyg_content).contentWindow.focus){
                document.getElementById(this.wysiwyg_content).contentWindow.focus();
            }
        }
    }else{
alert(this.lang.browser_not_supported + " Method: toggleMode");
        return false;
    }
}

/**
*   WYSIWYG_Editor::insertTable
*
*   Used for inserting a table into the IFRAME content window
**/
WYSIWYG_Editor.prototype.insertTable = function (){
    colstext = prompt(this.lang.table_num_cols,0);
    rowstext = prompt(this.lang.table_num_rows,0);
    rows = parseInt(rowstext,'0');
    cols = parseInt(colstext,'0');

    if(document.getElementById
        && document.getElementById(this.wysiwyg_content)
        && document.getElementById(this.wysiwyg_content).contentWindow
        && document.getElementById(this.wysiwyg_content).contentWindow.document
        && document.getElementById(this.wysiwyg_content).contentWindow.document.selection
        && document.getElementById(this.wysiwyg_content).contentWindow.document.selection.createRange
        && document.getElementById(this.wysiwyg_content).contentWindow.focus
      ){
        //MSIE-style...
alert('msie-style');
        document.getElementById(this.wysiwyg_content).contentWindow.focus();
    
        //get current selected range
        var cursor=document.getElementById(this.wysiwyg_content).contentWindow.document.selection.createRange();
        if((rows > 0) && (cols > 0)){
            var tableHTML = '<table border="'+this.table_border+'" cellpadding="'+this.table_cell_padding+'" cellspacing="'+this.table_cell_spacing+'">';
            while(rows>0){
                rows--;
                var rowCols = cols;
                tableHTML = tableHTML + '<tr>';
                while(parseInt(rowCols)>0){
                    rowCols--;
                    tableHTML=tableHTML+'<td>&nbsp;</td>';
                }
                tableHTML = tableHTML + '</tr>';
            }
            tableHTML = tableHTML + '</table>';
            cursor.pasteHTML(tableHTML);
            document.getElementById(this.wysiwyg_content).contentWindow.focus();
        }
        return true;
    }else if(document.getElementById
        && document.getElementById(this.wysiwyg_content)
        && document.getElementById(this.wysiwyg_content).contentWindow
        && document.getElementById(this.wysiwyg_content).contentWindow.document
        && document.getElementById(this.wysiwyg_content).contentWindow.document.createElement
      ){
        // Gecko-style...
alert('gecko-style');
        contentWin=document.getElementById(this.wysiwyg_content).contentWindow;
        if((rows > 0) && (cols > 0)){
            if(contentWin.document.createElement){
                table=contentWin.document.createElement('table');
                if(table.appendChild
                    && table.setAttribute){
                    table.setAttribute('border', this.table_border);
                    table.setAttribute('cellpadding', this.table_cell_padding);
                    table.setAttribute('cellspacing', this.table_cell_spacing);
                    tbody=contentWin.document.createElement('tbody');
                    for(i=0;i<rows;i++){
                        tr=contentWin.document.createElement('tr');
                        for(j=0;j<cols;j++){
                            td=contentWin.document.createElement('td');
                                br=contentWin.document.createElement('br');
                            td.appendChild(br);
                            tr.appendChild(td);
                        }
                        tbody.appendChild(tr);
                    }
                    table.appendChild(tbody);
                }else{
alert('Can\'t "appendChild" or "setAttribute"');
                    return false;
                }
                this._insert_element(contentWin, table);
            }else{
alert('Can\'t "createElement"');
                return false;
            }
        }
        return true;
    }else{
alert(this.lang.browser_not_supported + " Method: insertTable");
        return false;
    }
}

/**
*   WYSIWYG_Editor::_insert_element
*
*   Insert elements into the document for the insertTable method
*
*   @param  win The window object to insert the element into
*   @param  elem    The element to insert into the content window
**/
WYSIWYG_Editor.prototype._insert_element = function (win, elem){
    var sel = win.getSelection();           // get current selection
    var range = sel.getRangeAt(0);          // get the first range of the selection (there's almost always only one range)
    sel.removeAllRanges();                  // deselect everything
    range.deleteContents();                 // remove content of current selection from document
    var container = range.startContainer;   // get location of current selection
    var pos = range.startOffset;
    range=document.createRange();           // make a new range for the new selection

    if (container.nodeType==3 && elem.nodeType==3) {
        // if we insert text in a textnode, do optimized insertion
        container.insertData(pos, elem.nodeValue);

        // put cursor after inserted text
        range.setEnd(container, pos+elem.length);
        range.setStart(container, pos+elem.length);
    }else{
        var afterNode;
        if (container.nodeType==3) {
          // when inserting into a textnode we create 2 new textnodes and put the elem in between
          var textNode = container;
          container = textNode.parentNode;
          var text = textNode.nodeValue;

          var textBefore = text.substr(0,pos);  // text before the split
          var textAfter = text.substr(pos);     // text after the split

          var beforeNode = document.createTextNode(textBefore);
          var afterNode = document.createTextNode(textAfter);

          // insert the 3 new nodes before the old one
          container.insertBefore(afterNode, textNode);
          container.insertBefore(elem, afterNode);
          container.insertBefore(beforeNode, elem);

          // remove the old node
          container.removeChild(textNode);
        }else{
          // else simply insert the node
          afterNode = container.childNodes[pos];
          container.insertBefore(elem, afterNode);
        }
    }
}

/**
*   WYSIWYG_Editor::setColor
*
*   Used to set the text or highlight color of the selected text in Gecko engine browsers
**/
WYSIWYG_Editor.prototype.setColor = function (color, command){
    // close the window we made to display the pallete in
    if(
        document.getElementById(this.wysiwyg_content)
        && document.getElementById(this.wysiwyg_content).contentWindow
        && document.getElementById(this.wysiwyg_content).contentWindow.document
        && document.getElementById(this.wysiwyg_content).contentWindow.document.queryCommandEnabled
        && document.getElementById(this.wysiwyg_content).contentWindow.document.execCommand
        && document.getElementById(this.wysiwyg_content).contentWindow.focus
        && document.getElementById(this.instance_name+'_'+command+'Pallet')
        && document.getElementById(this.instance_name+'_'+command+'Pallet').style
      ){
        document.getElementById(this.wysiwyg_content).contentWindow.focus();
        palDiv=document.getElementById(this.instance_name+'_'+command+'Pallet');

//        // for MSIE
//        if(command == 'hilitecolor' && document.all){
//            command = 'backcolor';
//        }

        palDiv.style.visibility='hidden';
        palDiv.style.display='none';

        if(document.getElementById(this.wysiwyg_content).contentWindow.document.queryCommandEnabled(command)){
            document.getElementById(this.wysiwyg_content).contentWindow.document.execCommand(command, false, color);
        }else{
alert(this.lang.browser_not_supported + " Method: setColor - "+command);
            return false;
        }
        document.getElementById(this.wysiwyg_content).contentWindow.focus();
        return true;
    }else{
alert(this.lang.browser_not_supported + " Method: setColor");
        return false;
    }
}

/**
*   WYSIWYG_Editor::getPallet
*
*   Apply a text color to selected text or starting at current position
*
*   @param  command string  Used to determine which pallete pop-up to display
**/
WYSIWYG_Editor.prototype.getPallet = function (command, optn, evnt) {
    if(document.getElementById
        && document.getElementById(this.instance_name+'_'+command+'Pallet')
        && document.getElementById(this.instance_name+'_'+command+'Pallet').style
    ){
    	palDiv=document.getElementById(this.instance_name+'_'+command+'Pallet');
    	if(palDiv.style.visibility=='visible'
    	    && palDiv.style.display=='block'
    	  ){
            palDiv.style.visibility='hidden';
    	    palDiv.style.display='none';
    	}else{
            palDiv.style.zIndex='50';   // this doesn't seem to do a damn bit of good for Safari! I don't want to go back to pop-ups!
            palDiv.style.visibility='visible';
            palDiv.style.display='block';
            palDiv.style.backgroundColor='white';
            palDiv.style.color='black';
            palDiv.style.borderStyle='solid';
            palDiv.style.borderColor='black';
            palDiv.style.borderWidth='1px';
            palDiv.style.position='absolute';
            palDiv.style.top='65px';
            if(command == 'forecolor'){
                palDiv.style.left='15px';
            }else if(command == 'hilitecolor'){
                palDiv.style.left='45px';
            }else{
                palDiv.style.left='75px';
            }
            palDiv.style.margin='0px';
            palDiv.style.margin='0px';
        }
    }else{
alert(this.lang.browser_not_supported + " Method: getPallet");
        return false;
    }
}

/**
*   WYSIWYG_Editor::_get_pallet_html
*
*   Generates the HTML that will be used in the color palette pop-ups.
*
*   @param  command string  The command that indicates which text color is being set
**/
WYSIWYG_Editor.prototype._get_pallet_html = function (command) {
    s =     '  <table border="0" cellpadding="0" cellspacing="2">';
    s = s + '   <tr>';
    s = s + '    <td id="cFFFFFF" bgcolor="#FFFFFF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFCCCC" bgcolor="#FFCCCC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFCC99" bgcolor="#FFCC99" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFFF99" bgcolor="#FFFF99" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFFFCC" bgcolor="#FFFFCC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c99FF99" bgcolor="#99FF99" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c99FFFF" bgcolor="#99FFFF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cCCFFFF" bgcolor="#CCFFFF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cCCCCFF" bgcolor="#CCCCFF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFCCFF" bgcolor="#FFCCFF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '   </tr>';
    s = s + '   <tr>';
    s = s + '    <td id="cCCCCCC" bgcolor="#CCCCCC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFF6666" bgcolor="#FF6666" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFF9966" bgcolor="#FF9966" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFFF66" bgcolor="#FFFF66" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFFF33" bgcolor="#FFFF33" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c66FF99" bgcolor="#66FF99" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c33FFFF" bgcolor="#33FFFF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c66FFFF" bgcolor="#66FFFF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c9999FF" bgcolor="#9999FF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFF99FF" bgcolor="#FF99FF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '   </tr>';
    s = s + '   <tr>';
    s = s + '    <td id="cC0C0C0" bgcolor="#C0C0C0" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFF0000" bgcolor="#FF0000" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFF9900" bgcolor="#FF9900" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFCC66" bgcolor="#FFCC66" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFFF00" bgcolor="#FFFF00" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c33FF33" bgcolor="#33FF33" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c66CCCC" bgcolor="#66CCCC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c33CCFF" bgcolor="#33CCFF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c6666CC" bgcolor="#6666CC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cCC66CC" bgcolor="#CC66CC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '   </tr>';
    s = s + '   <tr>';
    s = s + '    <td id="c999999" bgcolor="#999999" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cCC0000" bgcolor="#CC0000" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFF6600" bgcolor="#FF6600" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFCC33" bgcolor="#FFCC33" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cFFCC00" bgcolor="#FFCC00" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c33CC00" bgcolor="#33CC00" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c00CCCC" bgcolor="#00CCCC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c3366FF" bgcolor="#3366FF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c6633FF" bgcolor="#6633FF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cCC33CC" bgcolor="#CC33CC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '   </tr>';
    s = s + '   <tr>';
    s = s + '    <td id="c666666" bgcolor="#666666" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c990000" bgcolor="#990000" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cCC6600" bgcolor="#CC6600" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="cCC9933" bgcolor="#CC9933" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c999900" bgcolor="#999900" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c009900" bgcolor="#009900" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c339999" bgcolor="#339999" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c3333FF" bgcolor="#3333FF" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c6600CC" bgcolor="#6600CC" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c993399" bgcolor="#993399" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '   </tr>';
    s = s + '   <tr>';
    s = s + '    <td id="c333333" bgcolor="#333333" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c660000" bgcolor="#660000" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c993300" bgcolor="#993300" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c996633" bgcolor="#996633" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c666600" bgcolor="#666600" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c006600" bgcolor="#006600" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c336666" bgcolor="#336666" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c000099" bgcolor="#000099" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c333399" bgcolor="#333399" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c663366" bgcolor="#663366" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '   </tr>';
    s = s + '   <tr>';
    s = s + '    <td id="c000000" bgcolor="#000000" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c330000" bgcolor="#330000" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c663300" bgcolor="#663300" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c663333" bgcolor="#663333" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c333300" bgcolor="#333300" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c003300" bgcolor="#003300" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c003333" bgcolor="#003333" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c000066" bgcolor="#000066" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c330099" bgcolor="#330099" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '    <td id="c330033" bgcolor="#330033" width="15" height="15" onmouseover="this.style.borderStyle=\'solid\';this.style.borderWidth=\'2px\';this.style.borderColor=\'white\';this.width=\'11px\';" onmouseout="this.style.borderWidth=\'0px\';this.width=\'15px\'" onmousedown="str=this.id;color=str.replace(\'c\',\'#\');'+this.instance_name+'.setColor(color,\''+command+'\');"><img width="1" height="1" alt="" src=""></td>';
    s = s + '   </tr>';
    s = s + '  </table>';
    return s;
}

/**
*   WYSIWYG_Editor::isSupported
*
*   Checks that the browser supports this programming by writing an invisible IFRAME and testing its properties
*/
WYSIWYG_Editor.prototype.isSupported = function () {
    // This is to get rid of the browser UA check that was previously implemented for this class.
    // should be called from somewhere in the body of the document for best results
    if(document.write
        && document.getElementById){
        // if this isn't displayed *somewhere*, safari can't get the ".contentWindow" property... shove it (hopefully) off-screen
        document.write('<iframe id="WYSIWYG_Editor_Testing_Browser_Features" style="position:absolute;left:-9999px;"></iframe>');
        test = typeof(document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow);
        if(test == 'object'){
            if( document.getElementById('WYSIWYG_Editor_Testing_Browser_Features')
                && document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow
                && document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow.document
                && document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow.document.designMode
                && document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow.document.open
                && document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow.document.close
                && document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow.document.write
                && document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow.document.queryCommandEnabled
                && document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow.document.execCommand
              ){
                
                // the iframe was put in here, now to turn on design mode and add some content!
                testDoc=document.getElementById('WYSIWYG_Editor_Testing_Browser_Features').contentWindow.document;
                testDoc.designMode='On';
                testDoc.open();
                testDoc.write('<html><head></head><body>Some test content for feature sniffing.</body></html>');
                testDoc.close();
      
                // of course, there is no easy way when working with MSIE...
                if(testDoc.all){
                    this._sfontname             = true;
                    this._sfontsize             = true;
                    this._sformatblock          = true;
                    this._sforecolor            = true;
                    this._shilitecolor          = true;
                    this._sbold                 = true;
                    this._sitalic               = true;
                    this._sunderline            = true;
                    this._ssuperscript          = true;
                    this._ssubscript            = true;
                    this._sjustifyleft          = true;
                    this._sjustifycenter        = true;
                    this._sjustifyright         = true;
                    this._sjustifyfull          = true;
                    this._sindent               = true;
                    this._soutdent              = true;
                    this._screatelink           = true;
                    this._sunlink               = true;
                    this._sinsertorderedlist    = true;
                    this._sinsertunorderedlist  = true;
                    this._sinserthorizontalrule = true; 
                    return true;
                }          

                // this is just temporary while I am doing some tests for safari...
                // I want all the buttons to show up for now...
                // also MSIE has some kind of problem with the tests below! I need to figure that out as well...
                if( (/AppleWebKit/.test(window.navigator.userAgent) && /Safari/.test(window.navigator.userAgent)) ){
                    this._sfontname             = true;
                    this._sfontsize             = true;
                    this._sformatblock          = true;
                    this._sforecolor            = true;
                    this._shilitecolor          = true;
                    this._sbackcolor            = true;
                    this._sbold                 = true;
                    this._sitalic               = true;
                    this._sunderline            = true;
                    this._ssuperscript          = true;
                    this._ssubscript            = true;
                    this._sjustifyleft          = true;
                    this._sjustifycenter        = true;
                    this._sjustifyright         = true;
                    this._sjustifyfull          = true;
                    this._sindent               = true;
                    this._soutdent              = true;
                    this._screatelink           = true;
                    this._sunlink               = true;
                    this._sinsertorderedlist    = true;
                    this._sinsertunorderedlist  = true;
                    this._sinserthorizontalrule = true; 
                    return true;
                }
                
                //let's do some feature sniffing so we know what buttons we can display for the user!
                /*
                    here is a list of the commands that we will test:
                    fontname 
                    fontsize 
                    formatblock 
                    forecolor 
                    hilitecolor 
                    backcolor 
                    bold 
                    italic 
                    underline 
                    superscript 
                    subscript 
                    justifyleft 
                    justifycenter 
                    justifyright 
                    justifyfull 
                    indent 
                    outdent 
                    createlink 
                    unlink 
                    insertorderedlist 
                    insertunorderedlist 
                    inserthorizontalrule 
                */
                if(testDoc.queryCommandEnabled('fontname')){
                    this._sfontname=true;
                }else{
                    this._sfontname=false;
                }
                if(testDoc.queryCommandEnabled('fontsize')){
                    this._sfontsize=true;
                }else{
                    this._sfontsize=false;
                }
                if(testDoc.queryCommandEnabled('formatblock')){
                    this._sformatblock=true;
                }else{
                    this._sformatblock=false;
                }
                if(testDoc.queryCommandEnabled('forecolor')){
                    this._sforecolor=true;
                }else{
                    this._sforecolor=false;
                }
                if(testDoc.queryCommandEnabled('hilitecolor')){
                    this._shilitecolor=true;
                    this._sbackcolor=false;
                }else{
                    this._shilitecolor=false;
        
                    // need to test the alternate command name as well
                    if(testDoc.queryCommandEnabled('backcolor')){
                        this._sbackcolor=true;
                    }else{
                        this._sbackcolor=false;
                    }
                }
                if(testDoc.queryCommandEnabled('bold')){
                    this._sbold=true;
                }else{
                    this._sbold=false;
                }
                if(testDoc.queryCommandEnabled('italic')){
                    this._sitalic=true;
                }else{
                    this._sitalic=false;
                }
                if(testDoc.queryCommandEnabled('underline')){
                    this._sunderline=true;
                }else{
                    this._sunderline=false;
                }
                if(testDoc.queryCommandEnabled('superscript')){
                    this._ssuperscript=true;
                }else{
                    this._ssuperscript=false;
                }
                if(testDoc.queryCommandEnabled('subscript')){
                    this._ssubscript=true;
                }else{
                    this._ssubscript=false;
                }
                if(testDoc.queryCommandEnabled('justifyleft')){
                    this._sjustifyleft=true;
                }else{
                    this._sjustifyleft=false;
                }
                if(testDoc.queryCommandEnabled('justifycenter')){
                    this._sjustifycenter=true;
                }else{
                    this._sjustifycenter=false;
                }
                if(testDoc.queryCommandEnabled('justifyright')){
                    this._sjustifyright=true;
                }else{
                    this._sjustifyright=false;
                }
                if(testDoc.queryCommandEnabled('justifyfull')){
                    this._sjustifyfull=true;
                }else{
                    this._sjustifyfull=false;
                }
        
// for now, we assume that if indent is supported, so is outdent...
// otherwise, we'll need to work with ranges & indent something, then test if outdent works...
// looks like I might have to do that (select something) to get anything is safari to test true anyhow...
                if(testDoc.queryCommandEnabled('indent')){
                    this._soutdent=true;
                    this._sindent=true;
                }else{
                    this._sindent=false;
                    this._soutdent=false;
                }
/*      
                if(testDoc.queryCommandEnabled('outdent')){
                    this._soutdent=true;
                }else{
                    this._soutdent=false;
                }
*/      
                if(testDoc.queryCommandEnabled('createlink')){
                    this._screatelink=true;
                }else{
                    this._screatelink=false;
                }
                if(testDoc.queryCommandEnabled('unlink')){
                    this._sunlink=true;
                }else{
                    this._sunlink=false;
                }
                if(testDoc.queryCommandEnabled('insertorderedlist')){
                    this._sinsertorderedlist=true;
                }else{
                    this._sinsertorderedlist=false;
                }
                if(testDoc.queryCommandEnabled('insertunorderedlist')){
                    this._sinsertunorderedlist=true;
                }else{
                    this._sinsertunorderedlist=false;
                }
                if(testDoc.queryCommandEnabled('inserthorizontalrule')){
                    this._sinserthorizontalrule=true;
                }else{
                    this._sinserthorizontalrule=false;
                }
        
                return true;
            }else{
                return false;
            }
        }else{
            return false;
        }
    }else{
        return false;
    }
}

/**
*   WYSIWYG_Editor::preview
*
*   Used open a pop-up window that allows the user to preview their page before they submit the form
**/
WYSIWYG_Editor.prototype.preview = function (){
    var prevWin=window.open('','','width='+this.prevWin_width+',height='+this.prevWin_height+',resizable=1,scrollbars=yes');
    var htmlCode=document.getElementById(this.wysiwyg_content).contentWindow.document.body.innerHTML;
    prevWin.document.write('<html><head><title>'+this.lang.content_preview+'</title>');
    if(this.stylesheet){
        // must be done after the document has been opened
        prevWin.document.write('<style type="text/css">@import url('+this.stylesheet+');</style>');
    }
    prevWin.document.write('</head><body>');
    prevWin.document.write(htmlCode);
    prevWin.document.write('</body></html>');
    prevWin.document.close();
    return true;
}

/**
*   WYSIWYG_Editor::print
*
*   Print out the content currently in the editor
**/
WYSIWYG_Editor.prototype.print = function (){
    document.getElementById(this.wysiwyg_content).contentWindow.focus();
    document.getElementById(this.wysiwyg_content).contentWindow.print();
}





/*****
    The following methods are used in my own custom CMS, but I have left them here for
    reference purposes in the event that you too want to incorporate some of this
    additional functionality.
*****/

/**********************************************************************************************************************************************************************/

/**
*   WYSIWYG_Editor::insertImage
*
*   Brings a pop-up window for the user to choose an image from to insert into the contents
*   This is really only part of my custom CMS, but I left it here for reference if other people
*   want to use a similar method.
*
*   @param string popurl The URL of the page to open in the pop-up window
**/
WYSIWYG_Editor.prototype.insertImage = function (popurl){
    if(typeof(popurl)=='undefined'){
        // this is just a default case until I can get my all my CMS code bases updated...
        this.imagePopUp=window.open(this.site_path+'/_include/back_end/image_dialog.php?page_title='+this.page_title,'','width=620,height=500,resizable=1,scrollbars=yes');
    }
    if(popurl!=''){
        this.imagePopUp=window.open(popurl,'','width=620,height=500,resizable=1,scrollbars=yes');
    }
    // if it was defined as an empty string, just do nothing
    // the button should not be displayed if that is the case
    // that is only there in case I forget...
}

/**********************************************************************************************************************************************************************/

/**
*   WYSIWYG_Editor::addImage
*
*   Puts the image into the editor iframe (Called from the pop-up window that insertImage creates)
**/
WYSIWYG_Editor.prototype.addImage = function (thisimage){
    if(this.imagePopUp && !this.imagePopUp.closed)
        this.imagePopUp.close();
    document.getElementById(this.wysiwyg_content).contentWindow.focus()
    if(this.viewMode==1){
        var x=document.getElementById(this.wysiwyg_content).contentWindow.document;
        x.execCommand('insertimage', false, thisimage);
    }
}

/**********************************************************************************************************************************************************************/

/**
*   WYSIWYG_Editor::checkSpelling
*
*   This method uses spellerpages 0.5.1 to check the spelling of our
*   content area's HTML code... May not produce the results we really
*   want, but it's better than not having any checking!
**/
WYSIWYG_Editor.prototype.checkSpelling = function (){
    if(this.spell_path.length > 0){
/**
NOW I WOULD LIKE A WAY TO DYNAMICALLY INCLUDE THE JAVASCRIPT FILE HERE. (LIKE INCLUDE IN PHP)
OTHERWISE, YOU NEED TO INCLUDE THE JS FILE IN THE HTML PAGE. I WANT TO AVOID THAT IF POSSIBLE.
I WASN'T ABLE TO FIND A CLEAN WAY OF DOING SO, AND USING XMLHttpRequest DIDN'T WORK.
**/

        if(typeof(spellChecker)!='undefined'){
            // file is included, time to create an object to use

            this.speller = new spellChecker(document.getElementById(this.wysiwyg_hidden));
            if(typeof(this.speller)!='undefined'){
                this.prepareSubmit(); // so that we are using the most updated code
                this.speller.popUpUrl = this.spell_path+'/spellchecker.html';
                this.speller.popUpName = 'spellchecker';
                //this.speller.popUpProps = "menu=no,width=440,height=350,top=70,left=120,resizable=yes,status=yes";
                this.speller.popUpProps = "width=440,height=350,top=70,left=120,resizable=yes,status=yes";
                
                // this should have been defined in the editor's constructor method...
                this.speller.spellCheckScript = this.spellCheckScript;
                
                // this is made to replace spellerpages 0.5.1 terminateSpell function - do this instead of
                // editing the original files since we only want to replace the function for THIS instance
                // of the spell checker in case spellerpages is used for other input elements on the same page.
                // if future versions of spellerpages change this function, then the code for this will also
                // need to be updated.
                this.speller.terminateSpell = function (){
/** start 0.5.1 terminateSpell() **/
                    	// called when we have reached the end of the spell checking. 
                    	var msg = this.lang.spell_check_complete+"\n\n"; 
                    	var numrepl = this._getTotalReplaced(); 
                    	if( numrepl == 0 ) { 
                    		// see if there were no misspellings to begin with 
                    		if( !this.wordWin ) { 
                    			msg = ""; 
                    		} else { 
                    			if( this.wordWin.totalMisspellings() ) { 
                    				msg += this.lang.spell_check_no_change; 
                    			} else { 
                    				msg += this.lang.spell_check_no_misspellings; 
                    			} 
                    		} 
                    	} else if( numrepl == 1 ) { 
                    		msg += this.lang.spell_check_one_change; 
                    	} else { 
                    		msg += numrepl + this.lang.spell_check_words_changed; 
                    	} 
                    	if( msg ) { 
                    		msg += "\n"; 
                    		alert( msg ); 
                    	} 
                     
                    	if( numrepl > 0 ) { 
                    		// update the text field(s) on the opener window
                    /** begin koivi edit **/
                    		if(this.textInputs.length && this.wordWin && this.wordWin.textInputs[0] ) {
            				    // the editor only has 1 input! 
            					var hidden_element = this.textInputs[0].name;
                                var iframe_element = (hidden_element.substring(0,hidden_element.length-8))+'_WYSIWYG_Editor';

                                // replace the values into the editor
                                document.getElementById(hidden_element).value = this.wordWin.textInputs[0];
                                document.getElementById(iframe_element).contentWindow.document.body.innerHTML = this.wordWin.textInputs[0];
                    	    }
                    /** end koivi edit **/
                    	} 
                     
                    	// return back to the calling window 
                    	this.spellCheckerWin.close();
                    	
                    	return true; 
/** end 0.5.1 terminateSpell() **/
                }
                this.speller.openChecker();
                return true;
            }else{
                alert(this.lang.spell_check_init_problem);
                return false;
            }
        }else{
            alert(this.lang.no_spellerpages);
        }
    }
}

/**********************************************************************************************************************************************************************/

/**
*   WYSIWYG_Editor::_get_offset_left
*
*   Used to define position of pop-up pallete window in Gecko browsers
**/
WYSIWYG_Editor.prototype._get_offset_left = function (elm){
    var mOffsetLeft=elm.offsetLeft;
    var mOffsetParent=elm.offsetParent;
    while(mOffsetParent){
        mOffsetLeft += mOffsetParent.offsetLeft;
        mOffsetParent=mOffsetParent.offsetParent;
    }
    return mOffsetLeft;
}

/**********************************************************************************************************************************************************************/

/**
*   WYSIWYG_Editor::_get_offset_top
*
*   Used to define position of pop-up pallete window in Gecko browsers
**/
WYSIWYG_Editor.prototype._get_offset_top = function (elm){
    var mOffsetTop=elm.offsetTop;
    var mOffsetParent=elm.offsetParent;
    while(mOffsetParent){
        mOffsetTop += mOffsetParent.offsetTop;
        mOffsetParent=mOffsetParent.offsetParent;
    }
    return mOffsetTop;
}

/**
*   WYSIWYG_Editor::_objDump
*
*   This is used during debugging and development
**/
WYSIWYG_Editor.prototype._objDump = function (refObj){
    s=''
	for (objProp in refObj) { 
	    s += '<p>' + objProp + ' => ' + refObj[objProp] + '</p>'; 
	}
	// why does this code work in the old version, but not the new one with the same browser?
    pwin = window.open();
    pwin.document.write(s);
    pwin.document.close();
}
