function FJInsertIcon(mt_icon_base) {
    var mt_icons = [
        [ "emoji30.gif", "", 19, 19 ],
        [ "emoji31.gif", "", 19, 19 ],
        [ "emoji32.gif", "", 19, 19 ],
        [ "emoji33.gif", "", 19, 19 ],
        [ "emoji34.gif", "", 19, 19 ],
        [ "emoji35.gif", "", 19, 19 ],
        [ "emoji36.gif", "", 19, 19 ],
        [ "emoji37.gif", "", 19, 19 ],
        [ "emoji38.gif", "", 19, 19 ],
        [ "emoji39.gif", "", 19, 19 ],
        [ "emoji40.gif", "", 19, 19 ],
        [ "emoji41.gif", "", 19, 19 ],
        [ "emoji42.gif", "", 19, 19 ],
        [ "emoji101.gif", "", 19, 19 ],
        [ "emoji102.gif", "", 19, 19 ],
        [ "bikkuri01.gif", "びっくり", 15, 15 ],
        [ "bikkuri02.gif", "びっくり", 15, 15 ],
        [ "cake.gif", "ケーキ", 15, 15 ],
        [ "hare.gif", "", 15, 15 ],
        [ "hatena01.gif", "", 15, 15 ],
        [ "heart01.gif", "", 15, 15 ],
        [ "heart02.gif", "", 15, 15 ],
        [ "heart04.gif", "", 15, 15 ],
        [ "heart05.gif", "", 15, 15 ],
        [ "kao06.gif", "", 15, 15 ],
        [ "kao07.gif", "", 15, 15 ],
        [ "kao08.gif", "", 15, 15 ],
        [ "osake02.gif", "", 15, 15 ],
        [ "spoon01.gif", "", 15, 15 ],
        [ "emoji609.gif", "", 20, 20 ],
        [ "emoji610.gif", "", 20, 20 ],
        [ "emoji611.gif", "", 20, 20 ],
        [ "emoji612.gif", "", 20, 20 ],
        [ "emoji613.gif", "", 20, 20 ],
        [ "emoji614.gif", "", 20, 20 ],
        [ "emoji615.gif", "", 20, 20 ],
        [ "emoji296.gif", "", 20, 20 ],
        [ "emoji639.gif", "", 20, 20 ],
        [ "emoji63.gif", "", 20, 20 ],
        [ "emoji432.gif", "", 17, 23 ],
        [ "emoji433.gif", "", 17, 23 ],
        [ "emoji434.gif", "", 17, 23 ],
        [ "emoji215.gif", "", 20, 20 ],
        [ "emoji216.gif", "", 20, 20 ],
        [ "emoji224.gif", "", 20, 20 ],
        [ "emoji370.gif", "", 20, 20 ],
        [ "emoji323.gif", "", 20, 20 ],
        [ "emoji324.gif", "", 20, 20 ],
        [ "emoji325.gif", "", 20, 20 ],
        [ "emoji592.gif", "", 20, 20 ],
        [ "emoji593.gif", "", 20, 20 ],
        [ "emoji594.gif", "", 20, 20 ],
        [ "emoji781.gif", "", 20, 20 ],
        [ "emoji782.gif", "", 20, 20 ],
        [ "emoji6.gif", "", 20, 20 ],
        [ "emoji13.gif", "", 20, 20 ],
        [ "emoji14.gif", "", 20, 20 ],
        [ "emoji15.gif", "", 20, 20 ],
        [ "emoji17.gif", "", 20, 20 ],
        [ "emoji18.gif", "", 20, 20 ],
        [ "emoji19.gif", "", 20, 20 ],
        [ "emoji21.gif", "", 20, 20 ],
        [ "emoji84.gif", "", 20, 20 ],
        [ "emoji89.gif", "", 20, 20 ],
        [ "emoji90.gif", "", 20, 20 ],
        [ "emoji130.gif", "", 20, 20 ],
        [ "emoji131.gif", "", 20, 20 ],
        [ "emoji132.gif", "", 20, 20 ],
        [ "emoji184.gif", "", 20, 20 ],
        [ "emoji185.gif", "", 20, 20 ],
        [ "emoji187.gif", "", 20, 20 ],
        [ "emoji190.gif", "", 20, 20 ],
        [ "emoji208.gif", "", 20, 20 ],
        [ "emoji228.gif", "", 20, 20 ],
        [ "emoji229.gif", "", 20, 20 ],
        [ "emoji297.gif", "", 20, 20 ],
        [ "emoji550.gif", "", 20, 20 ],
        [ "emoji579.gif", "", 20, 20 ],
        [ "emoji661.gif", "", 20, 20 ],
        [ "emoji663.gif", "", 20, 20 ],
        [ "emoji784.gif", "", 20, 20 ],
        [ "emoji806.gif", "", 20, 20 ],
        [ "emoji578.gif", "", 20, 20 ]
    ];

/*
    以下の例はpepper様の「BALLOON-01」を使う場合です。
    var mt_icons = [
        [ "pp_00.gif", "・・・", 17, 17 ],
        [ "pp_01.gif", "ハート", 17, 17 ],
        [ "pp_02.gif", "汗", 17, 17 ],
        [ "pp_03.gif", "嫌な感じ", 17, 17 ],
        [ "pp_04.gif", "怒り", 17, 17 ],
        [ "pp_05.gif", "音符", 17, 17 ],
        [ "pp_06.gif", "？", 17, 17 ],
        [ "pp_07.gif", "！", 17, 17 ],
        [ "pp_08.gif", "汗2", 17, 17 ],
        [ "pp_09.gif", "ひらめき", 17, 17 ],
        [ "pp_10.gif", "ハートブレイク", 17, 17 ],
        [ "pp_11.gif", "ダブルハート", 17, 17 ],
        [ "pp_12.gif", "ドクロ", 17, 17 ]
    ];
*/

    var i_file = 0;
    var i_alt = 1;
    var i_width = 2;
    var i_height = 3;

    this.insertToTextArea = function(v) {
        var e = document.getElementById('comment-text');
        if (document.selection) {
            e.focus();
            var range = document.selection.createRange();
            range.text = v;
        } else {
            var length = e.textLength;
            var start = e.selectionStart;
            var end = e.selectionEnd;
            if (end == 1 || end == 2) end = length;
            e.value = e.value.substring(0, start) + v + e.value.substr(end, length);
            e.selectionStart = start + v.length;
            e.selectionEnd = start + v.length;
        }
        e.focus();
    };

    this.insertIconEditor = function(i) {
        var i_html;

        if (app.editor.mode == 'iframe') {
            var id = "temp_id_for_retrieving_inserted_element_" + Unique.id();
            i_html = '<img src="' + mt_icon_base + mt_icons[i][i_file] + '" class="mt_icon" width="' + mt_icons[i][i_width] + '" height="' + mt_icons[i][i_height] + '" alt="' + mt_icons[i][i_alt] + '" id="' + id + '" />';
            var inserted = _insertHTML(i_html, false, id, true);
            if (inserted) {
                inserted.src = mt_icon_base + mt_icons[i][i_file];
            }
        }
        else {
            i_html = '<img src="' + mt_icon_base + mt_icons[i][i_file] + '" class="mt_icon" width="' + mt_icons[i][i_width] + '" height="' + mt_icons[i][i_height] + '" alt="' + mt_icons[i][i_alt] + '" />';
            app.editor.actual.setSelection(i_html);
        }
    };

    this.insertIconTag = function(i) {
        var i_html;

        i_html = '<img src="' + mt_icon_base + mt_icons[i][0] + '" class="mt_icon" width="' + mt_icons[i][i_width] + '" height="' + mt_icons[i][i_height] + '" alt="' + mt_icons[i][i_alt] + '" />';
        this.insertToTextArea(i_html);
    };

    this.insertIconMacro = function(i) {
        var i_html;

        i_html = ':' + mt_icons[i][0] + ':';
        this.insertToTextArea(i_html);
    };

    this.listIconsEditor = function() {
        var i;
        var html = '';

        for (i = 0; i < mt_icons.length; i++) {
            html += '<img src="' + mt_icon_base + mt_icons[i][i_file] + '" border="0" width="' + mt_icons[i][i_width] + '" height="' + mt_icons[i][i_height] + '" alt="' + mt_icons[i][i_alt] + '" onclick="_fj_insert_icon_obj.insertIconEditor(' + i + ');" style="cursor : pointer;" />';
        }
        document.getElementById('editor_insert_icons').innerHTML = html;
    };

    this.listIconsCommentForm = function(mode) {
        var i;
        var html = '';

        for (i = 0; i < mt_icons.length; i++) {
            if (mode == 'tag') {
                html += '<img src="' + mt_icon_base + mt_icons[i][i_file] + '" border="0" width="' + mt_icons[i][i_width] + '" height="' + mt_icons[i][i_height] + '" alt="' + mt_icons[i][i_alt] + '" onclick="_fj_insert_icon_obj.insertIconTag(' + i + ');" style="cursor : pointer;" />';
            }
            else if (mode == 'macro') {
                html += '<img src="' + mt_icon_base + mt_icons[i][i_file] + '" border="0" width="' + mt_icons[i][i_width] + '" height="' + mt_icons[i][i_height] + '" alt="' + mt_icons[i][i_alt] + '" onclick="_fj_insert_icon_obj.insertIconMacro(' + i + ');" style="cursor : pointer;" />';
            }
        }
        document.write(html);
    };

    _insertHTML = function(html, select, id, isTempId) {
        var editor = app.editor.actual;
        var selection = editor.getSelection();
        var inserted = null;
        if (selection.createRange) { // Internet Explorer (IE)
            var range = selection.createRange();
            if (selection.type == "None" || selection.type == "Text") {
                try {
                    range.pasteHTML(html);
                } catch (err) {
                    log("Error pasting html on selection of type 'Text' or 'None': " + err);                
                }
                if (defined(id)) {
                    inserted = editor.document.getElementById(id);
                    if(select) 
                        range.moveToElementText(inserted);
                } else {
                    if(range.moveStart) {
                        range.moveStart("character", ((html.length) * (-1)));
                        inserted = range.parentElement();
                    }
                }
                if (select) 
                    range.select();
            }
            else { // IE 'Control' selection    
                range.item(0).outerHTML = html;
                inserted = range.item(0); 
            }
        }
 
        // mozilla
        else if (selection.getRangeAt) {
            var range;
            if (selection.rangeCount)
                range = selection.getRangeAt(0);
            else {
                range = editor.document.createRange();
                range.setStart(editor.document.body, 0);
                range.setEnd(editor.document.body, 0);
                selection.addRange(range);
            }
            var anchor = range.startContainer;

            if (selection && range && editor.isCaretAtEnd(selection, range)) { 
                var paragraph = editor.document.createElement(editor.FORMAT_BLOCK_TAG);
                paragraph.insertBefore(editor.document.createElement("br"), null);
                editor.document.getElementsByTagName("body")[0].insertBefore(paragraph, null);
            } 

            if (select && anchor.nodeType == Node.TEXT_NODE && !html.match( /<[a-z][a-z]*\s/i)) {
                range.setStart(anchor, selection.anchorOffset);
                var insertNode = editor.document.createTextNode(html);
                range.insertNode(insertNode);
                var inserted = insertNode;
            }
            else {
                var pS = anchor.previousSibling;
                var nS = anchor.nextSibling;
                editor.document.execCommand("insertHTML", false, html);
                if(pS !== anchor.previousSibling)
                    inserted = anchor.previousSibling;
                else if(nS !== anchor.nextSibling)
                    inserted = anchor.nextSibling;
                else 
                    inserted = anchor.firstChild;
            }

            if (defined(id))
                inserted = editor.document.getElementById(id);
            if (inserted && inserted.tagName && inserted.tagName.toLowerCase() == "a")
                editor.tagJustInserted = true;
            if (select) {
                range.selectNode(inserted);
                editor.monitorSelection(); // Required for Mozilla for proper arrow keys on highlighted link.
            }
            selection.addRange(range);        
        }

        if(isTempId && inserted) {
            inserted.id = undefined;
            inserted.removeAttribute("id");
        }
        return inserted;
    };
}
