function FJInsertIcon(mt_icon_base) {
    var mt_icons = [
[ "happy01.gif", "", 16, 16 ],
[ "angry.gif", "", 16, 16 ],
[ "despair.gif", "", 16, 16 ],
[ "sad.gif", "", 16, 16 ],
[ "wobbly.gif", "", 16, 16 ],
[ "think.gif", "", 16, 16 ],
[ "confident.gif", "", 16, 16 ],
[ "coldsweats01.gif", "", 16, 16 ],
[ "coldsweats02.gif", "", 16, 16 ],
[ "pout.gif", "", 16, 16 ],
[ "gawk.gif", "", 16, 16 ],
[ "lovely.gif", "", 16, 16 ],
[ "bleah.gif", "", 16, 16 ],
[ "wink.gif", "", 16, 16 ],
[ "happy02.gif", "", 16, 16 ],
[ "bearing.gif", "", 16, 16 ],
[ "catface.gif", "", 16, 16 ],
[ "crying.gif", "", 16, 16 ],
[ "weep.gif", "", 16, 16 ],
[ "delicious.gif", "", 16, 16 ],
[ "smile.gif", "", 16, 16 ],
[ "shock.gif", "", 16, 16 ],
[ "sweat01.gif", "", 16, 16 ],
[ "sweat02.gif", "", 16, 16 ],
[ "heart01.gif", "", 16, 16 ],
[ "heart02.gif", "", 16, 16 ],
[ "heart03.gif", "", 16, 16 ],
[ "heart04.gif", "", 16, 16 ],
[ "note.gif", "", 16, 16 ],
[ "notes.gif", "", 16, 16 ],
[ "rock.gif", "", 16, 16 ],
[ "scissors.gif", "", 16, 16 ],
[ "paper.gif", "", 16, 16 ],
[ "good.gif", "", 16, 16 ],
[ "punch.gif", "", 16, 16 ],
[ "up.gif", "", 16, 16 ],
[ "down.gif", "", 16, 16 ],
[ "upwardright.gif", "", 16, 16 ],
[ "downwardright.gif", "", 16, 16 ],
[ "upwardleft.gif", "", 16, 16 ],
[ "downwardleft.gif", "", 16, 16 ],
[ "sign01.gif", "", 16, 16 ],
[ "sign02.gif", "", 16, 16 ],
[ "sign03.gif", "", 16, 16 ],
[ "shine.gif", "", 16, 16 ],
[ "flair.gif", "", 16, 16 ],
[ "annoy.gif", "", 16, 16 ],
[ "bomb.gif", "", 16, 16 ],
[ "sleepy.gif", "", 16, 16 ],
[ "impact.gif", "", 16, 16 ],
[ "dash.gif", "", 16, 16 ],
[ "sun.gif", "", 16, 16 ],
[ "cloud.gif", "", 16, 16 ],
[ "rain.gif", "", 16, 16 ],
[ "snow.gif", "", 16, 16 ],
[ "thunder.gif", "", 16, 16 ],
[ "typhoon.gif", "", 16, 16 ],
[ "sprinkle.gif", "", 16, 16 ],
[ "moon1.gif", "", 16, 16 ],
[ "moon2.gif", "", 16, 16 ],
[ "moon3.gif", "", 16, 16 ],
[ "fullmoon.gif", "", 16, 16 ],
[ "night.gif", "", 16, 16 ],
[ "restaurant.gif", "", 16, 16 ],
[ "cafe.gif", "", 16, 16 ],
[ "japanesetea.gif", "", 16, 16 ],
[ "beer.gif", "", 16, 16 ],
[ "fastfood.gif", "", 16, 16 ],
[ "birthday.gif", "", 16, 16 ],
[ "cherry.gif", "", 16, 16 ],
[ "banana.gif", "", 16, 16 ],
[ "apple.gif", "", 16, 16 ],
[ "riceball.gif", "", 16, 16 ],
[ "cake.gif", "", 16, 16 ],
[ "wine.gif", "", 16, 16 ],
[ "noodle.gif", "", 16, 16 ],
[ "bread.gif", "", 16, 16 ],
[ "snail.gif", "", 16, 16 ],
[ "penguin.gif", "", 16, 16 ],
[ "fish.gif", "", 16, 16 ],
[ "pig.gif", "", 16, 16 ],
[ "virgo.gif", "", 16, 16 ],
[ "taurus.gif", "", 16, 16 ],
[ "libra.gif", "", 16, 16 ],
[ "sports.gif", "", 16, 16 ],
[ "golf.gif", "", 16, 16 ],
[ "tennis.gif", "", 16, 16 ],
[ "car.gif", "", 16, 16 ],
[ "hospital.gif", "", 16, 16 ],
[ "toilet.gif", "", 16, 16 ],
[ "music.gif", "", 16, 16 ],
[ "book.gif", "", 16, 16 ],
[ "ribbon.gif", "", 16, 16 ],
[ "present.gif", "", 16, 16 ],
[ "memo.gif", "", 16, 16 ],
[ "tv.gif", "", 16, 16 ],
[ "game.gif", "", 16, 16 ],
[ "diamond.gif", "", 16, 16 ],
[ "foot.gif", "", 16, 16 ],
[ "eyeglass.gif", "", 16, 16 ],
[ "xmas.gif", "", 16, 16 ],
[ "mailto.gif", "", 16, 16 ],
[ "mail.gif", "", 16, 16 ],
[ "key.gif", "", 16, 16 ],
[ "search.gif", "", 16, 16 ],
[ "ok.gif", "", 16, 16 ],
[ "spa.gif", "", 16, 16 ],
[ "kissmark.gif", "", 16, 16 ],
[ "pen.gif", "", 16, 16 ],
[ "clock.gif", "", 16, 16 ],
[ "t-shirt.gif", "", 16, 16 ],
[ "denim.gif", "", 16, 16 ],
[ "pencil.gif", "", 16, 16 ],
[ "ring.gif", "", 16, 16 ],
[ "sandclock.gif", "", 16, 16 ],
[ "run.gif", "", 16, 16 ],
[ "danger.gif", "", 16, 16 ],
[ "school.gif", "", 16, 16 ],
[ "clover.gif", "", 16, 16 ],
[ "cherryblossom.gif", "", 16, 16 ],
[ "tulip.gif", "", 16, 16 ]
/*
        [ "ファイル名", "説明", 幅, 高さ ],
        [ "ファイル名", "説明", 幅, 高さ ]
*/
    ];
    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 editor = document.getElementById('editor-content-enclosure');
        var editorParent = editor.parentNode;
        var iconDiv = document.createElement('div');
        iconDiv.id = 'editor-content-iconbar';
        iconDiv.style.padding = '3px 10px';
        iconDiv.style.border = '1px solid #cccccc';
        iconDiv.style.borderTop = 'none';
        iconDiv.style.backgroundColor = '#f3f3f3';
        editorParent.insertBefore(iconDiv, editor);
        var spanElement = document.createElement('span');
        spanElement.id = 'editor_insert_icons';
        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;" />';
        }
        spanElement.innerHTML = html;
        iconDiv.appendChild(spanElement);
    };

    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;
    };
}
