////////////////////////////////////////////////////////////////////////
//
//                            CHEditor 3.1
//
//       Author: ³ªÃ¢È£
//       EMail:  chna@chcode.com
//       Homepage: http://chcode.com, http://chsoft.co.kr
//
//       Copyright (C) 1997-2006, CHSoft. All rights reserved.
//
////////////////////////////////////////////////////////////////////////

var chutil = new CH_UTILITIES();
var command = "";
var editorPath = "";

var htmlKey = [
    "!DOCTYPE", "A", "ABBR", "ACRONYM", "ADDRESS", "APPLET",
    "AREA", "B", "BASE", "BASEFONT", "BGSOUND", "BDO",
    "BIG", "BLINK", "DL", "BODY", "BR", "BUTTON",
    "CAPTION", "CENTER", "CITE", "CODE", "COL", "COLGROUP",
    "COMMENT", "DD", "DEL", "DFN", "DIR", "DIV",
    "FONT", "DT", "EM", "EMBED", "FIELDSET", "BLOCKQUOTE",
    "FORM", "FRAME", "FRAMESET", "H", "H1", "H2",
    "H3", "H4", "H5", "H6", "HEAD", "HR",
    "HTML", "I", "IFRAME", "IMG", "INPUT", "INS",
    "ISINDEX", "KBD", "LABEL", "LEGEND", "LI", "LINK",
    "LISTING", "MAP", "MARQUEE", "MENU", "META", "MULTICOL",
    "NEXTID", "NOBR", "NOFRAMES", "NOSCRIPT", "OBJECT", "OL",
    "OPTGROUP", "OPTION", "P", "PARAM", "PLAINTEXT","PRE",
    "Q", "S", "SAMP", "SCRIPT", "SELECT", "SERVER",
    "SMALL", "SOUND", "SPACER", "SPAN", "STRIKE", "STRONG",
    "STYLE", "SUB", "SUP", "TABLE", "TBODY", "TD",
    "TEXTAREA", "TITLE", "TFOOT", "TH", "THEAD", "TEXTFLOW",
    "TR", "TT", "U", "UL", "VAR", "WBR", "XMP"
];

var colorTable = [
    "#FF0000", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFFFFF", "#F5F5F5", "#DCDCDC", "#FFFAFA",
    "#D3D3D3", "#C0C0C0", "#A9A9A9", "#808080", "#696969", "#000000", "#2F4F4F", "#708090", "#778899", "#4682B4",
    "#4169E1", "#6495ED", "#B0C4DE", "#7B68EE", "#6A5ACD", "#483D8B", "#191970", "#000080", "#00008B", "#0000CD",
    "#1E90FF", "#00BFFF", "#87CEFA", "#87CEEB", "#ADD8E6", "#B0E0E6", "#F0FFFF", "#E0FFFF", "#AFEEEE", "#00CED1",
    "#5F9EA0", "#48D1CC", "#00FFFF", "#40E0D0", "#20B2AA", "#008B8B", "#008080", "#7FFFD4", "#66CDAA", "#8FBC8F",
    "#3CB371", "#2E8B57", "#006400", "#008000", "#228B22", "#32CD32", "#00FF00", "#7FFF00", "#7CFC00", "#ADFF2F",
    "#98FB98", "#90EE90", "#00FF7F", "#00FA9A", "#556B2F", "#6B8E23", "#808000", "#BDB76B", "#B8860B", "#DAA520",
    "#FFD700", "#F0E68C", "#EEE8AA", "#FFEBCD", "#FFE4B5", "#F5DEB3", "#FFDEAD", "#DEB887", "#D2B48C", "#BC8F8F",
    "#A0522D", "#8B4513", "#D2691E", "#CD853F", "#F4A460", "#8B0000", "#800000", "#A52A2A", "#B22222", "#CD5C5C",
    "#F08080", "#FA8072", "#E9967A", "#FFA07A", "#FF7F50", "#FF6347", "#FF8C00", "#FFA500", "#FF4500", "#DC143C",
    "#FF0000", "#FF1493", "#FF00FF", "#FF69B4", "#FFB6C1", "#FFC0CB", "#DB7093", "#C71585", "#800080", "#8B008B",
    "#9370DB", "#8A2BE2", "#4B0082", "#9400D3", "#9932CC", "#BA55D3", "#DA70D6", "#EE82EE", "#DDA0DD", "#D8BFD8",
    "#E6E6FA", "#F8F8FF", "#F0F8FF", "#F5FFFA", "#F0FFF0", "#FAFAD2", "#FFFACD", "#FFF8DC", "#FFFFE0", "#FFFFF0",
    "#FFFAF0", "#FAF0E6", "#FDF5E6", "#FAEBD7", "#FFE4C4", "#FFDAB9", "#FFEFD5", "#FFF5EE", "#FFF0F5", "#FFE4E1"
];

function CH_UTILITIES()
{
    this.oname;
}

function setIcon(icon_name, width, height, cmd)
{
    var icon = this.editorPath + '/icons/' + icon_name + ' width='+width+' height='+height+' align="absmiddle" ';
    return ("<img src="+icon+"onmouseup=\""+cmd+"\" style=\"cursor:pointer;\" />");
}

function inside_editor(el)
{
    while (el != null) {
        if (el.tagName=="BODY" && el.contentEditable=="true")
            return true;
        el = el.parentElement;
    }
    return false;
}

function set_selection()
{
    var myobj = eval("id" + this.oname);
    this.selection = myobj.document.selection.createRange();
    this.selection_type = myobj.document.selection.type;
}

function fix_selection(oname, selection)
{
    var myobj = eval("id" + oname);

    if(selection.parentElement != null) {
        if(!inside_editor(selection.parentElement())) {
            myobj.focus();
            var selection = myobj.document.selection.createRange();
        }
    }
    else {
        if(!inside_editor(selection.item(0))) {
            myobj.focus();
            var selection = myobj.document.selection.createRange();
        }
    }

    return selection;
}

function fix_selection_type(oname, selection, selection_type)
{
    var myobj = eval("id" + oname);

    if (selection.parentElement != null) {
        if (!inside_editor(selection.parentElement())) {
            myobj.focus();
            var selection_type = myobj.document.selection.type;
        }
    }
    else {
        if (!inside_editor(selection.item(0))) {
            myobj.focus();
            var selectoin_type = myobj.document.selection.type;
        }
    }
    return selection_type;
}

function exec(exec, opt)
{
    var myobj = eval("id" + this.oname);
    var target;
    var selection;

    if (this.IE) {
        selection = myobj.document.selection.createRange();
        var selection_type = myobj.document.selection.type;
        var oname = this.oname;

        selection = fix_selection(oname, selection);
        selection_type = fix_selection_type(oname, selection, selection_type);

        var target = (selection_type == "None" ? myobj.document : selection);
    }
    else {
        target = myobj.document;
    }

    myobj.focus();
    target.execCommand(exec, false, opt);
}

function exec2(exec, opt)
{
    var myobj = eval("id" + this.oname);
    var selection = this.selection;
    var selection_type = this.selection_type;
    var oname = this.oname;

    selection = fix_selection(oname, selection);
    selection_type = fix_selection_type(oname, selection, selection_type);

    var target = (selection_type == "None" ? myobj.document : selection);
    selection.select();
    myobj.focus();
    target.execCommand(exec, false, opt);
}

function exec3(html)
{
    this.box_hide();

    var myobj = eval("id" + this.oname);
    myobj.focus();

    var select = myobj.document.selection.createRange();
    select.pasteHTML(html);
}

function hyperLink (szURL, szTarget, szTitle)
{
    var myobj = eval("id" + this.oname);
    var el;

    if (this.IE) {
        var sel = this.selection;
        var sel_type = this.selection_type;
        var oname = this.oname;

        sel = fix_selection(oname, sel);
        sel_type = fix_selection_type(oname, sel, sel_type);

        var target = (sel_type == "None" ? myobj.document : sel);
        sel.select();

        target.execCommand("UnLink", false);
        target.execCommand("CreateLink", false, szURL);
    }
    else {
        var sel = document.getElementById("id"+this.oname).contentWindow.getSelection();

        if (typeof sel != "undefined") {
            range = sel.getRangeAt(0);
        }
        else {
            range = document.getElementById("id"+this.oname).document.createRange();
        }

        document.getElementById("id"+this.oname).contentDocument.execCommand("CreateLink", false, szURL);
    }

    if (this.IE) {
        el = sel.parentElement ? sel.parentElement() : get_element(sel.item(0),"A");
    }
    else {
        el = range.startContainer.previousSibling;
    }

    if (el) {
        if (szTarget) el.target = szTarget;
        if (szTitle) el.title = szTitle;
    }
}

function showColor (val, obj)
{
    val.style.backgroundColor = obj.style.backgroundColor;
    val.innerText = obj.style.backgroundColor;
}

function SetForeColor (obj)
{
    for (var i = 0; i < parent.frames.length; i++) {
        if (parent.frames(i).name == window.name) {
            eval("parent.frames." + window.name + "." +
                 forecolor.document.body.document.getElementById("CHEditor").value).exec2("ForeColor",obj.style.backgroundColor);

            return;
        }
    }
    eval("parent." + forecolor.document.body.document.getElementById("CHEditor").value).exec2("ForeColor",obj.style.backgroundColor);
}

function dimension(boxName)
{
    var tblPopup = document.frames(boxName).document.body.document.getElementById("tblPopup");
    document.getElementById(boxName).style.width = tblPopup.offsetWidth;
    document.getElementById(boxName).style.height = tblPopup.offsetHeight;
}

function box_position(boxName)
{
    var tblPopup = document.frames(boxName).document.body.document.getElementById("tblPopup");
    var editarea = eval("editwin" + this.oname);

    myTop = 0;
    stmp = "";

    while (eval("editwin"+ this.oname + stmp).tagName!="BODY") {
        myTop += eval("editwin"+ this.oname + stmp).offsetTop;
        stmp += ".offsetParent";
    }

    myLeft = 0;
    stmp = "";

    while (eval("editwin"+ this.oname + stmp).tagName!="BODY") {
        myLeft += eval("editwin"+ this.oname + stmp).offsetLeft;
        stmp += ".offsetParent";
    }

    if (editarea.offsetHeight-tblPopup.offsetHeight > 0)
        document.getElementById(boxName).style.pixelTop=(myTop + (editarea.offsetHeight-tblPopup.offsetHeight)/2);
    else
        document.getElementById(boxName).style.pixelTop=(myTop + (editarea.offsetHeight-tblPopup.offsetHeight)/2);

    if (editarea.offsetWidth-tblPopup.offsetWidth > 0)
        document.getElementById(boxName).style.pixelLeft=(myLeft + (editarea.offsetWidth-tblPopup.offsetWidth)/2);
    else
        document.getElementById(boxName).style.pixelLeft=myLeft;
}

function displayWindow (boxName)
{
    this.box_hide();
    this.set_selection();

    eval(boxName).document.body.document.getElementById("CHEditor").innerText = this.oname;

    this.dimension(boxName);
    this.box_position(boxName);

    document.getElementById(boxName).style.zIndex = 2;
    document.getElementById(boxName).style.visibility = "";
    document.getElementById(boxName).focus();
}

function windowPos(idImg, boxName)
{
    myTop = 0;
    stmp = "";

    while (eval("idImg" + stmp).tagName!="BODY") {
        stmp += ".offsetParent";
        myTop += eval("idImg" + stmp).offsetTop;
    }

    myTop = myTop + 27;
    myLeft = 0;
    stmp = "";

    while (eval("idImg" + stmp).tagName!="BODY") {
        stmp += ".offsetParent";
        myLeft += eval("idImg" + stmp).offsetLeft;
    }

    myLeft = myLeft + 0;

    document.getElementById(boxName).style.pixelLeft = myLeft;
    document.getElementById(boxName).style.pixelTop = myTop;
}

function box_hide()
{
    document.getElementById("paragraph").style.visibility         = "hidden";
    document.getElementById("fontType").style.visibility          = "hidden";
    document.getElementById("fontSize").style.visibility          = "hidden";
    document.getElementById("backcolor").style.visibility         = "hidden";
    document.getElementById("forecolor").style.visibility         = "hidden";
    document.getElementById("horizontalRule").style.visibility    = "hidden";
    document.getElementById("zoom").style.visibility              = "hidden";
}

function mouse_over(el)
{
    el.style.background = this.selection_color;
    el.style.color = "white";
}

function mouse_out(el)
{
    el.style.background = "";
    el.style.color = "black";
}

function SetBackColor (obj)
{
    for (var i = 0; i < parent.frames.length; i++) {
        if (parent.frames(i).name == window.name) {
            eval("parent.frames."+window.name+"." +
                backcolor.document.body.document.getElementById("CHEditor").value).exec2("BackColor",obj.style.backgroundColor);
            return;
        }
    }
    eval("parent." +
        backcolor.document.body.document.getElementById("CHEditor").value).exec2("BackColor",obj.style.backgroundColor);
}

function SetColorTable (what)
{
    var strCap = '<table cellpadding=0 cellspacing=0 width=100% border=0 bgcolor=#f0f0f0>'+
        '<tr><td align=right bgcolor=#dedfdf>'+
        '<img src='+this.editorPath+'/icons/close.gif width=13 height=13 align=absmiddle '+
        'onClick="parent.box_hide();" />&nbsp;'+
        '</td></tr>' +
        '<table cellpadding=1 cellspacing=5 border=1 bordercolor=#666666 style="cursor: '+
        'pointer;font-family: Verdana; font-size: 7px; BORDER-LEFT: buttonhighlight 0px solid;'+
        'BORDER-RIGHT: buttonshadow 2px solid; BORDER-TOP: buttonhighlight 0px solid;'+
        'BORDER-BOTTOM: buttonshadow 0px solid;" bgcolor=#f0f0f0>'+
        '<tr><td colspan="10" id=color style="height=20px;font-family: verdana; font-size:12px; text-align:center">&nbsp;'+
        '</td></tr>';

    var colorRows = [strCap];
    var k = 0;
    var w = 14;
    var h = 10;
    var cmd = (what == 'back') ? 'SetBackColor(color)' : 'SetForeColor(color)';

    for (var i = 0; i < w; i++) {
        colorRows[colorRows.length] = "<tr>";
        for (var j = 0; j < h; j++) {
            colorRows[colorRows.length] = '<td onMouseOver="parent.showColor(color,this)" '+
                'onClick="parent.'+cmd+'" style="background-color:'+colorTable[k]+';"width=12px">&nbsp;</td>';
            k++;
        }
        colorRows[colorRows.length] = "</tr>";
    }

    colorRows[colorRows.length] =
        '<tr><td colspan="10" style="height=15px;font-size:9pt; text-align:center" '+
        'onMouseOver="parent.showColor(color,this)" onClick="parent.'+cmd+'">¾øÀ½</td></tr>'+
        '</table>';

    return colorRows.join("\n");
}

function createWindow(width, content)
{
    var htmlOutput = "" +
        "<style>" +
        "body {border:lightgrey 0px solid;background: #fff; font-family:"+this.fontface+"}" +
        ".dropdown {cursor:pointer}" +
        "</style>" +
        "<body topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0 onselectstart=\"return event.srcElement.tagName=='INPUT'\" oncontextmenu='return false'>" +
        "<table border=0 cellpadding=1 cellspacing=0 style='table-layout:fixed;border-right:#c3c3c3 1 solid;border-bottom:#c3c3c3 1 solid;border-left:#aeaeae 1 solid;border-top:#aeaeae 1 solid;' ID=tblPopup>" +
        "<col width="+width+">" +
        "<tr>" +
        "<td>" +
        content +
        "</td>" +
        "</tr>" +
        "</table>" +
        "<input type=text style='display:none;' id='CHEditor' name='CHEditor' contentEditable=true>" +
        "</body>";
    return htmlOutput;
}

function applyParagraph(val)
{
    for (var i = 0; i < parent.frames.length; i++) {
        if (parent.frames(i).name == window.name) {
            eval("parent.frames."+window.name+"." +
                paragraph.document.body.document.getElementById("CHEditor").value).exec2("FormatBlock",val);
            return;
        }
    }
    eval("parent." + paragraph.document.body.document.getElementById("CHEditor").value).exec2("FormatBlock",val);
}

function changeFontType(val)
{
    for (var i = 0; i < parent.frames.length; i++) {
        if (parent.frames(i).name == window.name) {
            eval("parent.frames."+window.name+"." +
                fontType.document.body.document.getElementById("CHEditor").value).exec2("fontName",val);
            return;
        }
    }

    eval("parent." + fontType.document.body.document.getElementById("CHEditor").value).exec2("fontName",val);
}

function changeSize(val)
{
    for (var i = 0; i < parent.frames.length; i++) {
        if (parent.frames(i).name == window.name) {
            eval("parent.frames."+window.name+"." +
                fontSize.document.body.document.getElementById("CHEditor").value).exec2("fontsize",val);
            return;
        }
    }

    eval("parent." + fontSize.document.body.document.getElementById("CHEditor").value).exec2("fontsize",val);
}

function setDisplayMode()
{
    this.box_hide();
    this.set_selection();

    var oname = chutil.oname;
    var editor = eval("id"+this.oname);

    if (this.Preview) {
        if (document.getElementById("chkPreviewMode").checked) {
            document.getElementById("chkPreviewMode").checked = false;
            this.displayMode = 'RICH';
        }
    }

    if (this.displayMode=='RICH') {
        this.hideStatus()
        var tmp = this.get_content();
        var key = this.htmlKey.join ("|");
        var reg = new RegExp ("(&lt;\/?)(" + key + ")(&gt;)", "ig");
        var reg2 = new RegExp ("(&lt;)(" + key + ") (.+?)(&gt;)", "ig");

        editor.document.body.innerText = tmp;
        var content = editor.document.body.innerHTML;
        content = content.replace (/&lt;META(.+?)&gt;/ig, "&lt;meta content=\"cheditor 3.1\" name=generator&gt;");
        content = content.replace (/(&lt;\/?)P(&gt;)/ig, "$1DIV$2");
        content = content.replace (/&lt;link href=(.*?)&gt;/ig, '');
        content = content.replace (/(&lt;)P(&gt;)/ig, '');
        content = content.replace (reg, "<font color=#0000ff>$1$2$3</font>");
        content = content.replace (reg2, "<font color=#0000ff>$1$2</font> $3<font color=#0000ff>$4</font>");

        editor.document.body.innerHTML = content;
        editor.document.body.clearAttributes;
        editor.document.body.style.fontFamily = 'Courier New';
        editor.document.body.style.fontSize = '9pt';
        editor.document.body.style.color = '#000';
        editor.document.body.style.background = '#fff';
        editor.document.body.contentEditable = true;
        editor.document.body.focus();

        this.displayMode = 'HTML';
        eval("idToolbar"+this.oname).style.display = "none";
    }
    else {
        this.put_content(editor.document.body.innerText);
        this.displayMode = 'RICH';
        eval("idToolbar"+this.oname).style.display = "block";
        this.default_css(editor);

        editor.document.body.focus();
        var myobj = this.oname;
        this._add_event(editor.document,
                    function (event) {
                        return SetEditorEvent(this.IE ? editor.document.contentWindow.event : event, myobj);
                    });
    }
}

function plainMode()
{
    if (this.displayMode != 'PLAIN' &&
        !confirm("ÀÏ¹Ý ÅØ½ºÆ®·Î ÀüÈ¯ÇÏ½Ã¸é HTML Á¤º¸¸¦ ÀÒ¾î ¹ö¸®°Ô µË´Ï´Ù.\nº¯È¯ÇÏ½Ã°Ú½À´Ï±î?"))
    {
        document.getElementById("chkPlainMode").checked = 0;
        return;
    }

    this.box_hide();
    this.set_selection();

    var editor = eval("id"+this.oname);
    this.hideStatus();

    if (this.displayMode != 'PLAIN') {
        var content = editor.document.body.innerText;

        if (document.getElementById("chkDisplayMode").checked) {
            this.put_content(content);
            content = editor.document.body.innerText;
        }

        content = content.replace (/\r\n\r/g, "");
        content = content.replace (/\n/g, "<br>");

        document.getElementById("chkPreviewMode").checked = 0;
        document.getElementById("chkDisplayMode").checked = 0;
        document.getElementById("chkPreviewMode").disabled = 1;
        document.getElementById("chkDisplayMode").disabled = 1;

        this.put_content(content);

        document.getElementById("idToolbar"+this.oname).style.display = "none";

        this.default_css(editor);

        editor.document.body.clearAttributes;
        editor.document.body.style.fontSize = '9pt';
        editor.document.body.style.fontFamily = this.fontface;
        editor.document.body.contentEditable = true;
        if (this.lineheight != 0) editor.document.body.style.lineHeight = this.lineheight;
        this.displayMode = 'PLAIN';
        var myobj = this.oname;
        this._add_event(editor.document,
                    function (event) {
                        return SetEditorEvent(this.IE ? editor.document.contentWindow.event : event, myobj);
                    });
    }
    else {
        document.getElementById("chkPreviewMode").disabled = 0;
        document.getElementById("chkDisplayMode").disabled = 0;
        var content = editor.document.body.innerHTML;
        editor.document.body.innerHTML = content;
        document.getElementById("idToolbar"+this.oname).style.display = "block";
        this.default_css(editor);

        this.displayMode = 'RICH';
    }

    editor.document.body.focus();
}

function ContentLength()
{
    var content = this.outputBodyText();

    content = content.replace (/^\s+/g, '');
    content = content.replace (/\s+$/g, '');
    content = content.replace (/\r\n/g, '');
    content = content.replace (/<\/?div>/ig, '');
    content = content.replace (/<\/?p>/ig, '');
    content = content.replace (/<br>/ig, '');
    content = content.replace (/&nbsp;/g, '');

    return content.length;
}

function default_css(editor)
{
    var el = editor.document.createElement("<link rel='stylesheet' type='text/css' href='"+this.editorPath+"/default.css'>");
    editor.document.childNodes[0].childNodes[0].appendChild(el);
}

function previewMode()
{
    this.box_hide();
    this.set_selection();

    var editor = eval("id"+this.oname);

    if (this.ViewHTML) {
        if (document.getElementById("chkDisplayMode").checked) {
            this.put_content(editor.document.body.innerText);
            this.displayMode = 'RICH';
            this.default_css(editor);

            eval("idToolbar"+this.oname).style.display = "block";
            editor.document.body.focus();
            document.getElementById("chkDisplayMode").checked = false;
        }
    }

    if (this.displayMode=='RICH') {
        this.hideStatus();
        var content = editor.document.body.innerHTML;
        editor.document.body.innerHTML = content;
        editor.document.body.contentEditable = false;
        editor.document.body.focus();
        this.displayMode = 'HTML';
        document.getElementById("idToolbar"+this.oname).style.display = "none";
    }
    else {
        var tmp = this.get_content();
        editor.document.body.innerText = tmp;
        this.put_content(editor.document.body.innerText);
        this.displayMode = 'RICH';
        document.getElementById("idToolbar"+this.oname).style.display = "block";
        editor.document.body.focus();
        var myobj = this.oname;
        this._add_event(editor.document,
                    function (event) {
                        return SetEditorEvent(this.IE ? editor.document.contentWindow.event : event, myobj);
                    });
    }
}

function returnFalse()
{
    var editor = eval("id"+this.oname);
    var tmp = this.get_content();

    editor.document.body.innerText = tmp;
    this.put_content(editor.document.body.innerText);
    this.displayMode = 'RICH';
    document.getElementById("idToolbar"+this.oname).style.display = "block";
    editor.document.body.focus();

    return false;
}

function get_content()
{
    var myobj = eval("id"+this.oname);

    if (this.hrefTarget) {
        for (var i=0; i < myobj.document.links.length; i++) {
            if (!myobj.document.links[i].target) {
                myobj.document.links[i].target = this.hrefTarget;
            }
        }
    }

    myobj.document.body.style.border = "";
    myobj.document.body.removeAttribute("contentEditable", 0);

    var el = this.BodyOnly ? myobj.document.body : myobj.document.documentElement;
    var mydoc = this.IE ? el.outerHTML : el.innerHTML;

    mydoc = mydoc.replace("BORDER-RIGHT: medium none; ", "");
    mydoc = mydoc.replace("BORDER-TOP: medium none; ", "");
    mydoc = mydoc.replace("BORDER-BOTTOM: medium none; ", "");
    mydoc = mydoc.replace("BORDER-LEFT: medium none; ", "");
    mydoc = mydoc.replace("BORDER-RIGHT: medium none", "");
    mydoc = mydoc.replace("BORDER-TOP: medium none", "");
    mydoc = mydoc.replace("BORDER-BOTTOM: medium none", "");
    mydoc = mydoc.replace("BORDER-LEFT: medium none", "");
    mydoc = mydoc.replace(" style=\"\"", "");

    if (this.BodyOnly) {
        mydoc = mydoc.replace("\r\n", "");
        mydoc = mydoc.replace(/<\/?BODY(.*?)>/ig, "");
    }


    return mydoc;
}

function outputBodyHTML()
{
    var str = this.outputHTML();
    var spl = this.IE ? "BODY" : "body";
    str = str.substr(str.indexOf("<"+spl) + 1);
    str = str.substr(str.indexOf(">") + 1);
    var tmp = str.split("</"+spl+">");
    str = tmp[0];
    return str;
}

function outputBodyText()
{
    var editor = eval("id"+this.oname);

    if (this.IE) {
        return editor.document.body.innerText;
    }

    var str = this.outputBodyHTML();
    var parsedText = document.createTextNode(str);

    return parsedText.nodeValue;
}

function outputHTML()
{
    var chkViewHtml = document.getElementById("chkDisplayMode");
    var editor = eval("id"+this.oname);

    if (chkViewHtml != null && chkViewHtml.checked) {
        this.put_content(editor.document.body.innerText);
    }

    var mydoc = this.get_content();
    mydoc = mydoc.replace (/<link href=(.*?)>/ig, '');
    mydoc = mydoc.replace (/(<\/?)P>/ig, "$1DIV>");
    editor.document.body.contentEditable = true;

    return mydoc;
}

function put_content(sContent)
{
    var editor = eval("id"+this.oname);
    var editorTmp = eval("idtmp"+this.oname);

    var doc = editorTmp.document.open("text/html", "replace");
    doc.write(sContent);
    doc.close();

    doc = editor.document.open("text/html", "replace");
    doc.write(editorTmp.document.documentElement.outerHTML);
    doc.close();

    editor.document.body.style.border = "";
    editor.document.body.contentEditable = true;

    editor.document.execCommand("2D-Position", true, true);
    editor.document.execCommand("MultipleSelection", true, true);
    editor.document.execCommand("LiveResize", true, true);
}

function insert (what)
{
    var myobj = eval("id" + this.oname);
    var tmpl;
    var w;
    var h;
    var scroll = 0;

    myobj.focus();
    chutil.oname = this.oname;

    if (this.IE) this.set_selection();

    switch (what) {
    case "forecolor" :
        tmpl = "gecko_forecolor.html";
        h = 240;
        w = 250;
        break;
    case "hilitecolor" :
        tmpl = "gecko_hilitecolor.html";
        h = 240;
        w = 250;
        break;
    case"backcolor" :
        tmpl = "gecko_backcolor.html";
        h = 240;
        w = 250;
        break;
    case "image" :
        tmpl = "insert_image.asp?filepath="+this.uploadPath;
        h = this.IE ? 615 : 650;
        w = 430;
        break;
    case "media" :
        tmpl = "insert_media.html";
        h = 480;
        w = 430;
        scroll = 1;
        break;
    case "bgimage" :
        tmpl = "insert_bgimage.html";
        h = this.IE ? 220 : 240;
        w = 430;
        break;
    case "table" :
        tmpl = "insert_table.html";
        h = this.IE ? 480 : 500;
        w = 430;
        break;
    case "hlink" :
        tmpl = "insert_hlink.html";
        h = this.IE ? 175 : 180;
        w = this.IE ? 450 : 500;
        break;
    case "em" :
        tmpl = "insert_emicon.html";
        h = this.IE ? 235 : 250;
        w = 400;
        break;
    default:
        return;
    }

    tmpl = this.editorPath + '/' + tmpl;

    var left = (screen.width-w)/2;
    var top = (screen.height-h)/2;

    window.open(tmpl, "new_window",
                "toolbar=no,menubar=no,personalbar=no,height="+h+",width="+w+"," +
                "left="+left+",top="+top+",scroolbars=yes,resizable=no");
}

function insertIE (what)
{
    var myobj = eval("id" + this.oname);
    var tmpl;

    myobj.focus();
    this.set_selection();

    switch(what) {
    case "schar":
        tmpl = "insert_schar.html";
        attr = "dialogHeight: 260px; dialogWidth: 600px; help:no; status:no";
        break;
    }

    tmpl = this.editorPath + '/' + tmpl;

    var el = showModalDialog(tmpl, this, attr);

    if (el) {
        var selection = myobj.document.selection.createRange();
        selection.parentElement ? selection.pasteHTML(el) : selection.item(0).outerHTML = el;
    }
}


function SetGeckoColor(cmd, colour)
{
    document.getElementById("id"+myobj).contentWindow.document.execCommand(cmd, false, colour);
}

function insertTable(insertNode)
{
    if (this.IE) {
        var editor = eval("id"+this.oname);
        var sel = editor.document.selection.createRange();
        sel.pasteHTML(insertNode.outerHTML);
    }
    else {
        var sel = document.getElementById("id"+this.oname).contentWindow.getSelection();
        var range = sel.getRangeAt(0);

        sel.removeAllRanges();
        range.deleteContents();

        var container = range.startContainer;
        var pos = range.startOffset;

        range = document.createRange();

        if (container.nodeType==3 && insertNode.nodeType==3) {
            container.insertData(pos, insertNode.nodeValue);

            range.setEnd(container, pos+insertNode.length);
            range.setStart(container, pos+insertNode.length);
        }
        else {
            var afterNode;
            if (container.nodeType==3) {
                var textNode = container;
                container = textNode.parentNode;
                var text = textNode.nodeValue;
                var textBefore = text.substr(0,pos);
                var textAfter = text.substr(pos);
                var beforeNode = document.createTextNode(textBefore);
                var afterNode = document.createTextNode(textAfter);

                container.insertBefore(afterNode, textNode);
                container.insertBefore(insertNode, afterNode);
                container.insertBefore(beforeNode, insertNode);
                container.removeChild(textNode);
            }
            else {
                afterNode = container.childNodes[pos];
                container.insertBefore(insertNode, afterNode);
            }

            range.setEnd(afterNode, 0);
            range.setStart(afterNode, 0);
        }
        sel.addRange(range);
    }
}

function insertImage (img)
{
    var myobj = eval("id" + this.oname);

    if (this.IE) {
        var sel = this.selection;
        var sel_type = this.selection_type;
        var oname = this.oname;

        sel = fix_selection(oname, sel);
        sel_type = fix_selection_type(oname, sel, sel_type);

        var target = (sel_type == "None" ? myobj.document : sel);
        sel.select();

        target.execCommand("InsertImage", false, img.src);
    }
    else {
        var sel = document.getElementById("id"+this.oname).contentWindow.getSelection();

        if (typeof sel != "undefined") {
            range = sel.getRangeAt(0);
        }
        else {
            range = document.getElementById("id"+this.oname).document.createRange();
        }
        document.getElementById("id"+this.oname).contentDocument.execCommand("InsertImage", false, img.src);
    }

    var tmpImg = null;

    if (this.IE) {
        tmpImg = sel.parentElement();
        if (tmpImg.tagName.toLowerCase() != "img") {
            tmpImg = tmpImg.previousSibling;
        }
    }
    else {
        tmpImg = range.startContainer.previousSibling;
    }

    if (img.border) tmpImg.border = parseInt(img.border);
    if (img.hspace) tmpImg.hspace = parseInt(img.hspace);
    if (img.vspace) tmpImg.vspace = parseInt(img.vspace);
    if (img.width)  tmpImg.width  = parseInt(img.width);
    if (img.height) tmpImg.height = parseInt(img.height);
    if (img.alt)    tmpImg.alt    = img.alt;
    if (img.align)  tmpImg.align  = img.align;
	if (img.id)  tmpImg.id  = img.id;

    this.setImages.push(img.src.toLowerCase());
}

function getImages()
{
    var x = eval("id"+this.oname).document.body.getElementsByTagName('img');
    var rdata = new Array;

    for (var i=0; i < this.setImages.length; i++) {
        for (var j=0; j < x.length; j++) {
            if (x[j].src != undefined && x[j].src.toLowerCase() == this.setImages[i]) {
                var tmpImg = x[j].src;
                tmpImg = tmpImg.replace(/.*\/([^\/]+)$/g, "$1");
                //rdata.push(tmpImg + " " + x[j].width + " " + x[j].height);
				rdata.push(tmpImg);
                //rdata.push(tmpImg);
            }
        }
    }

    return(rdata.join(","));
}

function insertEl (c)
{
    var editor = eval("id"+this.oname);
    var sel = editor.document.selection.createRange();
    sel.pasteHTML(c);
}

function insertBgImage (img)
{
    var editor = eval("id"+this.oname);

    if (img) {
        img = this.editorPath + '/' + img;
        editor.document.body.style.backgroundImage = "url("+img+")";
    }
    else {
        var s = editor.document.body.style;
        this.IE ? s.removeAttribute("backgroundImage") : s.backgroundImage = "none";
    }
}

function setBackgroundColor()
{
    var editor = eval("id"+this.oname);
    var color  = editor.document.body.style.backgroundColor;
    var tmpl = this.editorPath + "/insert_colorpicker.html";
    chutil.oname = this.oname;
    
    if (!color)
        editor.document.body.bgcolor;

    var arr = showModalDialog (
        tmpl,
        {
            change  : changeBackgroundColor,
            color   : color,
            editor  : editor
        },
        "dialogWidth:470px; dialogHeight:360px; center:yes; help:no; status:no;"
    );

    editor.focus();
}

function changeBackgroundColor (s, editor) {
    editor.document.body.style.backgroundColor = s;
}

function insertHR (width, size, color, opt)
{
    var w = width ? width : "100%";
    var s = size    ? size  : 1;
    var c = color ? color : 0;

    var hr = "<hr width="+w+" size="+s;

    if (c)      hr += " color="+c;
    if (opt)    hr += " noshade";

    hr += ">";

    for (var i = 0; i < parent.frames.length; i++) {
        if (parent.frames(i).name == window.name) {
            eval("parent.frames."+window.name+"." +
                horizontalRule.document.body.getElementById("CHEditor").value).exec3(hr);
            return;
        }
    }
    eval("parent." + horizontalRule.document.body.document.getElementById("CHEditor").value).exec3(hr);
}

function viewZoom(val)
{
    for (var i=0; i < parent.frames.length; i++) {
        if (parent.frames(i).name == window.name) {
            eval("parent.frames."+window.name+"." +
                zoom.document.body.document.getElementById("CHEditor").value).box_hide();
            var editor = eval("id"+zoom.document.body.document.getElementById("CHEditor").value);
            editor.document.body.style.zoom = val;
            return;
        }
    }

    eval("parent." + zoom.document.body.document.getElementById("CHEditor").value).box_hide();
    var editor = eval("id"+zoom.document.body.document.getElementById("CHEditor").value);
    editor.document.body.style.zoom = val;
}

function get_element(elm, tag)
{
    while (elm != null && elm.tagName != tag) {
        if (elm.id == "id"+this.oname)
            return null;

        elm = elm.parentElement;
    }
    return elm;
}

function get_element_node(elm, tag)
{
    while (elm != null && elm.tagName != tag) {
        if (elm.id == "id"+this.oname)
            return null;

        elm = elm.parentNode;
    }
    return elm;
}

function run ()
{
    myobj        = this.oname;
    obj          = eval(myobj);
    editorPath   = this.editorPath;

    document.write("<table width='"+this.width+"' height='"+this.height+"' border=0 cellpadding=0 cellspacing=0><tr><td>");

    // ¸Þ´º ¹öÆ° Ãâ·Â: ½ÃÀÛ *****/
    document.write("<table cellpadding=0 cellspacing=0 width=100% id='idToolbar"+myobj+"'style=\""+this.editorToolbar+"\">");
    document.write("<tr><td><table cellpadding=0 cellspacing=0><tr><td>");
    document.write("<table id='toolbar1' cellpadding=1 cellspacing=1>");
    document.write("<tr>");
    //document.write("<td title='±×¸² ³Ö±â'>" + obj.setIcon("image.gif", 26, 26, myobj + ".insert('image')") + "</td>");
    document.write("<td title='½ÇÇà Ãë¼Ò'>" + obj.setIcon("undo.gif", 26, 26, myobj + ".exec('Undo',false)") + "</td>");
    document.write("<td title='µÇ»ì¸®±â'>" + obj.setIcon("redo.gif", 26, 26, myobj + ".exec('Redo',false)") + "</td>");
    document.write("<td title='ÀÚ¸£±â'>" + obj.setIcon("cut.gif", 26, 26, myobj + ".exec('Cut',false)") + "</td>");
    document.write("<td title='º¹»ç'>" + obj.setIcon("copy.gif", 26, 26, myobj + ".exec('Copy',false)") + "</td>");
    document.write("<td title='ºÙÀÌ±â'>" + obj.setIcon("paste.gif", 26, 26, myobj + ".exec('Paste',false)") + "</td>");
    //document.write("<td title='ÀüÃ¼ ¼±ÅÃ'>" + obj.setIcon("selectall.gif", 26, 26, myobj + ".exec('SelectAll',false)") + "</td>");
    document.write("<td title='ÁøÇÏ°Ô'>" + obj.setIcon("bold.gif", 26, 26, myobj + ".exec('Bold',false)") + "</td>");
    document.write("<td title='±â¿ïÀÓ'>" + obj.setIcon("italic.gif", 26, 26, myobj + ".exec('Italic',false)") + "</td>");
    document.write("<td title='¹ØÁÙ'>" + obj.setIcon("underline.gif", 26, 26, myobj + ".exec('Underline',false)") + "</td>");
    document.write("<td>" + obj.setIcon("strike.gif", 26, 26, myobj + ".exec('Strikethrough',false)") + "</td>");
    document.write("<td title='À§ Ã·ÀÚ'>" + obj.setIcon("superscript.gif", 26, 26, myobj + ".exec('Superscript',false)") + "</td>");
    document.write("<td title='¾Æ·¡ Ã·ÀÚ'>" + obj.setIcon("subscript.gif", 26, 26, myobj + ".exec('Subscript',false)") + "</td>");
    document.write("<td title='¿ÞÂÊ Á¤·Ä'>" + obj.setIcon("justifyleft.gif", 26, 26, myobj + ".exec('JustifyLeft',false)") + "</td>");
    document.write("<td title='°¡¿îµ¥ Á¤·Ä'>" + obj.setIcon("justifycenter.gif", 26, 26, myobj + ".exec('JustifyCenter',false)") + "</td>");
    document.write("<td title='¿À¸¥ÂÊ Á¤·Ä'>" + obj.setIcon("justifyright.gif", 26, 26, myobj + ".exec('JustifyRight',false)") + "</td>");
    document.write("<td title='¾çÂÊ Á¤·Ä'>" + obj.setIcon("justifyfull.gif", 26, 26, myobj + ".exec('JustifyFull',false)") + "</td>");
    document.write("<td title='¹®´Ü ¹øÈ£'>" + obj.setIcon("orderedlist.gif", 26, 26, myobj + ".exec('InsertOrderedList',false)") + "</td>");
    document.write("<td title='±Û ¸Ó¸®Ç¥'>" + obj.setIcon("unorderedlist.gif", 26, 26, myobj + ".exec('InsertUnorderedList',false)") + "</td>");
    document.write("<td title='¿ÞÂÊ ¿©¹é ÁÙÀÌ±â'>" + obj.setIcon("outdent.gif", 26, 26, myobj + ".exec('Outdent',false)") + "</td>");
    document.write("<td title='¿ÞÂÊ ¿©¹é ´Ã¸®±â'>" + obj.setIcon("indent.gif", 26, 26, myobj + ".exec('Indent',false)") + "</td>");
    document.write("</tr></table></td></tr>");
    document.write("<tr><td>");
    document.write("<table id='toolbar1' cellpadding=1 cellspacing=1>");
    document.write("<tr>");
    document.write("<td title='ÇÏÀÌÆÛ¸µÅ©'>" + obj.setIcon("link.gif", 26, 26, myobj + ".insert('hlink')") + "</td>");
    document.write("<td title='ÇÏÀÌÆÛ¸µÅ© ÇØÁ¦'>" + obj.setIcon("unlink.gif", 26, 26, myobj + ".exec('UnLink',false)") + "</td>");
    document.write("<td title='¹Ìµð¾î'>" + obj.setIcon("media.gif", 26, 26, myobj + ".insert('media')") + "</td>");
    document.write("<td title='ÀÎ¼â'>" + obj.setIcon("print.gif", 26, 26, myobj + ".exec('Print',false)") + "</td>");
    document.write("<td title='¹ÙÅÁ ±×¸²'>" + obj.setIcon("bgimage.gif", 26, 26, myobj + ".insert('bgimage')") + "</td>");
    document.write("<td title='Ç¥Á¤ ¾ÆÀÌÄÜ'>" + obj.setIcon("em.gif", 26, 26, myobj + ".insert('em')") + "</td>");

    if (this.IE) {
        document.write("<td title='Æ¯¼ö ¹®ÀÚ'>" + obj.setIcon("schar.gif", 27, 27, myobj + ".insertIE('schar')") + "</td>");
        //document.write("<td title='º»¹® È®´ë'>" + obj.setIcon("zoom.gif", 70, 26, myobj + ".displayWindow('zoom');windowPos(this,'zoom')",false) + "</td>");
        document.write("<td title='°¡·Î¼±'>" + obj.setIcon("hr.gif", 27, 27, myobj + ".displayWindow('horizontalRule');windowPos(this,'horizontalRule')",false) + "</td>");
        document.write("<td title='¹ÙÅÁ»ö'>" + obj.setIcon("bgcolor.gif", 27, 27, myobj + ".setBackgroundColor()") + "</div></td>");
        document.write("<td title='±ÛÀÚ»ö'>" + obj.setIcon("forecolor.gif", 27, 27, myobj + ".displayWindow('forecolor');windowPos(this,'forecolor')",false) + "</td>");
        document.write("<td title='Çü±¤Ææ'>" + obj.setIcon("backcolor.gif", 27, 27, myobj + ".displayWindow('backcolor');windowPos(this,'backcolor')",false) + "</td>");
        document.write("<td title='ÆÄ¶ó±×·¡ÇÁ'>" + obj.setIcon("paragraph.gif", 58, 27, myobj + ".displayWindow('paragraph');windowPos(this,'paragraph')",false) + "</td>");
        document.write("<td title='±Û²Ã'>" + obj.setIcon("fonttype.gif", 58, 26, myobj + ".displayWindow('fontType');windowPos(this,'fontType')",false) + "</td>");
        document.write("<td title='±ÛÀÚ Å©±â'>" + obj.setIcon("fontsize.gif", 58, 26, myobj + ".displayWindow('fontSize');windowPos(this,'fontSize')",false) + "</td>");
    }
    else {
        document.write("<td title='°¡·Î¼±'>" + obj.setIcon("hr.gif", 27, 27, myobj + ".exec('InsertHorizontalRule',false)") + "</td>");
        document.write("<td title='¹ÙÅÁ»ö'>" + obj.setIcon("bgcolor.gif", 27, 27, myobj + ".insert('backcolor')") + "</td>");
        document.write("<td title='±ÛÀÚ»ö'>" + obj.setIcon("forecolor.gif", 27, 27, myobj + ".insert('forecolor')") + "</td>");
        document.write("<td title='Çü±¤Ææ'>" + obj.setIcon("backcolor.gif", 27, 27, myobj + ".insert('hilitecolor')") + "</td>");

        document.write("<td title='ÆÄ¶ó±×·¡ÇÁ'><select style='font-size:9pt' id='formatblock' onchange='"+myobj+".exec(\"FormatBlock\", this.options[selectedIndex].value)'>" +
                     "<option value='<p>'>º¸Åë</option>" +
                     "<option value='<h1>'>Á¦¸ñ 1</option>" +
                     "<option value='<h2>'>Á¦¸ñ 2</option>" +
                     "<option value='<h3>'>Á¦¸ñ 3</option>" +
                     "<option value='<h4>'>Á¦¸ñ 4</option>" +
                     "<option value='<h5>'>Á¦¸ñ 5</option>" +
                     "<option value='<h6>'>Á¦¸ñ 6</option>" +
                     "<option value='<address>'>ÁÖ¼Ò</option>" +
                     "<option value='<pre>'>Çü½Ä</option>" +
                    "</select></td>");

        document.write("<td title='±Û²Ã'><select style='font-size:9pt' id='fontname' onchange='"+myobj+".exec(\"fontname\", this.options[selectedIndex].value)'>" +
                     "<option value='±¼¸²'>±¼¸²</option>" +
                     "<option value='¹ÙÅÁ'>¹ÙÅÁ</option>" +
                     "<option value='µ¸¿ò'>µ¸¿ò</option>" +
                     "<option value='±Ã¼­'>±Ã¼­</option>" +
                     "<option value='Arial'>Arial</option>" +
                     "<option value='Arial Black'>Arial Black</option>" +
                     "<option value='Courier'>Courier</option>" +
                     "<option value='Times New Roman'>Times New Roman</option>" +
                     "<option value='Verdana'>Verdana</option>" +
                    "</select></td>");

        document.write("<td title='±ÛÀÚ Å©±â'><select style='font-size:9pt' id='fontsize' onchange='"+myobj+".exec(\"fontsize\", this.options[selectedIndex].value)'>" +
                     "<option value='1'>Å©±â 1</option>" +
                     "<option value='2'>Å©±â 2</option>" +
                     "<option value='3'>Å©±â 3</option>" +
                     "<option value='4'>Å©±â 4</option>" +
                     "<option value='5'>Å©±â 5</option>" +
                     "<option value='6'>Å©±â 6</option>" +
                    "</select></td>");
    }

    document.write("<td title='Å×ÀÌºí ¸¸µé±â'>" + obj.setIcon("table.gif", 30, 26, myobj + ".insert('table')") + "</td>");
	document.write("<td title='ÀüÃ¼ ¼±ÅÃ'>" + obj.setIcon("selectall.gif", 28, 26, myobj + ".exec('SelectAll',false)") + "</td>");
    document.write("</tr></table></td></tr></table></td></tr></table></td></tr><tr><td height='100%'>");
    // ¸Þ´º ¹öÆ° Ãâ·Â: ³¡ *****/

    document.write("<table name='editwin"+myobj+"' id='editwin"+myobj+"' cellpadding=0 cellspacing=0 width=100% height=100%>");
    document.write("<tr><td>");
    document.write("<iframe style='width:100%;height:100%;overflow:auto; border:" +
                 this.editorBorder+"' NAME='id"+myobj+"' ID='id"+myobj+"' onfocus=\""+myobj+".box_hide()\"></iframe>");

    document.write("</td></tr></table>");
    document.write("</td></tr><tr><td><span id=CHstatusBar"+myobj+"></span></td></tr>");

    if (this.IE) {
        document.write("</td></tr><tr><td>");
        if (this.ViewHTML)
            document.write("<input type=checkbox onclick='"+myobj+".setDisplayMode()' id=chkDisplayMode name=chkDisplayMode><font style='font-size:9pt;'> HTML &nbsp;</font>");
        if (this.Preview)
            document.write("<input type=checkbox onclick='"+myobj+".previewMode()' id=chkPreviewMode name=chkPreviewMode><font style='font-size:9pt;'> ¹Ì¸®º¸±â &nbsp;</font>");
        if (this.PlainMode)
            document.write("<input type=checkbox onclick='"+myobj+".plainMode()' id=chkPlainMode name=chkPlainMode><font style='font-size:9pt;'> ÀÏ¹ÝÅØ½ºÆ® &nbsp;</font>");
    }

    document.write("</td></tr>");
//	document.write("<tr><td align='right'>"+obj.setIcon("image.gif", 26, 26, myobj + ".insert('image')")+"&nbsp;ÀÌ¹ÌÁö ³Ö±â</td></tr>");
	document.write("</table>");


    editor = eval("id" + myobj);

    if (!this.IE)
        document.getElementById("id"+myobj).contentWindow.document.designMode = "on";

    editor.document.open("text/html", "replace");
    editor.document.write("<html><head></head>");
    if (this.pasteContent) {
        var theForm = this.formName;
        var formValue = this.unescape_html(eval("document."+theForm+"."+this.pasteContentForm+".value"));
        editor.document.write("<body style='margin:5;background-color:"+this.editorBgcolor+"'>"+formValue+"</body></html>");
    }
    else {
        editor.document.write("<body style='margin:5;background-color:"+this.editorBgcolor+"'></body></html>");
    }
    editor.document.close();

    editor.document.body.style.fontSize   = this.fontsize;
    editor.document.body.style.fontFamily = this.fontface;
    if (this.lineheight != 0) editor.document.body.style.lineHeight = this.lineheight;

    if (this.IE) {
        this.default_css(editor);
        editor.document.execCommand("2D-Position", true, true);
        editor.document.execCommand("MultipleSelection", true, true);
        editor.document.execCommand("LiveResize", true, true);
        editor.document.body.style.border = '1px';
        editor.document.body.contentEditable = true;

        document.write("<iframe name='idtmp"+myobj+"' contentEditable=true id='idtmp"+myobj+"' style='width:0;height:0;overflow:auto;' noborder onfocus='"+myobj+".box_hide()'></iframe>");
        var tmpeditor = eval("idtmp"+myobj);
        tmpeditor.document.designMode = "on";
        tmpeditor.document.open("text/html","replace");
        tmpeditor.document.write("<html><head></head><body><div></div></body></html>");
        tmpeditor.document.close();

        if (!document.getElementById("horizontalRule")) {
            htmlOutput = "<style>" + ".inputbox {font-size:9pt;}" + "</style>" +
                    '<table cellpadding="0" cellspacing="0" width="100%" border="0" bgcolor="#f0f0f0">' +
                            "<tr><td align=right bgcolor=#dedfdf><img src="+this.editorPath+"/icons/close.gif width=13 height=13 align=absmiddle onClick='parent.box_hide();' />&nbsp;</td></tr>" +
                            "<tr><td align=center><div style='margin:5px;'><fieldset><legend><font style=font-size:9pt>°¡·Î¼± ³Ö±â</font></legend>" +
                            "<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td><div style='margin-left:5px'><font style=font-size:9pt>¼± ±æÀÌ : <input type=text size=5 class=inputbox name=hr_width id=hr_width value=100%> %°¡ ¾øÀ¸¸é ÇÈ¼¿</font></div></td></tr>" +
                            "<tr><td><div style='margin-left:5px'><font style=font-size:9pt>¼± ±½±â : <input type=text size=5 class=inputbox name=hr_size id=hr_size value=2> ÇÈ¼¿</font></div></td></tr>" +
                            "<tr><td><div style='margin-left:5px'><font style=font-size:9pt>¼± »ö»ó : <input type=text size=5 class=inputbox name=hr_color id=hr_color value=> #000000 ¶Ç´Â black</font></div></td></tr>" +
                            "<tr><td><div style='margin-left:5px'><font style=font-size:9pt>¼± ¸ð¾ç : <input type=checkbox name=hr_shade id=hr_shade value=1> Æò¸é</font></div></td></tr>" +
                            "<tr><td height=10></td></tr></table></fieldset></div></td></tr>" +
                            "<tr><td align=center><font style=font-size:9pt><input type=button style='font-size:9pt;width:6em;height:24px;padding-top:3px;' value='È®ÀÎ' onClick=\"parent.insertHR(hr_width.value,hr_size.value,hr_color.value,hr_shade.checked ? 1 : 0)\"></font>\n</td></tr>" +
                "<tr><td height=3></td></tr>" +
                "</table>";

            htmlOutput = createWindow(270, htmlOutput);
            document.write("<iframe id=horizontalRule name=horizontalRule style='position: absolute; visibility: hidden; z-index: 1;width:1;height:1;'></iframe>");

            horizontalRule.document.open("text/html", "replace");
            horizontalRule.document.write(htmlOutput);
            horizontalRule.document.close();
        }

        if (!document.getElementById("forecolor")) {
            htmlOutput = createWindow(200, obj.SetColorTable('fore'));
            document.write("<iframe id=forecolor name=forecolor style='position: absolute; visibility: hidden; z-index: -1;width:1;height:1;'></iframe>");
            forecolor.document.open("text/html", "replace");
            forecolor.document.write(htmlOutput);
            forecolor.document.close();
        }

        if (!document.getElementById("backcolor")) {
            htmlOutput = createWindow(200, obj.SetColorTable('back'));
            document.write("<iframe id=backcolor name=backcolor style='position: absolute; visibility: hidden; z-index: -1;width:1;height:1;'></iframe>");
            backcolor.document.open("text/html", "replace");
            backcolor.document.write(htmlOutput);
            backcolor.document.close();
        }

        if (!document.getElementById("paragraph")) {
            htmlOutput = '<table cellpadding="0" cellspacing="0" width="100%" border="0" bgcolor="'+this.editorPopupBgcolor+'">' +
                "<tr><td bgcolor=#dedfdf><div style='margin-left:5px'><font style=font-size:9pt><b>½ºÅ¸ÀÏ</b></font>\n</div></td><td align=right bgcolor=#dedfdf><img src="+this.editorPath+"/icons/close.gif width=13 height=13 align=absmiddle onClick='parent.box_hide()' />&nbsp;</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.applyParagraph('<H1>')\"  align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:45'><h1 style='margin:0'>Á¦¸ñ 1</h1></td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.applyParagraph('<H2>')\"  align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:40'><h2 style='margin:0'>Á¦¸ñ 2</h2></td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.applyParagraph('<H3>')\"  align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:35'><h3 style='margin:0'>Á¦¸ñ 3</h3></td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.applyParagraph('<H4>')\"  align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:30'><h4 style='margin:0'>Á¦¸ñ 4</h4></td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.applyParagraph('<H5>')\"  align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:25'><h5 style='margin:0'>Á¦¸ñ 5</h5></td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.applyParagraph('<H6>')\"  align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:20'><h6 style='margin:0'>Á¦¸ñ 6</h6></td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.applyParagraph('<PRE>')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:20'><pre style='margin:0'>Preformatted</pre></td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.applyParagraph('<P>')\"   align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:20'><p style='margin:0'>º¸Åë</p></td></tr>" +
                "<tr><td colspan=2 height=3></td></tr>" +
                "</table>";

            htmlOutput = createWindow(200, htmlOutput);
            document.write("<iframe id=paragraph name=paragraph style='position: absolute; visibility: hidden; z-index: 1;width:1;height:1;'></iframe>");

            paragraph.document.open("text/html", "replace");
            paragraph.document.write(htmlOutput);
            paragraph.document.close();
        }

        if (!document.getElementById("zoom")){
            htmlOutput = '<table cellpadding="0" cellspacing="0" width="100%"border="0" bgcolor="'+this.editorPopupBgcolor+'">' +
                "<tr><td bgcolor=#dedfdf><div style='margin-left:5px'><font style=font-size:9pt><b>º»¹® È®´ë</b></font>\n</div></td><td align=right bgcolor=#dedfdf><img src="+this.editorPath+"/icons/close.gif width=13 height=13 align=absmiddle onClick='parent.box_hide();' />&nbsp;</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('500%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font style='font-size:9pt'>500%</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('250%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font style='font-size:9pt'>250%</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('200%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font style='font-size:9pt'>200%</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('150%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font style='font-size:9pt'>150%</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('120%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font style='font-size:9pt'>120%</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('100%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font style='font-size:9pt'>100%</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('75%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font style='font-size:9pt'>75%</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('50%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font style='font-size:9pt'>50%</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.viewZoom('25%')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:19'><font style='font-size:9pt'>25%</font>\n</td></tr>" +
                "<tr><td colspan=2 height=3></td></tr>" +
                "</table>";
            htmlOutput = createWindow(100, htmlOutput);
            document.write("<iframe id=zoom name=zoom style='position: absolute; visibility: hidden; z-index: -1;width:1;height:1;'></iframe>");
            zoom.document.open("text/html","replace");
            zoom.document.write(htmlOutput);
            zoom.document.close();
        }

        if (!document.getElementById("fontType")){
            htmlOutput = '<table cellpadding="0" cellspacing="0" width="100% border="0" bgcolor="'+this.editorPopupBgcolor+'">' +
                "<tr><td bgcolor=#dedfdf><div style='margin-left:5px'><font style=font-size:9pt><b>±ÛÀÚÃ¼</b></font>\n</div></td><td align=right bgcolor=#dedfdf><img src="+this.editorPath+"/icons/close.gif width=13 height=13 align=absmiddle onClick='parent.box_hide();' />&nbsp;</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('±¼¸²')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='±¼¸²' style='font-size:9pt'>°¡³ª´Ù¶ó¸¶¹Ù»ç (±¼¸²)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('¹ÙÅÁ')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='¹ÙÅÁ' style='font-size:9pt'>°¡³ª´Ù¶ó¸¶¹Ù»ç (¹ÙÅÁ)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('µ¸¿ò')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='µ¸¿ò' style='font-size:9pt'>°¡³ª´Ù¶ó¸¶¹Ù»ç (µ¸¿ò)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('±Ã¼­')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='±Ã¼­' style='font-size:9pt'>°¡³ª´Ù¶ó¸¶¹Ù»ç (±Ã¼­)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('Arial')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='Arial' style='font-size:9pt'>ABCDEFGHIJK (Arial)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('Arial Black')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='Arial Black' style='font-size:9pt'>ABCDEFGHIJK (Arial Black)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('Arial Narrow')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='Arial Narrow' style='font-size:9pt'>ABCDEFGHIJK (Arial Narrow)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('Comic Sans MS')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='Comic Sans MS' style='font-size:9pt'>ABCDEFGHIJK (Comic Sans MS)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('Courier New')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='Courier New' style='font-size:9pt'>ABCDEFGHIJK (Courier New)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('System')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:19'><font face='System' style='font-size:9pt'>ABCDEFGHIJK (System)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('Tahoma')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='Tahoma' style='font-size:9pt'>ABCDEFGHIJK (Tahoma)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('Times New Roman')\"  align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='Times New Roman' style='font-size:9pt'>ABCDEFGHIJK (Times New Roman)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeFontType('Verdana')\" align=center onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:17'><font face='Verdana' style='font-size:9pt'>ABCDEFGHIJK (Verdana)</font></td>\n</tr>" +
                "<tr><td colspan=2 height=3></td></tr>" +
                "</table>";

            htmlOutput = createWindow(220, htmlOutput);
            document.write("<iframe id=fontType name=fontType style='position: absolute; visibility: hidden; z-index: -1;width:1;height:1;'></iframe>");
            fontType.document.open("text/html","replace");
            fontType.document.write(htmlOutput);
            fontType.document.close();
        }

        if (!document.getElementById("fontSize")) {
            htmlOutput = '<table cellpadding="0" cellspacing="0" width="100% border="0" bgcolor="'+this.editorPopupBgcolor+'">' +
                "<tr><td bgcolor=#dedfdf><div style='margin-left:5px'><font style=font-size:9pt><b>±ÛÀÚ Å©±â</b></font>\n</div></td><td align=right bgcolor=#dedfdf><img src="+this.editorPath+"/icons/close.gif width=13 height=13 align=absmiddle onClick='parent.box_hide()' />&nbsp;</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeSize(1)\" onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:20;'><font size=1>°¡³ª´Ù¶ó¸¶¹Ù»ç (1)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeSize(2)\" onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:20'><font size=2>°¡³ª´Ù¶ó¸¶¹Ù»ç (2)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeSize(3)\" onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:22'><font size=3>°¡³ª´Ù¶ó¸¶¹Ù»ç (3)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeSize(4)\" onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:27'><font size=4>°¡³ª´Ù¶ó¸¶¹Ù»ç (4)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeSize(5)\" onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:33'><font size=5>°¡³ª´Ù¶ó¸¶¹Ù»ç (5)</font>\n</td></tr>" +
                "<tr><td colspan=2 onclick=\"parent.changeSize(6)\" onmouseover='parent."+this.oname+".mouse_over(this)' onmouseout='parent."+this.oname+".mouse_out(this)' class=dropdown style='height:40'><font size=6>°¡³ª´Ù¶ó¸¶¹Ù»ç (6)</font>\n</td></tr>" +
                "<tr><td colspan=2 height=3></td></tr>" +
                "</table>";

            htmlOutput = createWindow(280, htmlOutput);
            document.write("<iframe id=fontSize name=fontSize style='position: absolute; visibility: hidden; z-index: -1;width:1;height:1;'></iframe>");
            fontSize.document.open("text/html","replace");
            fontSize.document.write(htmlOutput);
            fontSize.document.close();
        }
    }

    editor.focus();

    this._add_event(editor.document,
                    function (event) {
                        return SetEditorEvent(this.IE ? editor.document.contentWindow.event : event, myobj);
                    });
}

function unescape_html (content)
{
    content = content.replace(/&lt;/g, '<');
    content = content.replace(/&gt;/g, '>');
    content = content.replace(/&quot;/g, '"');
    content = content.replace(/&amp;/g, '&');
    return content;
}

function _add_event(el, func)
{
    if (this.IE) {
        el.attachEvent("onmouseup", func);
    }
    else {
        el.addEventListener("click", func, true);
    }
}

function SetEditorEvent(ev, obj)
{
    var statusbar = document.getElementById("CHstatusBar"+obj);
    var is_ie = navigator.userAgent.toLowerCase().indexOf("msie") != -1;
    var ol = document.getElementById("id"+obj).contentWindow;
    var cmd, el, sel, rng, parent, ancestors = [];

    if (is_ie) {
        sel = ol.document.selection;
    }
    else {
        sel = ol.getSelection();
        if (typeof sel != "undefined") {
            try {
                rng = sel.getRangeAt(0);
            }
            catch(e) {
                rng = ol.document.createRange();
            }
        }
        else {
            rng = ol.document.createRange();
        }
    }

    if (is_ie) {
        rng = sel.createRange()

        if (sel.type == "Text" || sel.type == "None") {
            parent = rng.parentElement();
        }
        else if (sel.type == "Control") {
            parent = rng.item(0);
        }
        else {
            parent = ol.document.body;
        }
    }
    else try {
        parent = rng.commonAncestorContainer;

        if (!rng.collapsed && rng.startContainer == rng.endContainer &&
            rng.startOffset - rng.endOffset <= 1 && rng.startContainer.hasChildNodes())
        {
            parent = rng.startContainer.childNodes[rng.startOffset];
        }

        while (parent.nodeType == 3) {
            parent = parent.parentNode;
        }
    }
    catch (e) {
        parent = null;
    }

    while (parent && (parent.nodeType == 1) && (parent.tagName.toLowerCase() != 'body')) {
        ancestors.push(parent);
        parent = parent.parentNode;
    }

    ancestors.push(ol.document.body);

    for (var i = ancestors.length; --i >= 0;) {
        el = ancestors[i];
        if (!el) countine;

        switch (el.tagName.toLowerCase()) {
            case "img" : cmd = "img"; break;
            case "td" : cmd = "cell"; break;
            default : continue;
        }
    }

    switch (cmd) {
    case "img" :
        statusbar.style.display = "block";
        this.modify_image(el, statusbar);
        break;
    case "cell" :
        statusbar.style.display = "block";
        this.modify_cell(el, statusbar);
        break;
    default :
        statusbar.style.display = "none";
        statusbar.innerHTML = '';
    }
}

function hideStatus() {
    var statusbar = document.getElementById("CHstatusBar"+this.oname);
    statusbar.style.display = "none";
    statusbar.innerHTML = '';
}

function _get_attribute(el, str) {
    return el.getAttribute(str) ? el.getAttribute(str) : '';
}

function modify_cell(cell, statusbar) {
    var tbl = cell;
    var row = tbl;

    while (tbl != null && tbl.tagName.toLowerCase() != "table") {
        tbl = tbl.parentNode;
    }

    while (row != null && row.tagName.toLowerCase() != "tr") {
        row = row.parentNode;
    }

    var t_width  = tbl.style.width  ? tbl.style.width  : tbl.width;
    var t_height = tbl.style.height ? tbl.style.height : tbl.getAttribute("height");
    var t_cellpadding = tbl.cellPadding;
    var t_cellspacing = tbl.cellSpacing;
    var t_bgcolor = tbl.getAttribute("bgcolor") ? tbl.bgColor : '';
    var t_bordercolor = tbl.getAttribute("bordercolor") ? tbl.getAttribute("bordercolor") : '';
    var t_border = tbl.getAttribute("border") ? tbl.border : '';
    var c_width = cell.getAttribute("width") ? cell.getAttribute("width") : '';
    var c_height = cell.getAttribute("height") ? cell.getAttribute("height") : '';
    var c_align = cell.getAttribute("align") ? cell.align : '';
    var c_bgcolor = cell.getAttribute("bgcolor") ? cell.bgColor : '';
    var is_ie = navigator.userAgent.toLowerCase().indexOf("msie") != -1;

    if (t_height == null) t_height = '';
    t_width = t_width.replace(/px/ig, '');
    t_height = t_height.replace(/px/ig, '');

    var html_output =   '<table cellpadding=2 cellspacing=0 style="margin-top:5px;border:#dedfdf 1px solid;background:#f7f7f7;" width=100%>' +
                        '<tr><td><img src=icons/dot.gif width=100 height=1></td><td><img src=icons/dot.gif width=130 height=1 /></td>' +
                        '<td><img src='+editorPath+'/icons/dot.gif width=170 height=1 /></td><td width=90%></td></tr>' +
                        '<tr>' +
                        '<td><font style=font-size:9pt;>°¡·Î Æø: <input type=text size=4 value="'+t_width+'" id=n_width>&nbsp;</font>\n</td>' +
                        '<td><font style=font-size:9pt;>¼¿ ÆÐµù: <input type=text size=4 value="'+t_cellpadding+'" id=n_cellpadding>&nbsp;</font>\n</td>' +
                        '<td align="right"><font style=font-size:9pt;>Å×ÀÌºí ¹è°æ »ö: <input type=text size=6 value="'+t_bgcolor+'" id=n_bgcolor>&nbsp;</font>\n</td>' +
                        '<td><font style=font-size:9pt;>Å×ÀÌºí Á¤·Ä: <select id=alignment style=font-size:9pt>' +
                        '<option value="">¾øÀ½' +
                        '<option value=left>¿ÞÂÊ' +
                        '<option value=center>°¡¿îµ¥' +
                        '<option value=right>¿À¸¥ÂÊ' +
                        '</select></font></td>' +
                        '</tr>' +
                        '<tr>' +
                        '<td><font style=font-size:9pt;>¼¼·Î Æø: <input type=text size=4 value="'+t_height+'" id=n_height>&nbsp;</font>\n</td>' +
                        '<td><font style=font-size:9pt;>¼¿ °£°Ý: <input type=text size=4 value="'+t_cellspacing+'" id=n_cellspacing>&nbsp;</font>\n</td>' +
                        '<td align="right"><font style=font-size:9pt;>Å×ÀÌºí Å×µÎ¸® »ö: <input type=text size=6 value="'+t_bordercolor+'" id=n_bordercolor>&nbsp;</font>\n</td>' +
                        '<td><font style=font-size:9pt;>Å×µÎ¸® µÎ²²: <input type=text size=7 value="'+t_border+'" id=n_border>&nbsp;</font>\n</td>' +
                        '</tr>' +
                        '<tr>' +
                        '<td><font style=font-size:9pt;>¼¿ °¡·Î: <input type=text size=4 value="'+c_width+'" id=c_width>&nbsp;</font>\n</td>' +
                        '<td><font style=font-size:9pt;>°¡·Î Á¤·Ä: <select id=c_alignment style=font-size:9pt>' +
                        '<option value="">¾øÀ½' +
                        '<option value=left>¿ÞÂÊ' +
                        '<option value=center>°¡¿îµ¥' +
                        '<option value=right>¿À¸¥ÂÊ' +
                        '<option value=justify>¾çÂÊ' +
                        '</select></font></td>' +
                        '<td align="right"><font style=font-size:9pt;>¼¿ ¹è°æ »ö: <input type=text size=6 value="'+c_bgcolor+'" id=c_bgcolor>&nbsp;</font>\n</td>' +
                        '<td><font style=font-size:9pt;>No Wrap: <input type=checkbox value="'+t_bgcolor+'" id=nowrap>&nbsp;</font>\n' +
                        '&nbsp;<img src='+editorPath+'/icons/status_modify.gif style=cursor:pointer width=50 height=21 align=absmiddle id="editcell" /></td>' +
                        '</tr>' +
                        '<tr>' +
                        '<td><font style=font-size:9pt;>¼¿ ¼¼·Î: <input type=text size=4 value="'+c_height+'" id=c_height>&nbsp;</font>\n</td>' +
                        '<td><font style=font-size:9pt;>¼¼·Î Á¤·Ä: <select id=c_valignment style=font-size:9pt>' +
                        '<option value="">¾øÀ½' +
                        '<option value=top>À§ÂÊ' +
                        '<option value=middle>°¡¿îµ¥' +
                        '<option value=bottom>¾Æ·¡' +
                        '<option value=baseline>±âÁØ¼±' +
                        '</select></font></td>' +
                        '<td style=padding-left:12px colspan=2>' +
                        '<img align=absmiddle src='+editorPath+'/icons/increasecolspan.gif width=20 height=20 id=increasecolspan style=cursor:pointer title="ColSpan Áõ°¡" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/decreasecolspan.gif width=20 height=20 id=decreasecolspan style=cursor:pointer title="ColSpan °¨¼Ò" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/increaserowspan.gif width=20 height=20 id=increaserowspan style=cursor:pointer title="RowSpan Áõ°¡" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/decreaserowspan.gif width=20 height=20 id=decreaserowspan style=cursor:pointer title="RowSpan °¨¼Ò" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/addcol.gif width=20 height=20 id=addcol style=cursor:pointer title="Çà »ðÀÔ" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/addcols.gif width=20 height=20 id=addcols style=cursor:pointer title="¼¿ »ðÀÔ" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/removecol.gif width=20 height=20 id=removecol style=cursor:pointer title="Çà »èÁ¦" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/removecols.gif width=20 height=20 id=removecols style=cursor:pointer title="¼¿ »èÁ¦" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/addrow.gif width=20 height=20 id=addrows style=cursor:pointer title="¿­ »ðÀÔ" />&nbsp;' +
                        '<img align=absmiddle src='+editorPath+'/icons/removerow.gif width=20 height=20 id=removerow style=cursor:pointer title="¿­ »èÁ¦" />' +
                        '</td></tr></table>';

    statusbar.innerHTML = html_output;

    document.getElementById("nowrap").checked = cell.getAttribute("nowrap") ? true : false;

    var align_selectbox = document.getElementById("alignment");
    switch(tbl.getAttribute("align")) {
    case "left" :
        align_selectbox.options[1].selected = true;
        break;
    case "center" :
        align_selectbox.options[2].selected = true;
        break;
    case "right" :
        align_selectbox.options[3].selected = true;
        break;
    default :
        align_selectbox.options[0].selected = true;
    }

    align_selectbox = document.getElementById("c_alignment");
    switch(cell.getAttribute("align")) {
    case "left" :
        align_selectbox.options[1].selected = true;
        break;
    case "center" :
        align_selectbox.options[2].selected = true;
        break;
    case "right" :
        align_selectbox.options[3].selected = true;
        break;
    case "justify" :
        align_selectbox.options[4].selected = true;
        break;
    default :
        align_selectbox.options[0].selected = true;
    }

    align_selectbox = document.getElementById("c_valignment");
    switch(cell.getAttribute("valign")) {
    case "top" :
        align_selectbox.options[1].selected = true;
        break;
    case "middle" :
        align_selectbox.options[2].selected = true;
        break;
    case "bottom" :
        align_selectbox.options[3].selected = true;
        break;
    case "baseline" :
        align_selectbox.options[4].selected = true;
        break;
    default :
        align_selectbox.options[0].selected = true;
    }

    document.getElementById("editcell").onclick = function() {
        var n_width = document.getElementById("n_width");
        var n_height = document.getElementById("n_height");
        var n_align = document.getElementById("alignment");
        var n_cellpadding = document.getElementById("n_cellpadding");
        var n_cellspacing = document.getElementById("n_cellspacing");
        var n_bgcolor = document.getElementById("n_bgcolor");
        var n_border = document.getElementById("n_border");
        var n_bordercolor = document.getElementById("n_bordercolor");
        var c_width = document.getElementById("c_width");
        var c_height = document.getElementById("c_height");
        var c_bgcolor = document.getElementById("c_bgcolor");
        var c_align = document.getElementById("c_alignment");
        var c_valign = document.getElementById("c_valignment");

        tbl.border = n_border.value;
        tbl.removeAttribute("width", 0);
        tbl.removeAttribute("height", 0);

        if (n_width.value) tbl.style.width = n_width.value;
        if (n_height.value > 0) tbl.style.height = n_height.value;

        tbl.cellPadding = n_cellpadding.value;
        tbl.cellSpacing = n_cellspacing.value;

        if (n_align.value != "") tbl.align = n_align.value;
        else
            if (tbl.getAttribute("align")) tbl.removeAttribute("align", 0);

        if (n_bgcolor.value) tbl.bgColor = n_bgcolor.value;
        else
            if (tbl.getAttribute("bgcolor")) tbl.removeAttribute("bgcolor", 0);

        if (n_bordercolor.value) tbl.setAttribute("bordercolor", n_bordercolor.value);
        else
            if (tbl.getAttribute("bordercolor")) tbl.removeAttribute("bordercolor", 0);



        if (c_width.value > 0) cell.width = c_width.value;
        if (c_height.value > 0) cell.height = c_height.value;

        cell.noWrap = document.getElementById("nowrap").checked ? true : false;

        if (c_align.value != "") cell.align = c_align.value;
        else
            if (cell.getAttribute("align")) cell.removeAttribute("align", 0);
        if (c_valign.value != "") cell.vAlign = c_valign.value;
        else
            if (cell.getAttribute("valign")) cell.removeAttribute("valign", 0);
        if (c_bgcolor.value) cell.bgColor = c_bgcolor.value;
        else
            if (cell.getAttribute("bgcolor")) cell.removeAttribute("bgcolor", 0);
    }

    document.getElementById("increasecolspan").onclick = function() {
        cell.colSpan++;
    }
    document.getElementById("decreasecolspan").onclick = function() {
        if (cell.colSpan == 1) cell.removeAttribute("colspan", 0);
        else cell.colSpan = cell.colSpan - 1;
    }
    document.getElementById("increaserowspan").onclick = function() {
        cell.rowSpan++;
    }
    document.getElementById("decreaserowspan").onclick = function() {
        if (cell.rowSpan == 1) cell.removeAttribute("rowspan", 0);
        else cell.rowSpan = cell.rowSpan - 1;
    }
    document.getElementById("addcol").onclick = function() {
        for (var i=0; i<tbl.rows.length; i++) {
            var trow = tbl.rows.item(i);
            var col = trow.insertCell(cell.cellIndex);
            if (!is_ie) {
                var br = document.createElement("br");
                col.appendChild(br);
            }
        }
    }
    document.getElementById("addcols").onclick = function() {
        var col = row.insertCell(cell.cellIndex);
        if (!is_ie) {
            var br = document.createElement("br");
            col.appendChild(br);
        }
    }
    document.getElementById("removecol").onclick = function() {
        for (var i=0; i<tbl.rows.length; i++) {
            var trow = tbl.rows.item(i);
            trow.deleteCell(cell.cellIndex);
        }
    }
    document.getElementById("removecols").onclick = function() {
        row.deleteCell(cell.cellIndex);
    }
    document.getElementById("addrows").onclick = function() {
        var nrow = tbl.insertRow(row.rowIndex);
        var len = row.cells.length;

        for (var i=0; i<len; i++) {
            var td = document.createElement("td");
            if (!is_ie) {
                var br = document.createElement("br");
                td.appendChild(br);
                nrow.appendChild(td);
            }
        }
    }
    document.getElementById("removerow").onclick = function() {
        tbl.deleteRow(row.rowIndex);
    }
}

function modify_image(img, statusbar) {
    var a_align = new Array("baseline","top","middle","bottom","texttop","absmiddle","absbottom","left","right");
    var a_text = new Array("±âÁØ¼±","À§ÂÊ","°¡¿îµ¥","¾Æ·¡ÂÊ","¹®ÀÚ¿­ À§ÂÊ","¼±ÅÃ ¿µ¿ªÀÇ °¡¿îµ¥","¼±ÅÃ ¿µ¿ªÀÇ ¾Æ·¡ÂÊ","¿ÞÂÊ","¿À¸¥ÂÊ");

    if (img.hspace < 0) img.hspace = 0;
    if (img.vspace < 0) img.vspace = 0;
    if (img.border < 0 || img.border == '') img.border = 0;

    var html_output =   '<table cellpadding=2 cellspacing=0 style="margin-top:5px;border:#dedfdf 1px solid;background:#f7f7f7;" width=100%>' +
                        '<tr>' +
                        '<td width=120><font style=font-size:9pt;>°¡·Î ÇÈ¼¿: <input type=text size=3 value='+img.width+' id=n_width>&nbsp;</font>\n</td>' +
                        '<td width=120><font style=font-size:9pt;>°¡·Î ¿©¹é: <input type=text size=3 value='+img.hspace+' id=n_hspace>&nbsp;</font>\n</td>' +
                        '<td width=200><font style=font-size:9pt;>±×¸² Á¤·Ä: <select id=n_alignment name=n_alignment style=font-size:9pt>' +
                        '<option value="">¾øÀ½</option>';

                        for (var i=0; i<a_align.length; i++) {
                            html_output += '<option value='+a_align[i];
                            if (img.align == a_align[i]) html_output += ' selected';
                            html_output += '>'+a_text[i]+'</option>';
                        }

                        html_output += '</select></font>' +
                        '</td>' +
                        '<td><font style=font-size:9pt;>Äè¼± µÎ²²: <input type=text size=3 value='+img.border+' id=n_border>&nbsp;</font>\n</td>' +
                        '</tr>' +
                        '<tr>' +
                        '<td width=120><font style=font-size:9pt;>¼¼·Î ÇÈ¼¿: <input type=text size=3 value='+img.height+' id=n_height>&nbsp;</font>\n</td>' +
                        '<td width=120><font style=font-size:9pt;>¼¼·Î ¿©¹é: <input type=text size=3 value='+img.vspace+' id=n_vspace>&nbsp;</font>\n</td>' +
                        '<td colspan=2><font style=font-size:9pt;>±×¸² ¼³¸í: <input type=text size=25 id=n_alt value='+img.alt+'>' +
                        '&nbsp;<img src='+editorPath+'/icons/status_modify.gif style=cursor:pointer width=50 height=21 align=absmiddle id="editimg" /></font>\n</td>' +
                        '</tr></table>';

    statusbar.innerHTML = html_output;

    document.getElementById("editimg").onclick = function() {
        var n_width  = document.getElementById("n_width");
        var n_height = document.getElementById("n_height");
        var n_hspace = document.getElementById("n_hspace");
        var n_vspace = document.getElementById("n_vspace");
        var n_border = document.getElementById("n_border");
        var n_align  = document.getElementById("n_alignment");
        var n_alt    = document.getElementById("n_alt");

        if (n_width.value == '' || n_width.value == null || n_width.value < 1) {
            alert("°¡·Î ÇÈ¼¿ Å©±â¸¦ ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À");
            return;
        }
        else if (n_height.value == '' || n_height.value == null || n_height.value < 1) {
            alert("¼¼·Î ÇÈ¼¿ Å©±â¸¦ ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À");
            return;
        }
        else {
            img.width  = parseInt(n_width.value);
            img.height = parseInt(n_height.value);

            if (n_hspace.value) img.hspace = parseInt(n_hspace.value);
            if (n_vspace.value) img.vspace = parseInt(n_vspace.value);
            if (n_border.value) img.border = parseInt(n_border.value);
            if (n_align.value)  img.align  = n_align.value ;
            if (n_alt.value)    img.alt    = n_alt.value;
        }
    };
}

function cheditor (myobj)
{
    // Áö¿ø ºê¶ó¿ìÀú Ã¼Å©
    // ºê¶ó¿ìÀú°¡ Á¢ÇÕÇÏÁö ¾ÊÀ» °æ¿ì <textarea> Ãâ·Â

    var w_msg = navigator.appVersion+"\n¹öÀü´Â Áö¿øÇÏÁö ¾Ê½À´Ï´Ù.";

    if (navigator.appVersion.indexOf("MSIE")!=-1) {
        if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 5.5) {
            this.run = function() {
                document.write("<textarea name=message style='width:100%; height:200px'></textarea>");
            };
            return;
        }
    }

    if (navigator.product == "Gecko") {
        if (navigator.productSub < 20030210) {
            this.run = function() {
                document.write("<textarea name=message style='width:100%; height:200px'>"+wmsg+"</textarea>");
            };
            return;
        }
    }

    this.oname                    = myobj;
    this.IE                       = navigator.userAgent.toLowerCase().indexOf("msie") != -1;
    this.width                    = "100%";
    this.height                   = "300px";
    this.fontsize                 = '9pt';
    this.fontface                 = 'gulim';
    this.lineheight               = '14pt';
    this.editorBgcolor            = "#fff";
    this.editorBorder             = "1px #999 solid";
    this.editorToolbar            = "border-left:#999 1 solid;border-top:#999 1 solid;border-right:#999 1 solid;background:#f0f0f0;";
    this.editorPopupBgcolor       = "#ffffff";
    this.run                      = run;
    this.editorPath               = ".";
    this.unescape_html            = unescape_html;
    this.dimension                = dimension;
    this.default_css              = default_css;
    this.displayWindow            = displayWindow;
    this.windowPos                = windowPos;
    this.box_position             = box_position;
    this.box_hide                 = box_hide;
    this.mouse_over               = mouse_over;
    this.mouse_out                = mouse_out;
    this.setIcon                  = setIcon;
    this.exec                     = exec;
    this.exec2                    = exec2;
    this.exec3                    = exec3;
    this.fix_selection;
    this.fix_selection_type;
    this.selection;
    this.selection_type;
    this.set_selection            = set_selection;
    this.SetColorTable            = SetColorTable;
    this.setDisplayMode           = setDisplayMode;
    this.displayMode              = "RICH";
    this.previewMode              = previewMode;
    this.plainMode                = plainMode;
    this.put_content              = put_content;
    this.selection_color          = "#5579aa";
    this.get_content              = get_content;
    this.outputHTML               = outputHTML;
    this.outputBodyHTML           = outputBodyHTML;
    this.outputBodyText           = outputBodyText;
    this.ContentLength            = ContentLength;
    this.htmlKey                  = htmlKey;
    this.get_element              = get_element;
    this.get_element_node         = get_element_node;
    this.insert                   = insert;
    this.setBackgroundColor       = setBackgroundColor;
    this.insertEl                 = insertEl;
    this.insertIE                 = insertIE;
    this.SetGeckoColor            = SetGeckoColor;
    this.pasteContent             = false;
    this.pasteContentForm         = "paste";
    this.formName                 = "";
    this.insertImage              = insertImage;
    this.insertTable              = insertTable;
    this.insertBgImage            = insertBgImage;
    this.hyperLink                = hyperLink;
    this.ViewHTML                 = true;
    this.BodyOnly                 = false;
    this.Preview                  = true;
    this.PlainMode                = false;
    this.returnFalse              = returnFalse;
    this.setImages                = [];
    this.getImages                = getImages;
    this._add_event               = _add_event;
    this.SetEditorEvent           = SetEditorEvent;
    this.modify_image             = modify_image;
    this.modify_cell              = modify_cell;
    this.hideStatus               = hideStatus;
    this.hrefTarget               = "_blank";
    this.uploadPath		  = "";
}
