function FJInsertIcon(mt_icon_base, position) {
    var mt_icons = [
["n1item02.gif","花びら",13,13],
["e_orangehana.gif","橙のお花",13,13],
["e129_clover.gif","クローバー",13,13],
["s_tree09.gif","花びら2",17,16],
["s_tree10.gif","花ひらひら",17,16],
["n1item14.gif","葉1",13,13],
["s_tree14.gif","もみじ",16,16],
["s_tree15.gif","青もみじ",16,16],
["s_tree16.gif","黄もみじ",16,16],
["e_ki.gif","木",13,13],
["s_tree08.gif","チューリップ",15,16],
["s_tree11.gif","朝顔",19,19],
["s_tree12.gif","ひまわり",17,20],
["s_tree13.gif","ひまわり2",17,17],
["e_kani.gif","かに",13,13],
["s_animal31.gif","かめ",18,14],
["e_zou.gif","ぞう1",13,13],
["e_buta.gif","豚",13,13],
["e_kuma.gif","くまさん",13,13],
["e114_kappa.gif","かっぱ",13,13],
["e122_tyo.gif","ちょう",13,13],
["e124_usagi.gif","うさぎ",15,15],
["e125_kirin.gif","きりん",15,15],
["s_animal21.gif","リス",20,16],
["e174_koala.gif","コアラ",25,13],
["e167_nya1.gif","にゃんこ1",20,15],
["e168_nya2.gif","にゃんこ2",19,15],
["e169_nya3.gif","にゃんこ3",19,15],
["e177_nikukyu.gif","肉球",22,15],
["s_animal_03.gif","ぱんだ",22,13],
["s_animal20.gif","やぎ",18,15],
["s_animal25.gif","ねずみ",16,13],
["s_animal08.gif","もー",18,18],
["s_animal07.gif","とら",17,14],
["s_animal18.gif","うさぎさん",18,16],
["s_animal23.gif","タツノオトシゴ1",15,19],
["s_animal30.gif","へび",20,20],
["s_animal28.gif","うま",20,18],
["s_animal29.gif","ひつじ",20,20],
["s_animal19.gif","さる",20,12],
["e_hiyoko.gif","ひよこさん",13,13],
["s_animal06.gif","わんわん",20,13],
["s_animal_04.gif","ほねっこ",18,10],
["e155_kaeru1.gif","かえるニコ",15,15],
["e156_kaeru2.gif","かえる口なし",15,15],
["s_animal_01.gif","てんとうむし",18,19],
["s_animal_02.gif","みつばち",18,16],
["s_animal16.gif","とんぼ1",19,19],
["s_animal17.gif","とんぼ2",19,19],
["s_animal09.gif","うなぎ",23,18],
["s_animal10.gif","でめきん",21,14],
["s_animal11.gif","右を向いている魚",21,14],
["s_animal12.gif","左を向いている魚",21,14],
["s_animal13.gif","右を向いている金魚",21,14],
["s_animal14.gif","左を向いている金魚",21,14],
["s_animal15.gif","たこ",20,19],
["s_animal24.gif","タツノオトシゴ2",15,19],
["e100_apple.gif","リンゴ",13,13],
["e104_banana.gif","バナナ",13,13],
["e204_orange.gif","オレンジ",23,13],
["e205_budou.gif","ぶどう",15,18],
["e123_sakuranbo.gif","さくらんぼ",13,13],
["s_eat11.gif","くり",17,15],
["s_eat02.gif","焼きいも",20,16],
["e106_hourenso.gif","ほうれん草",13,13],
["n1item07.gif","とまと",13,13],
["n1item09.gif","きのこ",16,18],
["s_eat13.gif","きのコ",16,18],
["n1item04.gif","豆",13,13],
["s_eat_01.gif","おむすび",15,14],
["e109_orangejuce.gif","オレンジジュース",13,13],
["e_eiyo.gif","栄養ドリンク",13,13],
["e131_coffee.gif","coffee",15,15],
["e132_beer.gif","ビール",15,15],
["e_sportsdrink.gif","スポーツドリンク",13,13],
["e142_tea.gif","ほうじ茶",15,15],
["e144_kakuteru.gif","カクテル",13,13],
["e130_cake.gif","ケーキ",13,13],
["e152_omu.gif","オムライス",23,13],
["e171_bis.gif","ビスケット",15,15],
["e133_eat1.gif","お食事1",25,15],
["e134_eat2.gif","お食事2",25,15],
["e116_gohan.gif","ご飯",13,13],
["e117_folk.gif","フォーク",13,13],
["s_eat03.gif","カレーライス",23,13],
["s_eat04.gif","ラーメン",20,16],
["s_eat06.gif","パスタ",20,18],
["s_eat07.gif","肉まん",20,20],
["s_eat08.gif","ドーナツ",20,18],
["s_eat09.gif","ぷりん",18,17],
["s_eat10.gif","おだんご",14,15],
["s_eat05.gif","鍋",20,13],
["s_eat12.gif","はんばーがー",18,14],
["n1item10.gif","カート",13,13],
["n1item11.gif","虫めがね",13,13],
["n1item12.gif","時計",13,13],
["n1item13.gif","旗",13,13],
["e_maiku.gif","カラオケ",13,13],
["e_tissue.gif","ティッシュ",13,13],
["e111_plug.gif","コンセント",13,13],
["e112_sentaku.gif","洗濯物",13,13],
["e126_aircon.gif","エアコン",15,15],
["e146_pc.gif","パソコン",24,14],
["e193_tv.gif","TV",11,13],
["e149_hasami.gif","はさみ",20,15],
["e150_memo.gif","メモ",15,15],
["e113_pencil.gif","えんぴつ",13,13],
["e151_jp.gif","日本",20,15],
["e157_hare.gif","はれ～",17,15],
["e158_kasa.gif","かさ",17,15],
["e136_teru.gif","てるてる",17,15],
["s_goods14.gif","ゆきだるま",19,20],
["e_snow.gif","スノーパターン",13,13],
["s_misc03.gif","ゆき",19,19],
["e206_eiga.gif","映画",22,10],
["s_parts_01.gif","サングラス",24,15],
["s_parts02.gif","緊急エイド",22,10],
["e172_ribon1.gif","赤いリボン",19,13],
["e173_ribon2.gif","ピンクリボン",19,13],
["e203_orantan.gif","オーランタン",24,16],
["s_animal22.gif","コウモリ",19,14],
["s_goods22.gif","菓子くれ",20,17],
["s_goods01.gif","リース",18,18],
["s_goods02.gif","柊",18,14],
["s_chara07.gif","サンタ",20,20],
["s_chara28.gif","となかい",18,16],
["s_goods04.gif","プレゼント",22,15],
["s_goods23.gif","五輪",25,12],
["s_goods24.gif","Gold",14,17],
["s_goods07.gif","クレヨン",21,14],
["s_goods08.gif","絵の具",16,15],
["s_goods05.gif","おそうじ",17,17],
["s_goods15.gif","おうち",17,16],
["s_goods25.gif","手袋",19,16],
["s_goods09.gif","年賀状",18,15],
["s_goods10.gif","おせち",19,16],
["s_goods11.gif","鏡もち",15,17],
["s_goods12.gif","元旦",11,18],
["s_goods28.gif","あかおに",18,19],
["s_goods26.gif","おだいりさま",20,20],
["s_goods27.gif","おひなさま",20,20],
["s_goods19.gif","こいのぼり",20,18],
["s_goods16.gif","信号",19,15],
["s_goods17.gif","ランドセル1",16,15],
["s_goods18.gif","ランドセル2",16,15],
["s_goods20.gif","ビーチサンダル",19,17],
["s_goods21.gif","風鈴",20,18],
["e154_car.gif","くるま",28,13],
["s_ride_03.gif","汽車頭",20,18],
["s_ride_04.gif","石炭車",20,18],
["s_ride_01.gif","汽車A",20,18],
["s_ride_02.gif","汽車B",20,18],
["s_ride_05.gif","電車A",20,18],
["s_ride_06.gif","電車B",20,18],
["s_ride07.gif","ロケット",24,13],
["s_ride08.gif","パトカー",22,15],
["s_ride09.gif","ふね",20,19],
["s_ride10.gif","ひこうき",19,13],
["s_chara06.gif","ガール",23,12],
["s_misc01.gif","なかよしブランコ",19,16],
["e181_ya1.gif","やぁ！",18,18],
["e183_ya3.gif","やぁ！お花",18,18],
["e184_ya4.gif","やぁ！ビキニ",18,18],
["e182_ya2.gif","やぁ！うきわ",20,20],
["s_chara08.gif","やぁ！サンタ",20,18],
["s_chara21.gif","マトちゃん",15,17],
["s_chara22.gif","マトちゃんいちご",15,17],
["s_chara23.gif","マトちゃんぶどう",15,17],
["s_chara24.gif","マトちゃんみかん",15,17],
["s_chara25.gif","マトちゃんめろん",15,17],
["e165_goma.gif","ごま1",20,13],
["e166_goma2.gif","ごま2",22,13],
["e175_tori.gif","とり",25,15],
["e176_rira.gif","リラ",22,13],
["s_chara11.gif","ごげたパン",19,13],
["s_chara15.gif","モノクロぶた",17,16],
["s_chara26.gif","かっぱ",20,16],
["s_chara_01.gif","きてい1",21,15],
["s_chara_02.gif","きてい2",21,15],
["s_chara09.gif","まいめろ",19,19],
["s_chara13.gif","シナモン",30,13],
["s_chara14.gif","モカ",30,13],
["s_chara16.gif","らって熊",24,15],
["s_chara27.gif","スカル",16,15],
["e202_anezu.gif","あのねずみ",16,12],
["s_chara17.gif","すてち",20,17],
["s_chara18.gif","えんじぇる",20,17],
["e101_kumapu.gif","くまぷー",13,13],
["e185_anpan.gif","あんぱん",17,13],
["e186_nupi.gif","ヌーピー",18,13],
["e187_pinga.gif","ぴんが",16,13],
["e188_pingu.gif","ぴんぐ～",16,13],
["s_chara12.gif","えるも",19,16],
["s_chara_03.gif","みふいー",16,17],
["s_chara04.gif","とろろ",15,18],
["s_chara05.gif","くろすけ",16,15],
["s_chara31.gif","ぽにょ",19,18],
["s_chara29.gif","りさ",15,18],
["s_chara30.gif","しば豆",17,14],
["s_chara10.gif","どられもん",20,18],
["s_chara19.gif","きたろう",20,19],
["s_chara20.gif","ぽけもん",20,17],
["e164_heart.gif","ハート1",20,15],
["e118_heart1.gif","ハート2",16,13],
["e119_heart2.gif","ハート3",13,13],
["s_pict13.gif","ハート4",13,13],
["s_pict17.gif","ハート5",13,13],
["s_pict15.gif","ハート6",13,13],
["e120_onpu1.gif","音符1",13,13],
["e121_onpu2.gif","音符2",13,13],
["e178_porange.gif","♪オレンジ",16,15],
["e179_pgreen.gif","♪グリーン",16,15],
["e180_ppink.gif","♪ピンク",16,15],
["n1item06.gif","nびっくり",13,13],
["n1item01.gif","n2重丸",13,13],
["n1item05.gif","nぐるぐる",13,13],
["e160_ya1.gif","右やじるし",15,15],
["e161_ya2.gif","左やじるし",15,15],
["e162_ya3.gif","下やじるし",13,15],
["e163_ya4.gif","上やじるし",13,15],
["e189_aka.gif","赤チェック1",12,12],
["e190_aka.gif","赤チェック2",14,14],
["e191_midori.gif","緑チェック",12,12],
["e196_aomigi2.gif","あお右２",17,15],
["e197_aohidari2.gif","あお左２",17,15],
["e200_akamigi2.gif","あか右２",17,15],
["e201_akahidari2.gif","あか左２",17,15],
["e148_down.gif","ダウン",20,15],
["e137_1.gif",":1",15,15],
["e138_2.gif",":2",15,15],
["e139_3.gif",":3",15,15],
["e141_vgood.gif","verygood",23,15],
["e127_batsu.gif","ばつ",15,15],
["e128_ll.gif","↑↑",15,15],
["s_pict_01.gif","グリーン○",17,16],
["s_pict_02.gif","ピンク○",17,16],
["s_pict_03.gif","ブルー○",17,16],
["s_pict12.gif","イエロー○",17,16],
["s_pict04.gif","キラキラ1",19,15],
["s_pict05.gif","キラキラ2",19,15],
["s_pict06.gif","キラキラ3",19,15],
["s_pict07.gif","キラキラ4",19,15],
["s_pict08.gif","☆1",14,14],
["s_pict09.gif","☆2",14,14],
["s_pict10.gif","メール",18,19],
["s_pict11.gif","メール2",18,13],
["s_kao_01.gif","あせり",22,14],
["s_kao_02.gif","え～",20,13],
["s_kao_03.gif","しくしく",20,13],
["s_kao_04.gif","だめ～",19,15],
["s_kao_05.gif","にっこり",20,13],
["s_kao_06.gif","ふーん",19,13],
["s_kao_07.gif","ワラ",18,13],
["s_kao08.gif","う～ん；",15,15],
["n1item03.gif","水滴",13,13],
["s_misc02.gif","ちょき",17,15]

/*
        [ "ファイル名", "説明", 幅, 高さ ],
        [ "ファイル名", "説明", 幅, 高さ ]
*/
    ];
    var i_file = 0;
    var i_alt = 1;
    var i_width = 2;
    var i_height = 3;
    var toolbarPosition = position;

    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';
        if (toolbarPosition == 1) {
            editorParent.insertBefore(iconDiv, editor);
        }
        else if (toolbarPosition == 2) {
            editorParent.appendChild(iconDiv);
        }
        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;
    };
}
