document.write( '<style type="text/css">\n' + 
	'.btn     { width: 22px; height: 22px; border: 1px solid buttonface; margin: 0; padding: 0; }\n' +
	'.btnOver { width: 22px; height: 22px; border: 1px outset; }\n' +
	'.btnDown { width: 22px; height: 22px; border: 1px inset; background-color: buttonhighlight; }\n' +
	'.btnNA   { width: 22px; height: 22px; border: 1px solid buttonface; filter: alpha(opacity=25); }\n' +
	'.cMenu     { background-color: threedface; color: menutext; cursor: Default; font-family: MS Sans Serif; font-size: 8pt; padding: 2 12 2 16; }' +
	'.cMenuOver { background-color: highlight; color: highlighttext; cursor: Default; font-family: MS Sans Serif; font-size: 8pt; padding: 2 12 2 16; }' +
	'.cMenuDivOuter { background-color: threedface; height: 9 }' +
	'.cMenuDivInner { margin: 0 4 0 4; border-width: 1; border-style: solid; border-color: threedshadow threedhighlight threedhighlight threedshadow; }' +
	'</style>\n');

function editor_defaultConfig(objname) {
this.version = "2.03";this.width =  "auto";this.height = "auto";
this.bodyStyle = 'background-color: #FFFFFF; font-family: "Verdana"; font-size: x-small;';
this.imgURL = _editor_url + 'images/';this.debug  = 0;this.replaceNextlines = 0;this.plaintextInput = 0;
this.toolbar = [['fontname'],['fontsize'],['linebreak'],['bold','italic','underline','separator'],['strikethrough','subscript','superscript','separator'],['justifyleft','justifycenter','justifyright','separator'],['OrderedList','UnOrderedList','Outdent','Indent','separator'],['forecolor','backcolor','separator'],['HorizontalRule','Createlink','InsertImage']];
this.fontnames = {
    "Arial":           "arial, helvetica, sans-serif",
    "Courier New":     "courier new, courier, mono",
    "Georgia":         "Georgia, Times New Roman, Times, Serif",
    "Tahoma":          "Tahoma, Arial, Helvetica, sans-serif",
    "Times New Roman": "times new roman, times, serif",
    "Verdana":         "Verdana, Arial, Helvetica, sans-serif",
    "impact":          "impact",
    "WingDings":       "WingDings"};
this.fontsizes = {
    "1 (8 pt)":  "1",
    "2 (10 pt)": "2",
    "3 (12 pt)": "3",
    "4 (14 pt)": "4",
    "5 (18 pt)": "5",
    "6 (24 pt)": "6",
    "7 (36 pt)": "7"
  };
this.fontstyles = [];
this.btnList = {
    "bold":           ['Bold',                 'Bold',               'editor_action(this.id)',  'ed_format_bold.gif'],
    "italic":         ['Italic',               'Italic',             'editor_action(this.id)',  'ed_format_italic.gif'],
    "underline":      ['Underline',            'Underline',          'editor_action(this.id)',  'ed_format_underline.gif'],
    "strikethrough":  ['StrikeThrough',        'Strikethrough',      'editor_action(this.id)',  'ed_format_strike.gif'],
    "subscript":      ['SubScript',            'Subscript',          'editor_action(this.id)',  'ed_format_sub.gif'],
    "superscript":    ['SuperScript',          'Superscript',        'editor_action(this.id)',  'ed_format_sup.gif'],
    "justifyleft":    ['JustifyLeft',          'Justify Left',       'editor_action(this.id)',  'ed_align_left.gif'],
    "justifycenter":  ['JustifyCenter',        'Justify Center',     'editor_action(this.id)',  'ed_align_center.gif'],
    "justifyright":   ['JustifyRight',         'Justify Right',      'editor_action(this.id)',  'ed_align_right.gif'],
    "orderedlist":    ['InsertOrderedList',    'Ordered List',       'editor_action(this.id)',  'ed_list_num.gif'],
    "unorderedlist":  ['InsertUnorderedList',  'Bulleted List',      'editor_action(this.id)',  'ed_list_bullet.gif'],
    "outdent":        ['Outdent',              'Decrease Indent',    'editor_action(this.id)',  'ed_indent_less.gif'],
    "indent":         ['Indent',               'Increase Indent',    'editor_action(this.id)',  'ed_indent_more.gif'],
    "forecolor":      ['ForeColor',            'Font Color',         'editor_action(this.id)',  'ed_color_fg.gif'],
    "backcolor":      ['BackColor',            'Background Color',   'editor_action(this.id)',  'ed_color_bg.gif'],
    "horizontalrule": ['InsertHorizontalRule', 'Horizontal Rule',    'editor_action(this.id)',  'ed_hr.gif'],
    "createlink":     ['CreateLink',           'Insert Web Link',    'editor_action(this.id)',  'ed_link.gif'],
    "insertimage":    ['InsertImage',          'Insert Image',       'editor_action(this.id)',  'ed_image.gif'],
    "popupeditor":    ['popupeditor',          'Enlarge Editor',     'editor_action(this.id)',  'fullscreen_maximize.gif'],
    "about":          ['about',                'About this editor',  'editor_about(\''+objname+'\')',  'ed_about.gif'],
    "help":           ['showhelp',             'Help using editor',  'editor_action(this.id)',  'ed_help.gif']};
}

function editor_generate(objname,userConfig) {
  var config = new editor_defaultConfig(objname);
  if (userConfig) { 
    for (var thisName in userConfig) {
      if (userConfig[thisName]) { config[thisName] = userConfig[thisName]; }
    }
  }
  document.all[objname].config = config;
  var obj    = document.all[objname];
  if (!config.width || config.width == "auto") {
    if      (obj.style.width) { config.width = obj.style.width; }
    else if (obj.cols)        { config.width = (obj.cols * 8) + 22; }
    else                      { config.width = '100%'; }
  }
  if (!config.height || config.height == "auto") {
    if      (obj.style.height) { config.height = obj.style.height; }
    else if (obj.rows)         { config.height = obj.rows * 17 }
    else                       { config.height = '200'; }
  }
  var tblOpen  = '<table border=0 cellspacing=0 cellpadding=0 style="float: left;"  unselectable="on"><tr><td style="border: none; padding: 1 0 0 0"><nobr>';
  var tblClose = '</nobr></td></tr></table>\n';
  var toolbar = '';
  var btnGroup, btnItem, aboutEditor;
  for (var btnGroup in config.toolbar) {
    if (config.toolbar[btnGroup].length == 1 &&
        config.toolbar[btnGroup][0].toLowerCase() == "linebreak") {
      toolbar += '<br clear="all">';
      continue;
    }
    toolbar += tblOpen;
    for (var btnItem in config.toolbar[btnGroup]) {
      var btnName = config.toolbar[btnGroup][btnItem].toLowerCase();
      if (btnName == "fontname") {
        toolbar += '<select id="_' +objname+ '_FontName" onChange="editor_action(this.id)" unselectable="on" style="margin: 1 2 0 2; font-size: 12px;">';
        for (var fontname in config.fontnames) {
          toolbar += '<option value="' +config.fontnames[fontname]+ '"'+ (config.bodyStyle.toLowerCase().indexOf(fontname.toLowerCase())!=-1?' selected':'') +'>' +fontname+ '</option>'
        }
        toolbar += '</select>';
        continue;
      }
      if (btnName == "fontsize") {
        toolbar += '<select id="_' +objname+ '_FontSize" onChange="editor_action(this.id)" unselectable="on" style="margin: 1 2 0 0; font-size: 12px;">';
        for (var fontsize in config.fontsizes) {
          toolbar += '<option value="' +config.fontsizes[fontsize]+ '">' +fontsize+ '</option>'
        }
        toolbar += '</select>\n';
        continue;
      }
      if (btnName == "fontstyle") {
        toolbar += '<select id="_' +objname+ '_FontStyle" onChange="editor_action(this.id)" unselectable="on" style="margin: 1 2 0 0; font-size: 12px;">';
        + '<option value="">Font Style</option>';
        for (var i in config.fontstyles) {
          var fontstyle = config.fontstyles[i];
          toolbar += '<option value="' +fontstyle.className+ '">' +fontstyle.name+ '</option>'
        }
        toolbar += '</select>';
        continue;
      }
      if (btnName == "separator") {
        toolbar += '<span style="border: 1px inset; width: 1px; font-size: 16px; height: 16px; margin: 0 3 0 3"></span>';
        continue;
      }
      var btnObj = config.btnList[btnName];
      if (btnName == 'linebreak') { alert("htmlArea error: 'linebreak' must be in a subgroup by itself, not with other buttons.\n\nhtmlArea wysiwyg editor not created."); return; }
      if (!btnObj) { alert("htmlArea error: button '" +btnName+ "' not found in button list when creating the wysiwyg editor for '"+objname+"'.\nPlease make sure you entered the button name correctly.\n\nhtmlArea wysiwyg editor not created."); return; }
      var btnCmdID   = btnObj[0];
      var btnTitle   = btnObj[1];
      var btnOnClick = btnObj[2];
      var btnImage   = btnObj[3];
      toolbar += '<button title="' +btnTitle+ '" id="_' +objname+ '_' +btnCmdID+ '" class="btn" onClick="' +btnOnClick+ '" onmouseover="if(this.className==\'btn\'){this.className=\'btnOver\'}" onmouseout="if(this.className==\'btnOver\'){this.className=\'btn\'}" unselectable="on"><img src="' +config.imgURL + btnImage+ '" border=0 unselectable="on"></button>';
    }
    toolbar += tblClose;
  }
  var editor = '<span id="_editor_toolbar"><table border=0 cellspacing=0 cellpadding=0 bgcolor="buttonface" style="padding: 1 0 0 2" width=' + config.width + ' unselectable="on"><tr><td>\n'
  + toolbar
  + '</td></tr></table>\n'
  + '</td></tr></table></span>\n'
  + '<textarea ID="_' +objname + '_editor" style="width:' +config.width+ '; height:' +config.height+ '; margin-top: -1px; margin-bottom: -1px;" wrap=soft></textarea>';

  // add context menu
  editor += '<div id="_' +objname + '_cMenu" style="position: absolute; visibility: hidden;"></div>';
  if (!config.debug) { document.all[objname].style.display = "none"; }

  if (config.plaintextInput) {     // replace nextlines with breaks
    var contents = document.all[objname].value;
    contents = contents.replace(/\r\n/g, '<br>');
    contents = contents.replace(/\n/g, '<br>');
    contents = contents.replace(/\r/g, '<br>');
    document.all[objname].value = contents;
  }
  document.all[objname].insertAdjacentHTML('afterEnd', editor)
  editor_setmode(objname, 'init');
  for (var idx=0; idx < document.forms.length; idx++) {
    var r = document.forms[idx].attachEvent('onsubmit', function() { editor_filterOutput(objname); });
    if (!r) { alert("Error attaching event to form!"); }
  }
return true;
}

function editor_action(button_id) {

  var BtnParts = Array();
  BtnParts = button_id.split("_");
  var objname    = button_id.replace(/^_(.*)_[^_]*$/, '$1');
  var cmdID      = BtnParts[ BtnParts.length-1 ];
  var button_obj = document.all[button_id];
  var eO = document.all["_" +objname + "_editor"];
  var config     = document.all[objname].config;
  if (eO.tagName.toLowerCase() == 'textarea') { return; }
  var editdoc = eO.contentWindow.document;
  editor_focus(eO);
  var idx = button_obj.selectedIndex;
  var val = (idx != null) ? button_obj[ idx ].value : null;
  if (0) {}
  else if (cmdID == 'FontName' && val) {
    editdoc.execCommand(cmdID,0,val);
  }
  else if (cmdID == 'FontSize' && val) {
    editdoc.execCommand(cmdID,0,val);
  }
  else if (cmdID == 'FontStyle' && val) {
    editdoc.execCommand('RemoveFormat');
    editdoc.execCommand('FontName',0,'636c6173734e616d6520706c616365686f6c646572');
    var fontArray = editdoc.all.tags("FONT");
    for (i=0; i<fontArray.length; i++) {
      if (fontArray[i].face == '636c6173734e616d6520706c616365686f6c646572') {
        fontArray[i].face = "";
        fontArray[i].className = val;
        fontArray[i].outerHTML = fontArray[i].outerHTML.replace(/face=['"]+/, "");
        }
    }
    button_obj.selectedIndex =0;
  }

  else if (cmdID == 'ForeColor' || cmdID == 'BackColor') {
    var oldcolor = _dec_to_rgb(editdoc.queryCommandValue(cmdID));
    var newcolor = showModalDialog(_editor_url + "popups/select_color.html", oldcolor, "resizable: no; help: no; status: no; scroll: no;");
    if (newcolor != null) { editdoc.execCommand(cmdID, false, "#"+newcolor); }
  }
  else {
    if (cmdID.toLowerCase() == 'subscript' && editdoc.queryCommandState('superscript')) { editdoc.execCommand('superscript'); }
    if (cmdID.toLowerCase() == 'superscript' && editdoc.queryCommandState('subscript')) { editdoc.execCommand('subscript'); }
    if (cmdID.toLowerCase() == 'createlink'){
      editdoc.execCommand(cmdID,1);
    }
    else if (cmdID.toLowerCase() == 'insertimage'){
      showModalDialog(_editor_url + "popups/insert_image.html", editdoc, "resizable: no; help: no; status: no; scroll: no; ");
    }
/*
    else if (cmdID.toLowerCase() == 'inserttable'){
      showModalDialog(_editor_url + "popups/insert_table.html?"+objname, window, "resizable: yes; help: no; status: no; scroll: no; ");
    }
*/
    else { editdoc.execCommand(cmdID); }
  }
  editor_event(objname);
}

function editor_event(objname,runDelay) {
  var config = document.all[objname].config;
  var eO  = document.all["_" +objname+  "_editor"];
  if (runDelay == null) { runDelay = 0; }
  var editdoc;
  var editEvent = eO.contentWindow ? eO.contentWindow.event : event;
    if (editEvent && editEvent.keyCode) {
      var ord       = editEvent.keyCode;
      var ctrlKey   = editEvent.ctrlKey;
      var altKey    = editEvent.altKey;
      var shiftKey  = editEvent.shiftKey;

      if (ord == 16 || ord == 17 || ord == 18) { return; }

      if (ctrlKey && (ord == 122 || ord == 90)) {
        return;
      }
      if ((ctrlKey && (ord == 121 || ord == 89)) ||
          ctrlKey && shiftKey && (ord == 122 || ord == 90)) {
        return;
      }
    }
  if (runDelay > 0) { return setTimeout(function(){ editor_event(objname); }, runDelay); }
  if (this.tooSoon == 1 && runDelay >= 0) { this.queue = 1; return; } // queue all but urgent events
  this.tooSoon = 1;
  setTimeout(function(){
    this.tooSoon = 0;
    if (this.queue) { editor_event(objname,-1); };
    this.queue = 0;
    }, 333);
  editor_updateOutput(objname);
  editor_updateToolbar(objname);
}

function editor_updateToolbar(objname,action) {
  var config = document.all[objname].config;
  var eO  = document.all["_" +objname+  "_editor"];
  if (action == "enable" || action == "disable") {
    var tbItems = new Array('FontName','FontSize','FontStyle');                           // add pulldowns
    for (var btnName in config.btnList) { tbItems.push(config.btnList[btnName][0]); } // add buttons
    for (var idxN in tbItems) {
      var cmdID = tbItems[idxN].toLowerCase();
      var tbObj = document.all["_" +objname+ "_" +tbItems[idxN]];
      if (cmdID == "htmlmode" || cmdID == "textmode" || cmdID == "about" || cmdID == "showhelp" || cmdID == "popupeditor") { continue; } // don't change these buttons
      if (tbObj == null) { continue; }
      var isBtn = (tbObj.tagName.toLowerCase() == "button") ? true : false;
      if (action == "enable")  { tbObj.disabled = false; if (isBtn) { tbObj.className = 'btn' }}
      if (action == "disable") { tbObj.disabled = true;  if (isBtn) { tbObj.className = 'btnNA' }}
    }
    return;
  }
  if (eO.tagName.toLowerCase() == 'textarea') { return; }   // don't update state in textedit mode
  var editdoc = eO.contentWindow.document;
  var fontnameO = document.all["_" +objname+ "_FontName"];
  if (fontnameO) {
    var fontname = editdoc.queryCommandValue('FontName');
    if (fontname == null) { fontnameO.value = null; }
    else {
      var found = 0;
      for (i=0; i<fontnameO.length; i++) {
        if (fontname.toLowerCase() == fontnameO[i].text.toLowerCase()) {
          fontnameO.selectedIndex = i;
          found = 1;
        }
      }
      if (found != 1) { fontnameO.value = null; }     // for fonts not in list
    }
  }
  var fontsizeO = document.all["_" +objname+ "_FontSize"];
  if (fontsizeO) {
    var fontsize = editdoc.queryCommandValue('FontSize');
    if (fontsize == null) { fontsizeO.value = null; }
    else {
      var found = 0;
      for (i=0; i<fontsizeO.length; i++) {
        if (fontsize == fontsizeO[i].value) { fontsizeO.selectedIndex = i; found=1; }
      }
      if (found != 1) { fontsizeO.value = null; }     // for sizes not in list
    }
  }
  var classnameO = document.all["_" +objname+ "_FontStyle"];
  if (classnameO) {
    var curRange = editdoc.selection.createRange();
    var pElement;
    if (curRange.length) { pElement = curRange[0]; }              // control tange
    else                 { pElement = curRange.parentElement(); } // text range
    while (pElement && !pElement.className) { pElement = pElement.parentElement; }  // keep going up
    var thisClass = pElement ? pElement.className.toLowerCase() : "";
    if (!thisClass && classnameO.value) { classnameO.value = null; }
    else {
      var found = 0;
      for (i=0; i<classnameO.length; i++) {
        if (thisClass == classnameO[i].value.toLowerCase()) {
          classnameO.selectedIndex = i;
          found=1;
        }
      }
      if (found != 1) { classnameO.value = null; }     // for classes not in list
    }
  }
  var IDList = Array('Bold','Italic','Underline','StrikeThrough','SubScript','SuperScript','JustifyLeft','JustifyCenter','JustifyRight','InsertOrderedList','InsertUnorderedList');
  for (i=0; i<IDList.length; i++) {
    var btnObj = document.all["_" +objname+ "_" +IDList[i]];
    if (btnObj == null) { continue; }
    var cmdActive = editdoc.queryCommandState( IDList[i] );
    if (!cmdActive)  {
      if (btnObj.className != 'btn') { btnObj.className = 'btn'; }
      if (btnObj.disabled  != false) { btnObj.disabled = false; }
    } else if (cmdActive)  {
      if (btnObj.className != 'btnDown') { btnObj.className = 'btnDown'; }
      if (btnObj.disabled  != false)   { btnObj.disabled = false; }
    }
  }
}
function editor_updateOutput(objname) {
  var config     = document.all[objname].config;
  var eO  = document.all["_" +objname+  "_editor"];
  var editEvent = eO.contentWindow ? eO.contentWindow.event : event;
  var isTextarea = (eO.tagName.toLowerCase() == 'textarea');
  var editdoc = isTextarea ? null : eO.contentWindow.document;
  var contents;
  if (isTextarea) { contents = eO.value; }
  else            { contents = editdoc.body.innerHTML; }
  if (config.lastUpdateOutput && config.lastUpdateOutput == contents) { return; }
  else { config.lastUpdateOutput = contents; }
  document.all[objname].value = contents;
}
function editor_filterOutput(objname) {
  editor_updateOutput(objname);
  var eO  = document.all["_" +objname+  "_editor"];
  var contents = document.all[objname].value;
  var config   = document.all[objname].config;
  if (contents.toLowerCase() == '<p>&nbsp;</p>') { contents = ""; }
  var filterTag = function(tagBody,tagName,tagAttr) {
    tagName = tagName.toLowerCase();
    var closingTag = (tagBody.match(/^<\//)) ? true : false;
    if (tagName == 'img') { tagBody = tagBody.replace(/(src\s*=\s*.)[^*]*(\*\*\*)/, "$1$2"); }
    if (tagName == 'a')   { tagBody = tagBody.replace(/(href\s*=\s*.)[^*]*(\*\*\*)/, "$1$2"); }
    return tagBody;
  };

  RegExp.lastIndex = 0;
    var matchTag = /<\/?(\w+)((?:[^'">]*|'[^']*'|"[^"]*")*)>/g;
  contents = contents.replace(matchTag, filterTag);
  if (config.replaceNextlines) { 
    contents = contents.replace(/\r\n/g, ' ');
    contents = contents.replace(/\n/g, ' ');
    contents = contents.replace(/\r/g, ' ');
  }
  document.all['BodyHTML'].value = contents;
  document.all['Body'].value = editor_getText(objname);
}
function editor_setmode(objname, mode) {
  var config     = document.all[objname].config;
  var eO = document.all["_" +objname + "_editor"];
  if (document.readyState != 'complete') {
    setTimeout(function() { editor_setmode(objname,mode) }, 25);
    return;
  }
  var TextEdit   = '<textarea tabindex="13" ID="_' +objname + '_editor" style="width:' +eO.style.width+ '; height:' +eO.style.height+ '; margin-top: -1px; margin-bottom: -1px;"></textarea>';
  var RichEdit   = '<iframe tabindex="13" src="'+_editor_url+'popups/blank.html" ID="_' +objname+ '_editor" style="width:' +eO.style.width+ '; height:' +eO.style.height+ ';"></iframe>';
  if (mode == "textedit" || eO.tagName.toLowerCase() == 'iframe') {
    config.mode = "textedit";
    var editdoc = eO.contentWindow.document;
    var contents = editdoc.body.createTextRange().htmlText;
    eO.outerHTML = TextEdit;
    eO = document.all["_" +objname + "_editor"];
    eO.value = contents;
    editor_event(objname);
    editor_updateToolbar(objname, "disable");  // disable toolbar items
    eO.onkeydown   = function() { editor_event(objname); }
    eO.onkeypress  = function() { editor_event(objname); }
    eO.onkeyup     = function() { editor_event(objname); }
    eO.onmouseup   = function() { editor_event(objname); }
    eO.ondrop      = function() { editor_event(objname, 100); }     // these events fire before they occur
    eO.oncut       = function() { editor_event(objname, 100); }
    eO.onpaste     = function() { editor_event(objname, 100); }
    eO.onblur      = function() { editor_event(objname, -1); }
    editor_updateOutput(objname);
    editor_focus(eO);
  }
  else {
    config.mode = "wysiwyg";
    var contents = eO.value;
    if (mode == 'init') { contents = document.all[objname].value; }
    eO.outerHTML = RichEdit;
    eO = document.all["_" +objname + "_editor"];
    var html = "";
    html += '<html><head>\n';
    html += '<style>\n';
    html += 'body {' +config.bodyStyle+ '} \n';
    for (var i in config.fontstyles) {
      var fontstyle = config.fontstyles[i];
      if (fontstyle.classStyle) {
        html += '.' +fontstyle.className+ ' {' +fontstyle.classStyle+ '}\n';
      }
    }
	html += 'p{margin:0px;padding:0px;}\n';
    html += '</style>\n'
      + '</head>\n'
      + '<body contenteditable="true" topmargin=1 leftmargin=1'
      +'>'
      + (contents.length == 0 ? '<div style="'+ config.bodyStyle +'"></div>' : contents)
      + '</body>\n'
      + '</html>\n';
    var editdoc = eO.contentWindow.document;
    editdoc.open();
    editdoc.write(html);
    editdoc.close();
    editor_updateToolbar(objname, "enable");
    editdoc.objname = objname;
    editdoc.onkeydown      = function() { editor_event(objname); }
    editdoc.onkeypress     = function() { editor_event(objname); }
    editdoc.onkeyup        = function() { editor_event(objname); }
    editdoc.onmouseup      = function() { editor_event(objname); }
    editdoc.body.ondrop    = function() { editor_event(objname, 100); }
    editdoc.body.oncut     = function() { editor_event(objname, 100); }
    editdoc.body.onpaste   = function() { editor_event(objname, 100); }
    editdoc.body.onblur    = function() { editor_event(objname, -1); }
    if (mode != 'init') {
      editor_focus(eO);
    }

  }
  if (mode != 'init') {
    editor_event(objname);
  }

}

function editor_focus(eO) {
try{
  if (eO.tagName.toLowerCase() == 'textarea') {
    var myfunc = function() { eO.focus(); };
    setTimeout(myfunc,100);
  }
  else {
    var editdoc = eO.contentWindow.document;
    var editorRange = editdoc.body.createTextRange();
    var curRange    = editdoc.selection.createRange();
    if (curRange.length == null && !editorRange.inRange(curRange)) {
      editorRange.collapse();
      editorRange.select();
      curRange = editorRange;
    }
  }
}catch(exception)
{
	// do nothing if you can't get focus
}
}
function _dec_to_rgb(value) {
  var hex_string = "";
  for (var hexpair = 0; hexpair < 3; hexpair++) {
    var myByte = value & 0xFF;
    value >>= 8;
    var nybble2 = myByte & 0x0F;
    var nybble1 = (myByte >> 4) & 0x0F;
    hex_string += nybble1.toString(16);
    hex_string += nybble2.toString(16);
  }
  return hex_string.toUpperCase();
}

function editor_insertHTML(objname, str1,str2, reqSel) {
  var config     = document.all[objname].config;
  var eO = document.all["_" +objname + "_editor"];
  if (str1 == null) { str1 = ''; }
  if (str2 == null) { str2 = ''; }
  if (document.all[objname] && eO == null) {
    document.all[objname].focus();
    document.all[objname].value = document.all[objname].value + str1 + str2;
    return;
  }
  if (eO == null) { return alert("Unable to insert HTML.  Invalid object name '" +objname+ "'."); }
  editor_focus(eO);
  var tagname = eO.tagName.toLowerCase();
  var sRange;
  if (tagname == 'iframe') {
    var editdoc = eO.contentWindow.document;
    sRange  = editdoc.selection.createRange();
    var sHtml   = sRange.htmlText;
    if (sRange.length) { return alert("Unable to insert HTML.  Try highlighting content instead of selecting it."); }
    var oldHandler = window.onerror;
    window.onerror = function() { alert("Unable to insert HTML for current selection."); return true; } // partial table selections cause errors
    if (sHtml.length) {
      if (str2) { sRange.pasteHTML(str1 +sHtml+ str2) }
      else      { sRange.pasteHTML(str1); }
    } else {
      if (reqSel) { return alert("Unable to insert HTML.  You must select something first."); }
      sRange.pasteHTML(str1 + str2);
    }
    window.onerror = oldHandler;
  }
  else if (tagname == 'textarea') {
    eO.focus();
    sRange  = document.selection.createRange();
    var sText   = sRange.text;
    if (sText.length) {
      if (str2) { sRange.text = str1 +sText+ str2; }
      else { sRange.text = str1; }
    } else {
      if (reqSel) { return alert("Unable to insert HTML.  You must select something first."); }
      sRange.text = str1 + str2;
    }
  }
  else { alert("Unable to insert HTML.  Unknown object tag type '" +tagname+ "'."); }
  sRange.collapse(false);
  sRange.select();

}
function editor_getHTML(objname) {
  var eO = document.all["_" +objname + "_editor"];
  var isTextarea = (eO.tagName.toLowerCase() == 'textarea');

  if (isTextarea) { return eO.value; }
  else            { return eO.contentWindow.document.body.innerHTML; }
}
function editor_getText(objname)
{
  var eO = document.all["_" +objname + "_editor"];
  var isTextarea = (eO.tagName.toLowerCase() == 'textarea');

  if (isTextarea) { return eO.value; }
  else            { return eO.contentWindow.document.body.innerText; }
}
function editor_setHTML(objname, html) {
  var eO = document.all["_" +objname + "_editor"];
  var isTextarea = (eO.tagName.toLowerCase() == 'textarea');
  if (isTextarea) { eO.value = html; }
  else            { eO.contentWindow.document.body.innerHTML = html; }
}
function editor_appendHTML(objname, html) {
  var eO = document.all["_" +objname + "_editor"];
  var isTextarea = (eO.tagName.toLowerCase() == 'textarea');
  if (isTextarea) { eO.value += html; }
  else            { eO.contentWindow.document.body.innerHTML += html; }
}
function _isMouseOver(obj,event) {
  var mouseX    = event.clientX;
  var mouseY    = event.clientY;
  var objTop    = obj.offsetTop;
  var objBottom = objTop + obj.offsetHeight;
  var objLeft   = obj.offsetLeft;
  var objRight  = objLeft + obj.offsetWidth;
  if (mouseX >= objLeft && mouseX <= objRight &&
      mouseY >= objTop  && mouseY <= objBottom) { return true; }
  return false;
}
