
var action_log_url = '/session/log';
var search_condition = {};
var school_jlist = {};
var school_search_max_row_per_page = 1000;
var school_search_current_page = 0;
var school_search_current_ct = 0;
var schools = Array();
var class1  = new Array('','大学','短大','専門学校','準看','その他');
var class2  = new Array('','国立','公立','私立','その他');
var pref    = new Array('','北海道','青森県','岩手県','宮城県','秋田県','山形県','福島県','茨城県','栃木県','群馬県','埼玉県','千葉県','東京都','神奈川県','新潟県','富山県','石川県','福井県','山梨県','長野県','岐阜県','静岡県','愛知県','三重県','滋賀県','京都府','大阪府','兵庫県','奈良県','和歌山県','鳥取県','島根県','岡山県','広島県','山口県','徳島県','香川県','愛媛県','高知県','福岡県','佐賀県','長崎県','熊本県','大分県','宮崎県','鹿児島県','沖縄県','外国','その他');


function action_log(action,log)
{
    var data = {
        action: action,
        log: log
    };
    
    $.ajax({
        type: "POST",
        url: action_log_url,
        data: data
    });
}



function show_login_dialog() {

}

function get_school_jlist() {
    $.getJSON("/school/jlist", function(json){
        schools = json['schools'];
        for (var i=0; i < schools.length; i++) {
            schools[i]['class1_cd'] -= 0;
            schools[i]['class2_cd'] -= 0;
            schools[i]['pref_cd']   -= 0;
            //schools[i]['lat']       -= 0;
            //schools[i]['lng']       -= 0;
            //schools[i]['recom']     -= 0;
            schools[i]['worker_apply'] -= 0;
            schools[i]['coeducation']  -= 0;
            schools[i]['visits']    -= 0;
            schools[i]['posts']     -= 0;
            schools[i]['comments']  -= 0;
            // 
            schools[i]['class1'] = class1[schools[i]['class1_cd']];
            schools[i]['class2'] = class2[schools[i]['class2_cd']];
            schools[i]['pref']   = pref[schools[i]['pref_cd']];
            schools[i]['href']   = 'info/'+schools[i]['school_id'];
        }
    });
}


function school_search_hide() {
    for( var i = 1 ; i <= school_search_current_ct; i++ ) {
        $('#school_'+i).hide();
    }
    $('#ss_results').hide();
}

function school_search_show() {
    for( var i = 1 ; i <= school_search_current_ct; i++ ) {
        $('#school_'+i).show();
    }
    $('#ss_results').text('検索条件に該当する看護学校は' + school_search_current_ct + '校です。').show();
}

function school_search_init()
{
    get_school_jlist();
    $(document).ready(function(){
        school_search_hide();
        $("#btn_search").bind('click',proc_school_search_event);
        $("#school_name").bind('change',proc_school_search_event);
        $("#class1_1").bind('change',proc_school_search_event);
        $("#class1_2").bind('change',proc_school_search_event);
        $("#class1_3").bind('change',proc_school_search_event);
        $("#class2_1").bind('change',proc_school_search_event);
        $("#class2_2").bind('change',proc_school_search_event);
        $("#class2_3").bind('change',proc_school_search_event);
        for( i = 1 ; i <= 47; i++ ) {
            $("#pref_" + i).bind('change',proc_school_search_event);
        }
        $("a[rel='external']").click(function(){
            this.target = "_blank";
        });
    });
}


function proc_school_search_event(ev)
{
    school_search_hide();
action_log('test_action','test_data');
    var lid = 1;
    
    var sn      = $("#school_name").val();
    
    var cl1_1   = $("#class1_1").attr("checked");
    var cl1_2   = $("#class1_2").attr("checked");
    var cl1_3   = $("#class1_3").attr("checked");
    var cl1_flg = cl1_1 | cl1_2 | cl1_3;
    var cl2_1   = $("#class2_1").attr("checked");
    var cl2_2   = $("#class2_2").attr("checked");
    var cl2_3   = $("#class2_3").attr("checked");
    var cl2_flg = cl2_1 | cl2_2 | cl2_3;
    
    var pf = new Array(48);
    var pf_flg = false;
    var i, flg;
    var elem;
    
    for( i = 1 ; i <= 47; i++ ) {
        if( $("#pref_"+i).attr("checked") ) {
            pf[i] = pf_flg = true;
        }
        else {
            pf[i] = false;
        }
    }
    
    if ( sn.length === 0 && !cl1_flg && !cl2_flg && !pf_flg) {
        return;
    }
    
    for( i = 0 ; i < schools.length; i++ ) {
        flg = true;
        
        if( flg && sn.length !== 0 && 
            schools[i]['school_name'].indexOf(sn) == -1 ) {
            flg = false;
        }
        
        if (flg && cl1_flg) {
            if (schools[i]['class1_cd'] == 1 && !cl1_1) {
                flg = false;
            }
            else if (schools[i]['class1_cd'] == 2 && !cl1_2) {
                flg = false;
            }
            else if (schools[i]['class1_cd'] == 3 && !cl1_3) {
                flg = false;
            }
        }
        
        if (flg && cl2_flg) {
            if (schools[i]['class2_cd'] == 1 && !cl2_1) {
                flg = false;
            }
            else if (schools[i]['class2_cd'] == 2 && !cl2_2) {
                flg = false;
            }
            else if (schools[i]['class2_cd'] == 3 && !cl2_3) {
                flg = false;
            }
        }
        
        if( flg && pf_flg &&
            pf[schools[i]['pref_cd']] === false ) {
            flg = false;
        }
        
        if( flg && lid <= school_search_max_row_per_page ) {
            elem = $("#school_" + lid);
            elem.find("[name='class1']").text(schools[i]['class1']);
            elem.find("[name='class2']").text(schools[i]['class2']);
            elem.find("[name='school_name']").text(schools[i]['school_name']);
            elem.find("[name='school_name']").attr('href',schools[i]['href']);
            elem.find("[name='onenote']").text(schools[i]['onenote']);
            elem.find("[name='course']").text(schools[i]['course']);
            elem.find("[name='pref']").text(schools[i]['pref']);
            elem.find("[name='city']").text(schools[i]['city']);
            elem.find("[name='recom']").text(schools[i]['recom']);
            elem.find("[name='comments']").text(schools[i]['comments']);
            if (schools[i]['coeducation'] == 1) {
                elem.find("[name='coeducation']").text('共学');
            }
            if (schools[i]['recom'] == '有') {
                elem.find("[name='recom']").text('推薦');
            }else {
                elem.find("[name='recom']").text('');
            }
            if (schools[i]['worker_apply'] == 1) {
                elem.find("[name='worker_apply']").text('社会人');
            }else {
                elem.find("[name='worker_apply']").text('');
            }
            lid++;
        }
    }
    
    school_search_current_ct = lid - 1;
    school_search_show();
}


function school_info_init()
{
    $(document).ready(function(){

        var lat = document.getElementById("gp_lat").value;
        var lng = document.getElementById("gp_lng").value;
        var pos;
        var map_options;
        var map;
        var marker;

        //try{
        //    $("#content_nje").nje();
        //    $("#content_nje").nje_setIcon();
        //    $("#content_nje").nje_setContent();
        //}
        //catch(e){
        //    alert(e);
        //}

        //$("#school_info_tabs_nav li").css("margin","0 .2em 1px 0");
        $("#school_info_tabs_nav li").css("margin","0");
        $("#school_info_tabs_nav a").click( function(e) {
            var ul = $(this).parent()[0];
            if ( ul.id == "school_info_nav_map") {
                var timeout = 0;
                if (!pos) {
                    pos = new google.maps.LatLng(lat,lng);
                    map_options = {
                        zoom: 13,
                        center: pos,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
                    map = new google.maps.Map($("#school_info_map")[0], map_options);
                    marker = new google.maps.Marker({
                        position: pos,
                        map: map,
                        icon: '/img/mark.png'
                    });
                    
                    //var adsManagerOptions = {
                    //    maxAdsOnMap : 3,
                    //    style: 'adunit',
                    //};
                    //adsManager = new GAdsManager(map, google_ad_client, adsManagerOptions);
                    //adsManager.enable();
                }
            }
        });

        $('#school_info_tabs').tabs();
        
        $('#si_btn_new_post').button().click(
            function() {
                $('#nje').nje('type2');
            }
        );
    });


}





function select_click(evt)
{
    var pobj = jQuery(evt.target).closest('tr');
    var cobj = jQuery(evt.target).closest('td');
    var pid = pobj.get(0).id;
    var cid = cobj.get(0).id;
//alert("pobj="+pobj+" cobj="+cobj+" pid="+pid+" cid="+cid);
    if( ! cid ) {
        search_reset("");
        return false;
    }
    
    search_reset( cid );
    
    for( var key in search_condition ) {
        if( key.match("_states$") ) {
            var states = search_condition[key];
            for( var key2 in states ) {
                if( key2 === cid ) {
                    if( states[key2] ) {
                        jQuery("#"+key2).removeClass(on_class).addClass(hover_on_class);
                        states[key2] = false;
                    }
                    else {
                        jQuery("#"+key2).removeClass(off_class).removeClass(hover_on_class).addClass(on_class);
                        states[key2] = true;
                    }
                    var key3 = key.replace("_states","_multi");
                    if( ! search_condition[key3] ) {
                        for( var key4 in states ) {
                            if( key4 !== cid ) {
                                jQuery("#"+key4).removeClass(on_class).addClass(off_class);
                                states[key4] = false;
                            }
                        }
                    }
                    return true;
                }
            }
        }
    }
    return false;
}

function select_hover_on(evt)
{
    var pobj = jQuery(evt.target).closest('tr');
    var cobj = jQuery(evt.target).closest('td');
    var pid = pobj.get(0).id;
    var cid = cobj.get(0).id;
    if( ! cid ) {
        search_reset("");
        return false;
    }
    
    search_reset( cid );
    
    for( var key in search_condition ) {
        if( key.match("_states$") ) {
            var states = search_condition[key];
            for( var key2 in states ) {
                if( key2 === cid ) {
                    if( ! states[key2] ) {
                        jQuery("#"+key2).removeClass(off_class).addClass(hover_on_class);
                    }
                    return true;
                }
            }
        }
    }
    return false;
}

function select_hover_out(evt)
{
    var pobj = jQuery(evt.target).closest('tr');
    var cobj = jQuery(evt.target).closest('td');
    var pid = pobj.get(0).id;
    var cid = cobj.get(0).id;
    if( ! cid ) {
        search_reset("");
        return false;
    }
    
    search_reset( cid );
    
    for( var key in search_condition ) {
        if( key.match("_states$") ) {
            var states = search_condition[key];
            for( var key2 in states ) {
                if( key2 === cid ) {
                    if( ! states[key2] ) {
                        jQuery("#"+key2).removeClass(hover_on_class).addClass(off_class);
                    }
                    return true;
                }
            }
        }
    }
    return true;
}

function search_reset(cid)
{
    for( var key in search_condition ) {
        if( key.match("_states$") ) {
            var states = search_condition[key];
            for( var key2 in states ) {
                if( key2 !== cid ) {
                    if( states[key2] ) {
                        jQuery("#"+key2).removeClass(off_class).addClass(on_class);
                    }
                    else {
                        jQuery("#"+key2).removeClass(on_class).addClass(off_class);
                    }
                }
            }
        }
    }
}

function action_search()
{
    var data = "";
    for( var key in search_condition ) {
        if( key.match("_states$") ) {
            var states = search_condition[key];
            for( var key2 in states ) {
                if( states[key2] ) {
                    data += key2 + "=true,";
                }
                else {
                    data += key2 + "=false,";
                }
            }
        }
    }
//  jQuery.getJSON( "#", data, function() {return true;} );
//alert("data="+data);
    document.forms['search_form'].elements['search_strings'].value = data;
    return true;
}

function action_reset()
{
    for( var key in search_condition ) {
        if( key.match("_states$") ) {
            var states = search_condition[key];
            for( var key2 in states ) {
                states[key2] = false;
            }
        }
    }
    search_reset("");
}

/*
jQuery(document).ready(function(){
    var ss = jQuery("#search_strings").get(0).value;
    for( var key in search_condition ) {
        if( key.match("_states$") ) {
            var states = search_condition[key];
            for( var key2 in states ) {
                if( ss.match(".*" + key2+"=true") ) {
                    states[key2] = true;
                }
            }
        }
    }
    for( var key in search_condition ) {
        if( key.match("_states$") ) {
            var states = search_condition[key];
            for( var key2 in states ) {
                jQuery("#"+key2).click(select_click);
                jQuery("#"+key2).hover(select_hover_on,select_hover_out);
                for( var key3 in initial_search_condition ) {
                    if( key2 === key3 ) {
                        states[key2] = initial_search_condition[key3];
                    }
                }
            }
        }
    }
    jQuery("#search_select").hover(search_reset);
    jQuery("#btn_search").click(action_search);
    jQuery("#btn_reset").click(action_reset);
    jQuery("#search_form").submit(action_search);
});
*/

var on_class  = "select_on";
var off_class = "select_off";
var hover_on_class  = "select_hover_on";

(function( $ )
{
    $.fn.document = function()
    {
        var element = this.get(0);

        if ( element.nodeName.toLowerCase() == 'iframe' )
        {
            return element.contentWindow.document;
            /*
            return ( $.browser.msie )
                ? document.frames[element.id].document
                : element.contentWindow.document // contentDocument;
             */
        }
        return this;
    };

    $.fn.documentSelection = function()
    {
        var element = this.get(0);

        if ( element.contentWindow.document.selection ) {
            return element.contentWindow.document.selection.createRange().text;
        }
        else {
            return element.contentWindow.getSelection().toString();
        }
    };

    $.fn.editor = function( options )
    {
        if ( arguments.length > 0 && arguments[0].constructor == String )
        {
            var action = arguments[0].toString();
            var params = [];

            for ( var i = 1; i < arguments.length; i++ ) {
                params[i - 1] = arguments[i];
            }

            if ( action in Wysiwyg )
            {
                return this.each(function()
                {
                    $.data(this, 'editor').designMode();
                    Wysiwyg[action].apply(this, params);
                });
            }
            else {
                return this;
            }
        }

        var controls = {};

        /**
         * If the user set custom controls, we catch it, and merge with the
         * defaults controls later.
         */
        if ( options && options.controls )
        {
            controls = options.controls;
            delete options.controls;
        }

        options = $.extend({
            html : '<'+'?xml version="1.0" encoding="UTF-8"?'+'><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">STYLE_SHEET</head><body style="margin: 0px;">INITIAL_CONTENT</body></html>',
            css  : {},
            debug        : false,
            autoSave     : true,
            rmUnwantedBr : true,
            brIE         : true,
            controls : {},
            messages : {}
        }, options);

        options.messages = $.extend(true, options.messages, Wysiwyg.MSGS_EN);
        options.controls = $.extend(true, options.controls, Wysiwyg.TOOLBAR);

        for ( var control in controls )
        {
            if ( control in options.controls ) {
                $.extend(options.controls[control], controls[control]);
            }
            else {
                options.controls[control] = controls[control];
            }
        }

        // not break the chain
        return this.each(function()
        {
            Wysiwyg(this, options);
        });
    };

    function Wysiwyg( element, options )
    {
        return this instanceof Wysiwyg ? this.init(element, options) : new Wysiwyg(element, options);
    }

    $.extend(Wysiwyg, {
        insertImage : function( szURL, attributes )
        {
            var self = $.data(this, 'editor');

            if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
            {
                if ($.browser.msie) {
                    self.focus();
                }
                if ( attributes )
                {
                    self.editorDoc.execCommand('insertImage', false, '#jeditor#');
                    var img = self.getElementByAttributeValue('img', 'src', '#jeditor#');

                    if ( img )
                    {
                        img.src = szURL;

                        for ( var attribute in attributes )
                        {
                            img.setAttribute(attribute, attributes[attribute]);
                        }
                    }
                }
                else
                {
                    self.editorDoc.execCommand('insertImage', false, szURL);
                }
            }
        },

        createLink : function( szURL )
        {
            var self = $.data(this, 'editor');

            if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
            {
                var selection = $(self.editor).documentSelection();

                if ( selection.length > 0 )
                {
                    if ($.browser.msie) {
                        self.focus();
                    }
                    self.editorDoc.execCommand('unlink', false, []);
                    self.editorDoc.execCommand('createLink', false, szURL);
                }
                else if ( self.options.messages.nonSelection ) {
                    alert(self.options.messages.nonSelection);
                }
            }
        },

        insertHtml : function( szHTML )
        {
            var self = $.data(this, 'editor');

            if ( self.constructor == Wysiwyg && szHTML && szHTML.length > 0 )
            {
                if ($.browser.msie)
                {
                    self.focus();
                    self.editorDoc.execCommand('insertImage', false, '#jeditor#');
                    var img = self.getElementByAttributeValue('img', 'src', '#jeditor#');
                    if (img)
                    {
                        $(img).replaceWith(szHTML);
                    }
                }
                else
                {
                    self.editorDoc.execCommand('insertHTML', false, szHTML);
                }
            }
        },

        setContent : function( newContent )
        {
            var self = $.data(this, 'editor');
                self.setContent( newContent );
                self.saveContent();
        },

        clear : function()
        {
            var self = $.data(this, 'editor');
                self.setContent('');
                self.saveContent();
        },

        MSGS_EN : {
            nonSelection : 'select the text you wish to link'
        },

        TOOLBAR : {
            bold          : { visible : true, tags : ['b', 'strong'], css : { fontWeight : 'bold' }, tooltip : "太字" },
            italic        : { visible : true, tags : ['i', 'em'], css : { fontStyle : 'italic' }, tooltip : "斜体" },
            strikeThrough : { visible : true, tags : ['s', 'strike'], css : { textDecoration : 'line-through' }, tooltip : "取消し線" },
            underline     : { visible : true, tags : ['u'], css : { textDecoration : 'underline' }, tooltip : "下線" },            insertOrderedList    : { visible : true, tags : ['ol'], tooltip : "番号リスト" },
            insertUnorderedList  : { visible : true, tags : ['ul'], tooltip : "リスト" },
            insertHorizontalRule : { visible : true, tags : ['hr'], tooltip : "区切り線" },

            createLink : {
                visible : true,
                exec    : function()
                {
                    var selection = $(this.editor).documentSelection();

                    if ( selection.length > 0 )
                    {
                        if ( $.browser.msie )
                        {
                            this.focus();
                            this.editorDoc.execCommand('createLink', true, null);
                        }
                        else
                        {
                            var szURL = prompt('URL', 'http://');

                            if ( szURL && szURL.length > 0 )
                            {
                                this.editorDoc.execCommand('unlink', false, []);
                                this.editorDoc.execCommand('createLink', false, szURL);
                            }
                        }
                    }
                    else if ( this.options.messages.nonSelection ) {
                        alert(this.options.messages.nonSelection);
                    }
                },

                tags : ['a'],
                tooltip : "リンクを挿入"
            },

            h1mozilla : { visible : true && $.browser.mozilla, className : 'h1', command : 'heading', arguments : ['h1'], tags : ['h1'], tooltip : "タイトル" },
            h2mozilla : { visible : true && $.browser.mozilla, className : 'h2', command : 'heading', arguments : ['h2'], tags : ['h2'], tooltip : "見出し" },
            h1 : { visible : true && !( $.browser.mozilla ), className : 'h1', command : 'formatBlock', arguments : ['<H1>'], tags : ['h1'], tooltip : "タイトル" },
            h2 : { visible : true && !( $.browser.mozilla ), className : 'h2', command : 'formatBlock', arguments : ['<H2>'], tags : ['h2'], tooltip : "見出し" }
        }
    });

    $.extend(Wysiwyg.prototype,
    {
        original : null,
        options  : {},

        element  : null,
        editor   : null,

        focus : function()
        {
            $(this.editorDoc.body).focus();
        },

        init : function( element, options )
        {
            var self = this;

            this.editor = element;
            this.options = options || {};

            $.data(element, 'editor', this);

            var newX = element.width || element.clientWidth;
            var newY = element.height || element.clientHeight;

            if ( element.nodeName.toLowerCase() == 'textarea' )
            {
                this.original = element;

                if ( newX == 0 && element.cols )
                    newX = ( element.cols * 8 ) + 21;

                if ( newY == 0 && element.rows )
                    newY = ( element.rows * 16 ) + 16;

                var editor = this.editor = $('<iframe src="javascript:false;"></iframe>').css({
                    minHeight : ( newY - 6 ).toString() + 'px',
                    width     : ( newX - 8 ).toString() + 'px'
                }).attr('id', $(element).attr('id') + 'IFrame')
                .attr('frameborder', '0');

                this.editor.attr('tabindex', $(element).attr('tabindex'));

                if ( $.browser.msie )
                {
                    this.editor
                        .css('height', ( newY ).toString() + 'px');

                    /**
                    var editor = $('<span></span>').css({
                        width     : ( newX - 6 ).toString() + 'px',
                        height    : ( newY - 8 ).toString() + 'px'
                    }).attr('id', $(element).attr('id') + 'IFrame');

                    editor.outerHTML = this.editor.outerHTML;
                     */
                }
            }

            var panel = this.panel = $('<ul role="menu" class="panel"></ul>');

            this.appendControls();
            this.element = $('<div></div>').css({
                width : ( newX > 0 ) ? ( newX ).toString() + 'px' : '100%'
            }).addClass('editor')
                .append(panel)
                .append( $('<div><!-- --></div>').css({ clear : 'both' }) )
                .append(editor)
        ;

            $(element)
                .hide()
                .before(this.element)
        ;

            this.viewHTML = false;
            this.initialHeight = newY - 8;

            this.initialContent = $(element).val();
            this.initFrame();

            if ( this.initialContent.length == 0 )
                this.setContent('');

            var form = $(element).closest('form');

            if ( this.options.autoSave )
        {
                form.submit(function() { self.saveContent(); });
        }

            form.bind('reset', function()
            {
                self.setContent( self.initialContent );
                self.saveContent();
            });
        },

        initFrame : function()
        {
            var self = this;
            var style = '';

            if ( this.options.css && this.options.css.constructor == String )
        {
                style = '<link rel="stylesheet" type="text/css" media="screen" href="' + this.options.css + '" />';
        }

            this.editorDoc = $(this.editor).document();
            this.editorDoc_designMode = false;

            try {
                this.editorDoc.designMode = 'on';
                this.editorDoc_designMode = true;
            } catch ( e ) {
                // Will fail on Gecko if the editor is placed in an hidden container element
                // The design mode will be set ones the editor is focused

                $(this.editorDoc).focus(function()
                {
                    self.designMode();
                });
            }

            this.editorDoc.open();
            this.editorDoc.write(
                this.options.html
                    .replace(/INITIAL_CONTENT/, function() { return self.initialContent; })
                    .replace(/STYLE_SHEET/, function() { return style; })
            );
            this.editorDoc.close();

            this.editorDoc.contentEditable = 'true';

            if ( $.browser.msie )
            {
                /**
                 * Remove the horrible border it has on IE.
                 */
                setTimeout(function() { $(self.editorDoc.body).css('border', 'none'); }, 0);
            }

            $(this.editorDoc).click(function( event )
            {
                self.checkTargets( event.target ? event.target : event.srcElement);
            });

            $(this.original).focus(function()
            {
                if (!$.browser.msie)
                {
                    self.focus();
                }
            });

            if ( this.options.autoSave )
            {
                $(this.editorDoc).keydown(function() { self.saveContent(); })
                                 .keyup(function() { self.saveContent(); })
                                 .mousedown(function() { self.saveContent(); });
            }

            if ( this.options.css )
            {
                setTimeout(function()
                {
                    if ( self.options.css.constructor == String )
                    {
                        /**
                         * $(self.editorDoc)
                         * .find('head')
                         * .append(
                         *     $('<link rel="stylesheet" type="text/css" media="screen" />')
                         *     .attr('href', self.options.css)
                         * );
                         */
                    }
                    else
                        $(self.editorDoc).find('body').css(self.options.css);
                }, 0);
            }

            $(this.editorDoc).keydown(function( event )
            {
                if ( $.browser.msie && self.options.brIE && event.keyCode == 13 )
                {
                    var rng = self.getRange();
                    rng.pasteHTML('<br />');
                    rng.collapse(false);
                    rng.select();
                    return false;
                }
                return true;
            });
        },

        designMode : function()
        {
            if ( !( this.editorDoc_designMode ) )
            {
                try {
                    this.editorDoc.designMode = 'on';
                    this.editorDoc_designMode = true;
                } catch ( e ) {}
            }
        },

        getSelection : function()
        {
            return ( window.getSelection ) ? window.getSelection() : document.selection;
        },

        getRange : function()
        {
            var selection = this.getSelection();

            if ( !( selection ) )
                return null;

            return ( selection.rangeCount > 0 ) ? selection.getRangeAt(0) : selection.createRange();
        },

        getContent : function()
        {
            return $( $(this.editor).document() ).find('body').html();
        },

        setContent : function( newContent )
        {
            $( $(this.editor).document() ).find('body').html(newContent);
        },

        saveContent : function()
        {
            if ( this.original )
            {
                var content = this.getContent();

                if ( this.options.rmUnwantedBr )
        {
                    content = ( content.substr(-4) == '<br>' ) ? content.substr(0, content.length - 4) : content;
        }

                $(this.original).val(content);
            }
        },

        withoutCss: function()
        {
            if ($.browser.mozilla)
            {
                try
                {
                    this.editorDoc.execCommand('styleWithCSS', false, false);
                }
                catch (e)
                {
                    try
                    {
                        this.editorDoc.execCommand('useCSS', false, true);
                    }
                    catch (e)
                    {
                    }
                }
            }
        },

        appendMenu : function( cmd, args, className, fn, tooltip )
        {
            var self = this;
            args = args || [];

            $('<li></li>').append(
                $('<a role="menuitem" tabindex="-1" href="javascript:;">' + (className || cmd) + '</a>')
                    .addClass(className || cmd)
                    .attr('title', tooltip)
            ).click(function() {
                if ( fn ) fn.apply(self); else
                {
                    self.withoutCss();
                    self.editorDoc.execCommand(cmd, false, args);
                }
                if ( self.options.autoSave ) self.saveContent();
            }).appendTo( this.panel );
        },

        appendMenuSeparator : function()
        {
            $('<li role="separator" class="separator"></li>').appendTo( this.panel );
        },

        appendControls : function()
        {
            for ( var name in this.options.controls )
            {
                var control = this.options.controls[name];

                if ( control.separator )
                {
                    if ( control.visible !== false )
                        this.appendMenuSeparator();
                }
                else if ( control.visible )
                {
                    this.appendMenu(
                        control.command || name, control.arguments || [],
                        control.className || control.command || name || 'empty', control.exec,
                        control.tooltip || control.command || name || ''
                    );
                }
            }
        },

        checkTargets : function( element )
        {
            for ( var name in this.options.controls )
            {
                var control = this.options.controls[name];
                var className = control.className || control.command || name || 'empty';

                $('.' + className, this.panel).removeClass('active');

                if ( control.tags )
                {
                    var elm = element;

                    do {
                        if ( elm.nodeType != 1 )
                            break;

                        if ( $.inArray(elm.tagName.toLowerCase(), control.tags) != -1 )
                            $('.' + className, this.panel).addClass('active');
                    } while ((elm = elm.parentNode));
                }

                if ( control.css )
                {
                    var elm = $(element);

                    do {
                        if ( elm[0].nodeType != 1 )
                            break;

                        for ( var cssProperty in control.css )
                            if ( elm.css(cssProperty).toString().toLowerCase() == control.css[cssProperty] )
                                $('.' + className, this.panel).addClass('active');
                    } while ((elm = elm.parent()));
                }
            }
        },

        getElementByAttributeValue : function( tagName, attributeName, attributeValue )
        {
            var elements = this.editorDoc.getElementsByTagName(tagName);

            for ( var i = 0; i < elements.length; i++ )
            {
                var value = elements[i].getAttribute(attributeName);

                if ( $.browser.msie )
                {
                    /** IE add full path, so I check by the last chars. */
                    value = value.substr(value.length - attributeValue.length);
                }

                if ( value == attributeValue )
                    return elements[i];
            }

            return false;
        }
    });
})(jQuery);



(function ($)
{
    $.fn.bgiframe = ($.browser.msie && /msie 6\.0/i.test(navigator.userAgent) ? function (s) 
    {
        s = $.extend(
        {
            top : 'auto', // auto == .currentStyle.borderTopWidth
            left : 'auto', // auto == .currentStyle.borderLeftWidth
            width : 'auto', // auto == offsetWidth
            height : 'auto', // auto == offsetHeight
            opacity : true,
            src : 'javascript:false;' 
        }, s);
        var html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' + 'style="display:block;position:absolute;z-index:-1;' + (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') + 'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' + 'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' + 'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' + 'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' + '"/>';
        return this.each(function () 
        {
            if ( $(this).children('iframe.bgiframe').length === 0 ) {
                this.insertBefore( document.createElement(html), this.firstChild );
            }
        });
    }
     : function () 
    {
        return this;
    });
    // old alias
    $.fn.bgIframe = $.fn.bgiframe;
    function prop(n) 
    {
        return n && n.constructor === Number ? n + 'px' : n;
    }
})(jQuery);



(function ($)
{
    $.fn.jqDrag = function (h)
    {
        return i(this, h, "d");
    };
    $.fn.jqResize = function (h)
    {
        return i(this, h, "r");
    };
    $.jqDnR = 
    {
        dnr : {}, e : 0,
        drag : function (v)
        {
            if (M.k == "d") {
                E.css({
                    left : M.X + v.pageX - M.pX, top : M.Y + v.pageY - M.pY
                })
            }
            else
            {
                E.css({
                    width : Math.max(v.pageX - M.pX + M.W, 200), height : Math.max(v.pageY - M.pY + M.H, 
                    100)
                })
            }
            return false;
        },
        stop : function ()
        {
            $(E).unbind("mousemove", J.drag).unbind("mouseup", J.stop)
        }
    };
    var J = $.jqDnR, M = J.dnr, E = J.e, i = function (e, h, k)
    {
        return e.each(function ()
        {
            h = (h) ? $(h, e) : e;
            h.bind("mousedown", {
                e : e, k : k
            },
            function (v)
            {
                var d = v.data, p = {};
                E = d.e;
                if (E.css("position") != "relative") {
                    try {
                        E.position(p)
                    }
                    catch (e) {}
                }
                M = 
                {
                    X : p.left || f("left") || 0, Y : p.top || f("top") || 0, W : f("width") || E[0].scrollWidth || 0, 
                    H : f("height") || E[0].scrollHeight || 0, pX : v.pageX, pY : v.pageY, k : d.k, o : E.css("opacity")
                };
                $(E).mousemove($.jqDnR.drag).mouseup($.jqDnR.stop).mousedown($.jqDnR.stop);
                return false;
            })
        })
    },
    f = function (k)
    {
        return parseInt(E.css(k)) || false;
    }
})(jQuery);



$.jQpopup = 
{
    minHeight : 100, minWidth : 200, imagePath : "img/", popupwrapper : null,
    box : function (object_id)
    {
        var popupwrapper = '<div id="' + object_id + '_p" class="jqpopup">';
        popupwrapper += '<div class="jqpopup_header"><div id="' + object_id + '_ph"></div>';
        popupwrapper += "<div>";
        popupwrapper += '<div id="' + object_id + '_pl" class="jqpopup_center"></div>';
        popupwrapper += '<div id="' + object_id + '_px" class="jqpopup_cross"></div>';
        popupwrapper += "</div>";
        popupwrapper += "</div>";
        popupwrapper += '<div id="' + object_id + '_pm" class="jqpopup_message"></div>';
        popupwrapper += '<div id="' + object_id + '_pc" class="jqpopup_content"></div>';
        popupwrapper += '<div id="' + object_id + '_pf" class="jqpopup_footer"></div>';
        popupwrapper += '<div id="' + object_id + '_ps" class="jqpopup_resize"></div>';
        popupwrapper += "</div>";
        return popupwrapper;
    },
    toTopEvent : function (e)
    {
        var rid = (this.id).substr(0, this.id.length - 1);
        var zMax = 0;
        $(".jqpopup").each(function (index)
        {
            if ($(this).css("zIndex") > zMax) {
                zMax = $(this).css("zIndex")
            }
        });
        var val = parseInt(zMax) + 1;
        $("#" + rid).css("zIndex", val)
    },
    toTop : function (id)
    {
        var str = id.substr(id.length - 2);
        var rid = id;
        if (str != "_p") {
            rid += "_p"
        }
        var zMax = 0;
        $(".jqpopup").each(function (index)
        {
            if ($(this).css("zIndex") > zMax) {
                zMax = $(this).css("zIndex")
            }
        });
        var val = parseInt(zMax) + 1;
        $("#" + rid).css("zIndex", val)
    },
    toCenter : function (id)
    {
        var top = parseInt($(window).scrollTop());
        var left = parseInt($(window).scrollLeft());
        var rid = id + "_p";
        var pos = $("#" + rid).offset();
        var box_x = parseInt($("#" + rid).width());
        var box_y = parseInt($("#" + rid).height());
        var center_x = parseInt($(window).width()) / 2 - box_x / 2 + left;
        var center_y = parseInt($(window).height()) / 2 - box_y / 2 + top;
        $("#" + rid).css({
            left : center_x, top : center_y
        })
    },
    open : function (button_id, object_id)
    {
        if ($("#" + object_id).html() != "")
        {
            var content = $.jQpopup.box(object_id);
            $("body").append(content);
            $("#" + object_id + "_p").bgiframe();
            $("#" + object_id + "_p").jqDrag(".jqpopup_header").jqResize(".jqpopup_resize");
            $("#" + object_id + "_px").unbind("click");
            $("#" + object_id + "_px").bind("click", function ()
            {
                $("#" + object_id).jqpopup_close()
            });
            $("#" + object_id + "_pl").unbind("click");
            $("#" + object_id + "_pl").bind("click", function ()
            {
                $("#" + object_id).jqpopup_toCenter(this.id)
            });
            var pos = $("#" + button_id).offset();
            var popup_x = parseInt(pos.left) + (parseInt($("#" + button_id).width() / 2));
            var popup_y = parseInt(pos.top) + parseInt($("#" + button_id).height());
            $("#" + object_id + "_p").css({
                left : popup_x, top : popup_y
            });
            var popup_content = $("#" + object_id).clone(true);
            var title = $("#" + object_id).attr("title");
            $("#" + object_id + "_ph").html(title);
            $("#" + object_id + "_pc").html(popup_content.show());
            $("#" + object_id + "_p").show();
            $("#" + object_id + "_ph").mousedown($.jQpopup.toTopEvent);
            $("#" + object_id).empty();
            if ($("#" + object_id + "_p").height() < $.jQpopup.minHeight) {
                $("#" + object_id + "_p").css("height", $.jQpopup.minHeight + 14)
            }
            else {
                $("#" + object_id + "_p").css("height", $("#" + object_id + "_p").height() + 14)
            }
            if ($("#" + object_id + "_p").width() < $.jQpopup.minWidth) {
                $("#" + object_id + "_p").css("width", $.jQpopup.minWidth)
            }
            $("#" + object_id + "_p").jqpopup_toTop()
        }
    },
    close : function (object_id)
    {
        var content = $("#" + object_id + "_pc").clone(true);
        $("#" + object_id).html(content.show());
        $("#" + object_id + "_pc").empty();
        $("#" + object_id + "_p").hide()
    }
};
$.fn.extend(
{
    jqpopup_close : function ()
    {
        return this.each(function ()
        {
            $.jQpopup.close(this.id)
        })
    },
    jqpopup_open : function (button_id)
    {
        return this.each(function ()
        {
            $.jQpopup.open(button_id, this.id)
        })
    },
    jqpopup_toCenter : function ()
    {
        return this.each(function ()
        {
            $.jQpopup.toCenter(this.id)
        })
    },
    jqpopup_toTop : function ()
    {
        return this.each(function ()
        {
            $.jQpopup.toTop(this.id)
        })
    }
});



$.jQCP = 
{
    imagePath : "img/c_tuner.png", prefix : "", colorObj : null,
    init : function (id)
    {
        var prefix = $.jQCP.prefix;
        var str = '<table class="jqcp_table"><tr>';
        str += '<td><div id="' + prefix + 'jqcp" class="jqcp"><div id="' + prefix + 'marker" class="jqcpmarker"></div></div></td>';
        str += '<td><div id="' + prefix + 'jqbr" class="jqbr"></td>';
        str += '<td><div id="' + prefix + 'jqbrp" class="jqbrp"><div id="' + prefix + 'c_point" class="jqbrpointer"></div></div></td>';
        str += "</tr></table>";
        $("#" + id).html(str);
        $("#" + prefix + "jqcp").click(function (e)
        {
            $.jQCP.clickCp(e.pageX, e.pageY)
        });
        $("#" + prefix + "jqbr").click(function (e)
        {
            $.jQCP.clickBp(e.pageX, e.pageY)
        });
        $("#" + prefix + "jqcp_h").keyup(function (e)
        {
            if ($.jQCP.validHSL($("#" + prefix + "jqcp_h").val(), "jqcp_h")) {
                $.jQCP.setHsl()
            }
        });
        $("#" + prefix + "jqcp_s").keyup(function (e)
        {
            if ($.jQCP.validHSL($("#" + prefix + "jqcp_s").val(), "jqcp_s")) {
                $.jQCP.setHsl()
            }
        });
        $("#" + prefix + "jqcp_l").keyup(function (e)
        {
            if ($.jQCP.validHSL($("#" + prefix + "jqcp_l").val(), "jqcp_l")) {
                $.jQCP.setHsl()
            }
        });
        $("#" + prefix + "jqcp_r").keyup(function (e)
        {
            if ($.jQCP.validRGB($("#" + prefix + "jqcp_r").val(), "jqcp_r")) {
                $.jQCP.setRGB()
            }
        });
        $("#" + prefix + "jqcp_g").keyup(function (e)
        {
            if ($.jQCP.validRGB($("#" + prefix + "jqcp_g").val(), "jqcp_g")) {
                $.jQCP.setRGB()
            }
        });
        $("#" + prefix + "jqcp_b").keyup(function (e)
        {
            if ($.jQCP.validRGB($("#" + prefix + "jqcp_b").val(), "jqcp_b")) {
                $.jQCP.setRGB()
            }
        });
        $(".jqcp_value").click(function (e)
        {
            $.jQCP.colorObj = this.id;
            $.jQCP.HextoRGB()
        });
        $.jQCP.setCpPos();
        $.jQCP.setBpPos()
    },
    validHSL : function (value, obj)
    {
        if (!isNaN(value))
        {
            if (value > 240) {
                $("#" + $.jQCP.prefix + obj).val(240)
            }
            else {
                if (value < 0) {
                    $("#" + $.jQCP.prefix + obj).val(0)
                }
            }
            return true
        }
        return false;
    },
    validRGB : function (value, obj)
    {
        if (!isNaN(value))
        {
            if (value > 255) {
                $("#" + $.jQCP.prefix + obj).val(255)
            }
            else {
                if (value < 0) {
                    $("#" + $.jQCP.prefix + obj).val(0)
                }
            }
            return true
        }
        return false;
    },
    setCpPos : function ()
    {
        var pos = $("#" + $.jQCP.prefix + "jqcp").offset();
        var x = parseInt($("#" + $.jQCP.prefix + "jqcp_h").val()) - 4;
        var y = 240 - parseInt($("#" + $.jQCP.prefix + "jqcp_s").val()) - 4;
        $("#" + $.jQCP.prefix + "marker").css({
            position : "relative", zIndex : 5000, left : x + "px", top : y + "px"
        })
    },
    setBpPos : function ()
    {
        var pos = $("#" + $.jQCP.prefix + "jqbrp").offset();
        var y = 240 - parseInt($("#" + $.jQCP.prefix + "jqcp_l").val()) - 5;
        $("#" + $.jQCP.prefix + "c_point").css({
            position : "relative", zIndex : 5000, top : y + "px"
        })
    },
    hsl2rgb : function ()
    {
        var h = parseInt($("#" + $.jQCP.prefix + "jqcp_h").val()) / 240;
        var s = parseInt($("#" + $.jQCP.prefix + "jqcp_s").val()) / 240;
        var l = parseInt($("#" + $.jQCP.prefix + "jqcp_l").val()) / 240;
        var r, g, b;
        if (s == 0) {
            r = g = b = l
        }
        else
        {
            function hue2rgb(p, q, t)
            {
                if (t < 0) {
                    t += 1
                }
                if (t > 1) {
                    t -= 1
                }
                if (t < 1 / 6) {
                    return p + (q - p) * 6 * t
                }
                if (t < 1 / 2) {
                    return q
                }
                if (t < 2 / 3) {
                    return p + (q - p) * (2 / 3 - t) * 6
                }
                return p
            }
            var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
            var p = 2 * l - q;
            r = hue2rgb(p, q, h + 1 / 3);
            g = hue2rgb(p, q, h);
            b = hue2rgb(p, q, h - 1 / 3)
        }
        $("#" + $.jQCP.prefix + "jqcp_r").val(Math.round(r * 255));
        $("#" + $.jQCP.prefix + "jqcp_g").val(Math.round(g * 255));
        $("#" + $.jQCP.prefix + "jqcp_b").val(Math.round(b * 255));
        $.jQCP.RGBtoHex()
    },
    rgb2hsl : function ()
    {
        var r = parseInt($("#" + $.jQCP.prefix + "jqcp_r").val()) / 255;
        var g = parseInt($("#" + $.jQCP.prefix + "jqcp_g").val()) / 255;
        var b = parseInt($("#" + $.jQCP.prefix + "jqcp_b").val()) / 255;
        var max = Math.max(r, g, b), min = Math.min(r, g, b);
        var h, s, l = (max + min) / 2;
        if (max == min) {
            h = s = 0
        }
        else
        {
            var d = max - min;
            s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
            switch (max) {
                case r:
                    h = (g - b) / d + (g < b ? 6 : 0);
                    break;
                case g:
                    h = (b - r) / d + 2;
                    break;
                case b:
                    h = (r - g) / d + 4;
                    break
            }
            h /= 6
        }
        $("#" + $.jQCP.prefix + "jqcp_h").val(Math.round(h * 240));
        $("#" + $.jQCP.prefix + "jqcp_s").val(Math.round(s * 240));
        $("#" + $.jQCP.prefix + "jqcp_l").val(Math.round(l * 240));
        $.jQCP.RGBtoHex()
    },
    clickCp : function (x, y)
    {
        var pos = $("#" + $.jQCP.prefix + "jqcp").offset();
        $("#" + $.jQCP.prefix + "jqcp_h").val(Math.round(x - pos.left));
        $.jQCP.validHSL($("#" + $.jQCP.prefix + "jqcp_h").val(), "jqcp_h");
        $("#" + $.jQCP.prefix + "jqcp_s").val(Math.round(240 - y + pos.top));
        $.jQCP.validHSL($("#" + $.jQCP.prefix + "jqcp_s").val(), "jqcp_s");
        $.jQCP.hsl2rgb();
        $.jQCP.changeBpBg();
        x = x - 4 - pos.left;
        y = y - 4 - pos.top;
        pos = $("#" + $.jQCP.prefix + "jqcp").offset();
        $("#" + $.jQCP.prefix + "marker").css({
            position : "relative", zIndex : 5000, left : x + "px", top : y + "px"
        })
    },
    clickBp : function (x, y)
    {
        var pos = $("#" + $.jQCP.prefix + "jqbr").offset();
        $("#" + $.jQCP.prefix + "jqcp_l").val(Math.round(240 - y + pos.top));
        $.jQCP.validHSL($("#" + $.jQCP.prefix + "jqcp_l").val(), "jqcp_l");
        $.jQCP.hsl2rgb();
        y = y - 3 - pos.top;
        pos = $("#" + $.jQCP.prefix + "jqbrp").offset();
        $("#" + $.jQCP.prefix + "c_point").css({
            position : "relative", zIndex : 5000, top : y + "px"
        })
    },
    changeBpBg : function ()
    {
        if (navigator.appVersion.indexOf("MSIE") !=- 1)
        {
            $("#" + $.jQCP.prefix + "jqbr").css(
            {
                backgroundImage : "none", filter : "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + $.jQCP.imagePath + "')", 
                backgroundColor : $("#" + $.jQCP.prefix + $.jQCP.colorObj).val()
            })
        }
        else
        {
            $("#" + $.jQCP.prefix + "jqbr").css({
                backgroundColor : $("#" + $.jQCP.prefix + $.jQCP.colorObj).val()
            })
        }
    },
    RGBtoHex : function ()
    {
        $("#" + $.jQCP.prefix + $.jQCP.colorObj).val("#" + $.jQCP.toHex($("#" + $.jQCP.prefix + "jqcp_r").val()) + $.jQCP.toHex($("#" + $.jQCP.prefix + "jqcp_g").val()) + $.jQCP.toHex($("#" + $.jQCP.prefix + "jqcp_b").val()));
        $("#" + $.jQCP.prefix + $.jQCP.colorObj).css({
            backgroundColor : $("#" + $.jQCP.prefix + $.jQCP.colorObj).val()
        })
    },
    HextoRGB : function ()
    {
        var value = $("#" + $.jQCP.prefix + $.jQCP.colorObj).val();
        $("#" + $.jQCP.prefix + "jqcp_r").val($.jQCP.HexToR(value));
        $("#" + $.jQCP.prefix + "jqcp_g").val($.jQCP.HexToG(value));
        $("#" + $.jQCP.prefix + "jqcp_b").val($.jQCP.HexToB(value));
        $.jQCP.setRGB()
    },
    setRGB : function ()
    {
        $.jQCP.rgb2hsl();
        $.jQCP.setCpPos();
        $.jQCP.setBpPos();
        $.jQCP.changeBpBg()
    },
    setHsl : function ()
    {
        $.jQCP.hsl2rgb();
        $.jQCP.setCpPos();
        $.jQCP.setBpPos();
        $.jQCP.changeBpBg()
    },
    toHex : function (N)
    {
        if (N == null) {
            return "00"
        }
        N = parseInt(N);
        if (N == 0 || isNaN(N)) {
            return "00"
        }
        N = Math.max(0, N);
        N = Math.min(N, 255);
        N = Math.round(N);
        return "0123456789ABCDEF".charAt((N - N % 16) / 16) + "0123456789ABCDEF".charAt(N % 16);
    },
    HexToR : function (h)
    {
        return parseInt(($.jQCP.cutHex(h)).substring(0, 2), 16);
    },
    HexToG : function (h)
    {
        return parseInt(($.jQCP.cutHex(h)).substring(2, 4), 16);
    },
    HexToB : function (h)
    {
        return parseInt(($.jQCP.cutHex(h)).substring(4, 6), 16);
    },
    cutHex : function (h)
    {
        return (h.charAt(0) == "#") ? h.substring(1, 7) : h;
    },
    setColorObj : function (colorObj)
    {
        $.jQCP.colorObj = colorObj;
        $("#" + $.jQCP.prefix + colorObj).unbind("change");
        $("#" + $.jQCP.prefix + colorObj).bind("change", function (e)
        {
            $.jQCP.HextoRGB()
        });
        $("#" + $.jQCP.prefix + $.jQCP.colorObj).css({
            backgroundColor : $("#" + $.jQCP.prefix + $.jQCP.colorObj).val()
        })
    },
    setColor : function (colorObj, color)
    {
        $.jQCP.colorObj = colorObj;
        $("#" + $.jQCP.prefix + colorObj).val(color);
        $.jQCP.HextoRGB()
    }
};
$.fn.extend(
{
    jqcp : function ()
    {
        return this.each(function ()
        {
            $.jQCP.init(this.id)
        })
    },
    jqcp_setObject : function ()
    {
        return this.each(function ()
        {
            $.jQCP.setColorObj(this.id)
        })
    },
    jqcp_setColor : function (color)
    {
        return this.each(function ()
        {
            $.jQCP.setColor(this.id, color)
        })
    }
});



$.NJE = 
{
    iconList : ["popup_html", "popup_bgcolor", "popup_forecolor", "bold", "italic", "underline", "justifyleft", 
        "justifycenter", "justifyright", "justifyfull", "insertHorizontalRule", "insertorderedlist", "insertunorderedlist", 
        "indent", "outdent", "popup_addlink", "unlink", "removeformat", "strikethrough", "superscript", "subscript", 
        "popup_addtable", "popup_uploadfile", "popup_addimage", "popup_uploadimage", "popup_pict_s", "popup_pict_m",
        "popup_pict_l", "popup_character",  "popup_copyright"
    ],
    rangeObj : null,
    element : null,
    selectionObj : null,
    boxy : {},
    backcolor : "#ffffff",
    forecolor : "#000000",
    backcolorList : {},
    forecolorList : {},
    init : function (element) {
try {
        document.getElementById(element).contentEditable = true;
} catch(e) {
alert("step0: " + e);
}
try {
        document.getElementById(element).contentWindow.document.designMode = "on";
} catch(e) {
alert("step1: " + e);
}
try {
        document.getElementById(element).contentDocument.designMode = "on";
} catch(e) {
alert("step2: " + e);
}
alert("1=" + document.getElementById(element).contentEditable + "  2=" + document.getElementById(element).contentWindow.document.designMode + "  3=" + document.getElementById(element).contentDocument.designMode );

        $(document.getElementById(element).contentWindow.document).bind("keyup", function (e)
        {
            $.NJE.saveRange(element)
        });
        $(document.getElementById(element).contentWindow.document).bind("keydown", function (e)
        {
            $.NJE.saveRange(element)
        });
        $(document.getElementById(element).contentWindow.document).bind("click", function (e)
        {
            $.NJE.saveRange(element)
        });
        $(document.getElementById(element).contentWindow.document).bind("focus", function (e)
        {
            $.NJE.saveRange(element)
        })
    },
    saveRange : function (element) {
        var iframe = document.getElementById(element);
        var doc = document.getElementById(element).contentDocument || document.getElementById(element).contentWindow.document;
        var selection = doc.selection || iframe.contentWindow.document.body;
        if (navigator.userAgent.indexOf("Firefox") !=- 1 || navigator.userAgent.indexOf("Safari") !=- 1) {
            selection = iframe.contentWindow.window.getSelection()
        }
        var range = selection.createRange ? selection.createRange() : selection.getRangeAt(0);
        var box = element.split("_");
        var textid = "";
        for (var i = 0; i < box.length - 1; i++) {
            textid += "_" + box[i]
        }
        textid = textid.substr(1);
        $("#" + textid).text(document.getElementById(element).contentWindow.document.body.innerHTML);
        $.NJE.rangeObj = range;
        $.NJE.selectionObj = selection;
    },
    restoreRange : function (element) {
        document.getElementById(element).contentWindow.focus();
        if (navigator.userAgent.indexOf("Firefox") !=- 1 || navigator.userAgent.indexOf("Safari") !=- 1)
        {
            if ($.NJE.rangeObj)
            {
                $.NJE.selectionObj.removeAllRanges();
                $.NJE.selectionObj.addRange($.NJE.rangeObj)
            }
        }
        else {
            if ($.NJE.rangeObj) {
                $.NJE.rangeObj.select()
            }
        }
    },
    setIcon : function (element) {
        for (var i = 0; i < $.NJE.iconList.length; i++)
        {
            var checkpopup = ($.NJE.iconList[i]).substr(0, 5);
            if (checkpopup == "popup")
            {
                var fn;
                var id = ($.NJE.iconList[i]).substr(6);
                if (id == "bgcolor" || id == "forecolor") {
                    fn = "handle_color"
                }
                else {
                    fn = "handle_" + id
                }
                $("#" + element + "_" + ($.NJE.iconList[i]).substr(6)).html('<span id="' + element + "_" + $.NJE.iconList[i].substr(6) + "_btn\" onclick='$.NJE.jqp_c();$.NJE." + fn + '("' + id + '","' + element + '");\' style="background-position: ' + (-18) * (i) + 'px 0px;" class="nje_icon"></span>')
            }
            else
            {
                $("#" + element + "_" + $.NJE.iconList[i]).html('<span id="' + element + "_" + $.NJE.iconList[i] + '_btn" onclick=\'$.NJE.setCommand("' + $.NJE.iconList[i] + '",null,"' + element + '");\' style="background-position: ' + (-18) * (i) + 'px 0px;" class="nje_icon"></span>')
            }
        }
        $("#" + element + "_fontsize").change(function ()
        {
            $.NJE.setCommand("fontsize", this.value, element);
            $(this).val("")
        });
        $("#" + element + "_fontname").change(function ()
        {
            $.NJE.setCommand("fontname", this.value, element);
            $(this).val("")
        });
        $("#" + element + "_formatblock").change(function ()
        {
            $.NJE.setCommand("formatblock", this.value, element);
            $(this).val("")
        })
    },
    setContent : function (element) {
        var rid = element.split("_");
        var textid = "";
        for (var i = 0; i < rid.length - 1; i++) {
            textid += "_" + rid[i]
        }
        textid = textid.substr(1);
        var content = $("#" + textid).text();
        if (content != "")
        {
            document.getElementById(element).contentWindow.document.open();
            document.getElementById(element).contentWindow.document.write(content);
            document.getElementById(element).contentWindow.document.close()
        }
    },
    setCommand : function (id, value, element) {
        $.NJE.restoreRange(element);
try {
        document.getElementById(element).contentWindow.document.execCommand(id, false, value);
} catch(e) {
    alert("element="+element+", e="+e);
}
        $.NJE.restoreRange(element);
        var box = element.split("_");
        var textid = "";
        for (var i = 0; i < box.length - 1; i++) {
            textid += "_" + box[i]
        }
        textid = textid.substr(1);
        $("#" + textid).text(document.getElementById(element).contentWindow.document.body.innerHTML)
    },
    jqp_o : function (id, element, btn_id) {
        $.NJE.boxy[id] = id;
        $("#" + id).jqpopup_open(element + "_" + btn_id + "_btn");
        $.NJE.element = element;
    },
    jqp_c : function () {
        $.each($.NJE.boxy, function ()
        {
            $("#" + this).jqpopup_close()
        });
        $.NJE.boxy = {}
    },
    handle_color : function (id, element) {
        var rid = id;
        if (id == "bgcolor" && navigator.userAgent.indexOf("MSIE") !=- 1) {
            rid = "backColor"
        }
        else {
            if (id == "bgcolor") {
                rid = "hiliteColor";
            }
        }
        $.NJE.jqp_o("color_div", element, id);
        if (id == "bgcolor")
        {
            if ($.NJE.backcolorList[element] == null) {
                $.NJE.backcolorList[element] = $.NJE.backcolor
            }
            $("#color_value").jqcp_setColor($.NJE.backcolorList[element])
        }
        else
        {
            if (id == "forecolor")
            {
                if ($.NJE.forecolorList[element] == null) {
                    $.NJE.forecolorList[element] = $.NJE.forecolor
                }
                $("#color_value").jqcp_setColor($.NJE.forecolorList[element])
            }
        }
        $("#color_btn").unbind("click");
        $("#color_btn").bind("click", function ()
        {
            if (rid == "backColor" || rid == "hiliteColor") {
                $.NJE.backcolorList[element] = $("#color_value").val()
            }
            else {
                $.NJE.forecolorList[element] = $("#color_value").val()
            }
            $.NJE.setCommand(rid, $("#color_value").val(), element);
            $.NJE.jqp_c()
        })
    },
    handle_character : function (id, element) {
        $.NJE.jqp_o(id + "_div", element, id);
        $(".character").unbind("click");
        $(".character").bind("click", function ()
        {
            $.NJE.htmlHandler(this.id.toString(), element);
            $.NJE.jqp_c()
        })
    },
    handle_pict_s : function (id, element) {
        $.NJE.jqp_o("pictgram_div", element, id);
        $(".picticon").unbind("click");
        $(".picticon").bind("click", function ()
        {
            var str = '<img src="' + this.src + '" title="' + this.title + '"/>';
            $.NJE.htmlHandler(str, element);
            $.NJE.jqp_c()
        })
    },
    handle_pict_m : function (id, element) {
        $.NJE.jqp_o("pictgram_div", element, id);
        $(".picticon").unbind("click");
        $(".picticon").bind("click", function ()
        {
            var str = '<img src="' + this.src.replace('s','m') + '" title="' + this.title + '"/>';
            $.NJE.htmlHandler(str, element);
            $.NJE.jqp_c()
        })
    },
    handle_pict_l : function (id, element) {
        $.NJE.jqp_o("pictgram_div", element, id);
        $(".picticon").unbind("click");
        $(".picticon").bind("click", function ()
        {
            var str = '<img src="' + this.src.replace('s','l') + '" title="' + this.title + '"/>';
            $.NJE.htmlHandler(str, element);
            $.NJE.jqp_c()
        })
    },
    handle_html : function (id, element) {
        $.NJE.jqp_o(id + "_div", element, id);
        var bcon = document.getElementById(element).contentWindow.document.body.innerHTML;
        if (bcon.length > 5 && bcon.substr(0, 5).toLowerCase() == "<pre>") {
            bcon = bcon.substr(5);
            bcon = bcon.substr(0, bcon.length - 6)
        }
        if (navigator.userAgent.indexOf("MSIE") !=- 1) {
            $("#html_content").text(bcon)
        }
        else {
            $("#html_content").val(bcon)
        }
        $("#" + id + "_btn").unbind("click");
        $("#" + id + "_btn").bind("click", function ()
        {
            var rid = element.split("_");
            var textid = "";
            for (var i = 0; i < rid.length - 1; i++) {
                textid += "_" + rid[i]
            }
            textid = textid.substr(1);
            if (navigator.userAgent.indexOf("MSIE") !=- 1) {
                $("#" + textid).text($("#html_content").text())
            }
            else {
                $("#" + textid).text($("#html_content").val())
            }
            if (navigator.userAgent.indexOf("MSIE") !=- 1)
            {
                $(document.getElementById(element).contentWindow.document.body).html($("#html_content").text())
            }
            else
            {
                var content = $("#html_content").val();
                $(document.getElementById(element).contentWindow.document.body).html("<pre>" + content + "</pre>")
            }
            $.NJE.jqp_c()
        })
    },
    handle_addimage : function (id, element) {
        $.NJE.jqp_o(id + "_div", element, id);
        $("#" + id + "_btn").unbind("click");
        $("#" + id + "_btn").bind("click", function ()
        {
            var str = " <img";
            str += ' src="' + $("#addimage_url").val() + '"';
            str += ' title="' + $("#addimage_desc").val() + '"';
            str += ' align="' + $("#addimage_alignment").val() + '"';
            str += ' border="' + $("#addimage_border").val() + '"';
            str += "/>";
            $.NJE.htmlHandler(str, element);
            $.NJE.jqp_c()
        })
    },
    handle_addlink : function (id, element) {
        $.NJE.jqp_o(id + "_div", element, id);
        $("#" + id + "_btn").unbind("click");
        $("#" + id + "_btn").bind("click", function ()
        {
            var str = '<a href="' + $("#addlink_url").val() + '"';
            str += ' target="' + $("#addlink_target").val() + '"';
            str += ">";
            str += $("#addlink_name").val();
            str += "</a>";
            $.NJE.htmlHandler(str, element);
            $.NJE.jqp_c()
        })
    },
    handle_addtable : function (id, element) {
        $.NJE.jqp_o(id + "_div", element, id);
        $("#" + id + "_btn").unbind("click");
        $("#" + id + "_btn").bind("click", function ()
        {
            var str = "<table";
            str += ' cellpadding="' + $("#addtable_cellpadding").val() + '"';
            str += ' cellspacing="' + $("#addtable_cellspacing").val() + '"';
            str += ' width="' + $("#addtable_width").val() + $("#addtable_width_format").val() + '"';
            str += ' border="' + $("#addtable_border").val() + '"';
            str += ' align="' + $("#addtable_alignment").val() + '"';
            str += ">";
            for (var i = 0; i < $("#addtable_row").val(); i++)
            {
                str += "<tr>";
                for (var j = 0; j < $("#addtable_column").val(); j++) {
                    str += "<td>&nbsp;</td>"
                }
                str += "</tr>"
            }
            str += "</table>";
            $.NJE.htmlHandler(str, element);
            $.NJE.jqp_c()
        })
    },
    handle_uploadimage : function (id, element) {
        $.NJE.jqp_o(id + "_div", element, id);
        $("#" + id + "_btn").unbind("click");
        $("#" + id + "_btn").bind("click", function ()
        {
            $.NJE.uploads("image", element)
        })
    },
    handle_uploadimageReturn : function (element) {
        var str = " <img";
        str += ' src="' + $("#uploadimage_url").val() + '"';
        str += ' title="' + $("#uploadimage_desc").val() + '"';
        str += ' align="' + $("#uploadimage_alignment").val() + '"';
        str += ' border="' + $("#uploadimage_border").val() + '"';
        str += "/>";
        $.NJE.htmlHandler(str, element);
        $.NJE.jqp_c()
    },
    handle_uploadfile : function (id, element) {
        $.NJE.jqp_o(id + "_div", element, id);
        $("#" + id + "_btn").unbind("click");
        $("#" + id + "_btn").bind("click", function ()
        {
            $.NJE.uploads("file", element)
        })
    },
    handle_uploadfileReturn : function (element) {
        var str = '<a href="' + $("#uploadfile_url").val() + '"><img';
        str += ' src="img/attachment.gif"';
        str += ' title="' + $("#uploadfile_name").val() + '"';
        str += ' border="0"/>';
        str += $("#uploadfile_name").val();
        str += "</a>";
        $.NJE.htmlHandler(str, element);
        $.NJE.jqp_c()
    },
    htmlHandler : function (html_content, element) {
        $.NJE.restoreRange(element);
        if (navigator.userAgent.indexOf("MSIE") !=- 1)
        {
            document.getElementById(element).contentWindow.document.selection.createRange().pasteHTML(html_content)
        }
        else
        {
            var success = false;
            try
            {
                document.getElementById(element).contentWindow.document.execCommand("insertHTML", false, 
                html_content);
                success = true
            }
            catch (e) {}
            if (!success)
            {
                try
                {
                    document.getElementById(element).contentWindow.document.execCommand("insertText", 
                    false, html_content)
                }
                catch (e) {}
            }
        }
        $.NJE.restoreRange(element);
        var box = element.split("_");
        var textid = "";
        for (var i = 0; i < box.length - 1; i++) {
            textid += "_" + box[i]
        }
        textid = textid.substr(1);
        $("#" + textid).text(document.getElementById(element).contentWindow.document.body.innerHTML)
    },
    uploads : function (fname, element) {
        var uid = fname.toLowerCase();
        $.NJE.ajaxFileUpload(
        {
            url : "genericupload.php", secureuri : false, fileElementId : "upload" + uid + "_fileToUpload", 
            dataType : "json",
            success : function (data, status)
            {
                if (typeof (data.error) != "undefined")
                {
                    if (data.error.value != "") {
                        alert(data.error.value)
                    }
                    else
                    {
                        $("#upload" + uid + "_url").val(data.imagepath.value);
                        eval("$.NJE.handle_upload" + fname + "Return('" + element + "');")
                    }
                }
            },
            error : function (data, status, e)
            {
                alert(e)
            }
        });
        return false;
    },
    uploadIframe : function (id, uri) {
        var frameId = "jUploadFrame" + id;
        if (window.ActiveXObject)
        {
            var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
            if (typeof uri == "boolean") {
                io.src = "javascript:false"
            }
            else {
                if (typeof uri == "string") {
                    io.src = uri;
                }
            }
        }
        else {
            var io = document.createElement("iframe");
            io.id = frameId;
            io.name = frameId
        }
        io.style.position = "absolute";
        io.style.top = "-1000px";
        io.style.left = "-1000px";
        document.body.appendChild(io);
        return io;
    },
    uploadForm : function (id, fileElementId) {
        var formId = "jUploadForm" + id;
        var fileId = "jUploadFile" + id;
        var form = $('<form  action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
        var oldElement = $("#" + fileElementId);
        var newElement = $(oldElement).clone();
        $(oldElement).attr("id", fileId);
        $(oldElement).before(newElement);
        $(oldElement).appendTo(form);
        $(form).css("position", "absolute");
        $(form).css("top", "-1200px");
        $(form).css("left", "-1200px");
        $(form).appendTo("body");
        return form;
    },
    ajaxFileUpload : function (s) {
        s = $.extend({}, $.ajaxSettings, s);
        var id = new Date().getTime();
        var form = $.NJE.uploadForm(id, s.fileElementId);
        var io = $.NJE.uploadIframe(id, s.secureuri);
        var frameId = "jUploadFrame" + id;
        var formId = "jUploadForm" + id;
        if (s.global && !$.active++) {
            $.event.trigger("ajaxStart")
        }
        var requestDone = false;
        var xml = {};
        if (s.global) {
            $.event.trigger("ajaxSend", [xml, s])
        }
        var uploadCallback = function (isTimeout)
        {
            var io = document.getElementById(frameId);
            try
            {
                if (io.contentWindow)
                {
                    xml.responseText = io.contentWindow.document.body ? io.contentWindow.document.body.innerHTML : null;
                    xml.responseXML = io.contentWindow.document.XMLDocument ? io.contentWindow.document.XMLDocument : io.contentWindow.document
                }
                else
                {
                    if (io.contentDocument)
                    {
                        xml.responseText = io.contentDocument.document.body ? io.contentDocument.document.body.innerHTML : null;
                        xml.responseXML = io.contentDocument.document.XMLDocument ? io.contentDocument.document.XMLDocument : io.contentDocument.document;
                    }
                }
            }
            catch (e) {
                $.handleError(s, xml, null, e)
            }
            if (xml || isTimeout == "timeout")
            {
                requestDone = true;
                var status;
                try
                {
                    status = isTimeout != "timeout" ? "success" : "error";
                    if (status != "error")
                    {
                        var data = $.NJE.uploadHttpData(xml, s.dataType);
                        if (s.success) {
                            s.success(data, status)
                        }
                        if (s.global) {
                            $.event.trigger("ajaxSuccess", [xml, s])
                        }
                    }
                    else {
                        $.handleError(s, xml, status)
                    }
                }
                catch (e) {
                    status = "error";
                    $.handleError(s, xml, status, e)
                }
                if (s.global) {
                    $.event.trigger("ajaxComplete", [xml, s])
                }
                if (s.global && !--$.active) {
                    $.event.trigger("ajaxStop")
                }
                if (s.complete) {
                    s.complete(xml, status)
                }
                $(io).unbind();
                setTimeout(function ()
                {
                    try {
                        $(io).remove();
                        $(form).remove()
                    }
                    catch (e) {
                        $.handleError(s, xml, null, e)
                    }
                }, 100);
                xml = null;
            }
        };
        if (s.timeout > 0) {
            setTimeout(function ()
            {
                if (!requestDone) {
                    uploadCallback("timeout")
                }
            },
            s.timeout)
        }
        try
        {
            var form = $("#" + formId);
            $(form).attr("action", s.url);
            $(form).attr("method", "POST");
            $(form).attr("target", frameId);
            if (form.encoding) {
                form.encoding = "multipart/form-data"
            }
            else {
                form.enctype = "multipart/form-data"
            }
            $(form).submit()
        }
        catch (e) {
            $.handleError(s, xml, null, e)
        }
        if (window.attachEvent) {
            document.getElementById(frameId).attachEvent("onload", uploadCallback)
        }
        else {
            document.getElementById(frameId).addEventListener("load", uploadCallback, false)
        }
        return {
            abort : function () {}
        }
    },
    uploadHttpData : function (r, type) {
        var data = !type;
        data = type == "xml" || data ? r.responseXML : r.responseText;
        if (type == "script") {
            $.globalEval(data)
        }
        if (type == "json") {
            eval("data = " + data)
        }
        if (type == "html") {
            $("<div>").html(data).evalScripts()
        }
        return data;
    }
};
$.fn.extend(
{
    nje : function (nje_type, contents) {
        return this.each(function ()
        {
            $(this).contents().remove().html("");
            
            if (nje_type === "type0") {
                $(this).html(nje_type0_div);
            }
            else if (nje_type === "type1") {
                $(this).html(nje_type1_div);
            }
            else if (nje_type === "type2") {
                $(this).html(nje_type2_div);
            }
            else if (nje_type === "type3") {
                $(this).html(nje_type3_div);
            }
            

            if (!contents) {
                contents = "";
            }
            $(this).append('<textarea id="content" name="content" class="nje_popup">'+contents+'</textarea>');
            
            $(this).ready( function() {
                //$.NJE.init(this.id)
                $.NJE.init("content_nje")
                $("#content_nje").nje_setIcon();
                $("#content_nje").nje_setContent();
            });
        })
    },
    nje_setIcon : function () {
        return this.each(function ()
        {
            $.NJE.setIcon(this.id)
        })
    },
    nje_setContent : function () {
        return this.each(function () {
            $.NJE.setContent(this.id)
        })
    },
    jqpopup_close : function () {
        return this.each(function ()
        {
            try {
                $.NJE.restoreRange($.NJE.element)
            }
            catch (e) {}$.jQpopup.close(this.id)
        })
    }
});
function specialcharacter()
{
    var cols = 15;
    var j = 0;
    var tablebox = '<table cellpadding="1" cellspacing="1" border="1">';
    for (var i = 128; i < 255; i++)
    {
        if (i != 129 && i != 141 && i != 143 && i != 144 && i != 157 && i != 160)
        {
            j++;
            if (j == 0) {
                tablebox += "<tr>"
            }
            tablebox += '<td class="character" width="20" align="center" id="&#' + i + ';">&#' + i + ";</td>";
            if (j == cols) {
                tablebox += "</tr>";
                j = 0;
            }
        }
    }
    tablebox += '<td class="character" id="&spades;">&spades;</td>';
    tablebox += '<td class="character" id="&clubs;">&clubs;</td>';
    tablebox += '<td class="character" id="&diams;">&diams;</td>';
    tablebox += '<td class="character" id="&hearts;">&hearts;</td>';
    tablebox += '<td class="character" id="&oline;">&oline;</td>';
    tablebox += '<td class="character" id="&larr;">&larr;</td>';
    tablebox += '<td class="character" id="&rarr;">&rarr;</td>';
    tablebox += '<td class="character" id="&uarr;">&uarr;</td>';
    tablebox += '<td class="character" id="&darr;">&darr;</td>';
    tablebox += '<td colspan="5">&nbsp;</td>';
    tablebox += "</tr>";
    tablebox += "</table>";
    $("#character_div").html(tablebox)
}
$(document).ready(function () {
    $("#color_picker").jqcp();
    $("#color_value").jqcp_setObject();
    specialcharacter();
    $(".nje_menu td").mouseover(function ()
    {
        $(this).toggleClass("nje_active")
    });
    $(".nje_menu td").mouseout(function ()
    {
        $(this).toggleClass("nje_active")
    })
});

var nje_formatblock = '\
    <select name="formatblock" id="content_nje_formatblock">\
       <option value="" selected="selected">フォーマット</option>\
       <option value="&lt;p&gt;">p</option>\
       <option value="&lt;h1&gt;">h1</option>\
       <option value="&lt;h2&gt;">h2</option>\
       <option value="&lt;h3&gt;">h3</option>\
       <option value="&lt;h4&gt;">h4</option>\
       <option value="&lt;h5&gt;">h5</option>\
       <option value="&lt;h6&gt;">h6</option>\
       <option value="&lt;blockquote&gt;">blockquote</option>\
       <option value="&lt;code&gt;">code</option>\
       <option value="&lt;abbr&gt;">abbr</option>\
       <option value="&lt;pre&gt;">pre</option>\
    </select>';

var nje_fontname = '\
    <select name="fontname" id="content_nje_fontname">\
       <option value="" selected="selected">フォント</option>\
       <option value="arial">Arial</option>\
       <option value="comic sans ms">Comic Sans</option>\
       <option value="courier new">Courier New</option>\
       <option value="georgia">Georgia</option>\
       <option value="helvetica">Helvetica</option>\
       <option value="impact">Impact</option>\
       <option value="times new roman">Times</option>\
       <option value="trebuchet ms">Trebuchet</option>\
       <option value="verdana">Verdana</option>\
    </select>';

var nje_fontsize = '\
    <select name="fontsize" id="content_nje_fontsize">\
       <option value="" selected="selected">サイズ</option>\
       <option value="-2">-2</option>\
       <option value="-1">-1</option>\
       <option value="+1">+1</option>\
       <option value="+2">+2</option>\
       <option value="+3">+3</option>\
    </select>';


var nje_color_div = '\
  <div id="color_div" style="display:none" title="Color Picker">\
    <table>\
      <tr>\
        <td colspan="3">\
          H:<input type="text" id="jqcp_h" size="3" value="0">\
          S:<input type="text" id="jqcp_s" size="3" value="0">\
          L:<input type="text" id="jqcp_l" size="3" value="0"><br>\
          R:<input type="text" id="jqcp_r" size="3" value="255">\
          G:<input type="text" id="jqcp_g" size="3" value="255">\
          B:<input type="text" id="jqcp_b" size="3" value="255"><br>\
          <input type="text" id="color_value" class="jqcp_value" size="8">\
          <input type="button" id="color_btn" value="Pick">\
        </td>\
      </tr>\
      <tr>\
        <td align="left"><div id="color_picker"></div></td>\
      </tr>\
    </table>\
  </div>';

var nje_character_div = '\
  <div id="character_div" style="display:none" title="特殊記号">\
  </div>';


var nje_addtable_div = '\
  <div id="addtable_div" style="display:none" title="表の挿入">\
    <table>\
      <tr>\
        <td>列</td>\
        <td><input type="text" id="addtable_column" name="table_column" value="2" size="10"></td>\
        <td>&nbsp;</td>\
      </tr>\
      <tr>\
        <td>行</td>\
        <td><input type="text" id="addtable_row" name="table_row" value="2" size="10"></td>\
        <td>&nbsp;</td>\
      </tr>\
      <tr>\
        <td>幅</td>\
        <td><input type="text" id="addtable_width" name="table_width" value="100" size="10"></td>\
        <td>\
          <select name="table_width_format" id="addtable_format">\
            <option value="%">%</option>\
            <option value="">pixels></option>\
          </select>\
        </td>\
      </tr>\
      <tr>\
        <td>枠線</td>\
        <td><input type="text" id="addtable_border" name="table_border" value="1" size="10"></td>\
        <td>&nbsp;</td>\
      </tr>\
      <tr>\
        <td>セルスペース</td>\
        <td><input type="text" id="addtable_cellspacing" name="table_cellspacing" value="0" size="10"></td>\
        <td>&nbsp;</td>\
      </tr>\
      <tr>\
        <td>パディング</td>\
        <td><input type="text" id="addtable_cellpadding" name="table_cellpadding" value="0" size="10"></td>\
        <td>&nbsp;</td>\
      </tr>\
      <tr>\
        <td>テーブル配置</td>\
        <td>\
          <select id="addtable_alignment" name="table_alignment">\
            <option value="">default</option>\
            <option value="left">left</option>\
            <option value="right">right</option>\
            <option value="center">center></option>\
          </select>\
        </td>\
        <td>&nbsp;</td>\
      </tr>\
      <tr>\
        <td>\
          <input type="button" id="addtable_btn" value="決定">\
        </td>\
      </tr>\
    </table>\
  </div>';


var nje_addlink_div = '\
  <div id="addlink_div" style="display:none"  title="リンクの設定">\
    <table>\
      <tr>\
        <td>サイト名</td>\
        <td><input type="text" id="addlink_name" name="link_name" size="20"></td>\
      </tr>\
      <tr>\
        <td>ＵＲＬ</td>\
        <td><input type="text" id="addlink_url" name="link_url"></td>\
      </tr>\
      <tr>\
        <td>Target</td>\
        <td>\
          <select name="link_target" id="addlink_target">\
            <option value=""></option>\
            <option value="_blank">_blank</option>\
            <option value="_parent">_parent</option>\
            <option value="_self">_self</option>\
            <option value="_top">_top</option>\
          </select>\
        </td>\
      </tr>\
      <tr>\
        <td>\
          <input type="button" id="addlink_btn" value="決定">\
        </td>\
      </tr>\
    </table>\
  </div>';

var nje_addimage_div = '\
  <div id="addimage_div" style="display:none" title="画像の挿入">\
    <table>\
      <tr>\
        <td>画像ＵＲＬ</td>\
        <td><input type="text" id="addimage_url" name="image_url"></td>\
      </tr>\
      <tr>\
        <td>画像の説明</td>\
        <td><input type="text" id="addimage_desc" name="image_desc"></td>\
      </tr>\
      <tr>\
        <td>画像の配置</td>\
        <td>\
          <select name="image_alignment" id="addimage_alignment">\
            <option value=""></option>\
            <option value="left">左</option>\
            <option value="right">右</option>\
          </select>\
        </td>\
      </tr>\
      <tr>\
        <td>枠線</td>\
        <td><input type="text" id="addimage_border" name="image_border" value="0" size="10"></td>\
      </tr>\
      <tr>\
        <td>\
          <input type="button" id="addimage_btn" value="決定">\
        </td>\
      </tr>\
    </table>\
  </div>';


var nje_uploadimage_div = '\
  <div id="uploadimage_div" style="display:none" title="画像のアップロード">\
    <form id="uploadimageform" name="uploadimageform" action="" method="post" enctype="multipart/form-data">\
      <table>\
        <tr>\
          <td>Upload Image</td>\
          <td>\
            <input type="hidden" name="uploadimage_url" id="uploadimage_url">\
            <input type="file" name="fileToUpload" id="uploadimage_fileToUpload">\
          </td>\
        </tr>\
        <tr>\
          <td>Image Description</td>\
          <td><input type="text" id="uploadimage_desc" name="uploadimage_desc"></td>\
        </tr>\
        <tr>\
          <td>Alignment</td>\
          <td>\
            <select name="uploadimage_alignment" id="uploadimage_alignment">\
              <option value=""></option>\
              <option value="left">left</option>\
              <option value="right">right</option>\
            </select>\
          </td>\
        </tr>\
        <tr>\
          <td>Border</td>\
          <td><input type="text" id="uploadimage_border" name="uploadimage_border" value="0" size="10"></td>\
        </tr>\
        <tr>\
          <td>\
            <input type="button" id="uploadimage_btn" value="Upload">\
          </td>\
        </tr>\
      </table>\
    </form>\
  </div>';

var nje_uploadfile_div = '\
  <div id="uploadfile_div" style="display:none"  title="ファイルのアップロード">\
    <form id="uploadfileform" name="uploadfileform" action="" method="post" enctype="multipart/form-data">\
      <table>\
        <tr>\
          <td>Upload File</td>\
          <td>\
            <input type="hidden" name="uploadfile_url" id="uploadfile_url">\
            <input type="file" name="fileToUpload" id="uploadfile_fileToUpload">\
          </td>\
        </tr>\
        <tr>\
          <td>File Name</td>\
          <td><input type="text" name="name" id="uploadfile_name" size="10"></td>\
        </tr>\
        <tr>\
          <td>\
            <input type="button" id="uploadfile_btn" value="Upload">\
          </td>\
        </tr>\
      </table>\
    </form>\
  </div>';

var nje_pictgram_div = '\
  <div id="pictgram_div" style="display:none"  title="絵文字">\
    <table>\
      <tr>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict001s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict002s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict003s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict004s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict006s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict007s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict008s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict009s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict010s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict011s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict012s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict013s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict014s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict015s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict016s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict017s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict018s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict020s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict022s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict030s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict033s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict035s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict036s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict037s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict038s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict040s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict041s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict042s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict043s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict044s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict045s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict046s.png" alt=""></td>\
      </tr>\
      <tr>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict047s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict049s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict050s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict051s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict052s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict053s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict056s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict057s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict058s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict066s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict069s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict070s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict071s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict072s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict075s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict076s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict077s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict079s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict080s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict081s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict082s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict083s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict084s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict086s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict087s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict088s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict091s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict094s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict098s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict100s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict101s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict102s.png" alt=""></td>\
      </tr>\
      <tr>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict103s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict111s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict145s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict146s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict147s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict155s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict156s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict159s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict160s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict163s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict175s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict177s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict179s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict180s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict182s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict185s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict186s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict188s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict189s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict190s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict191s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict192s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict193s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict194s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict196s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict197s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict201s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict203s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict206s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict209s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict211s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict214s.png" alt=""></td>\
      </tr>\
      <tr>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict216s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict217s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict221s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict222s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict225s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict228s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict230s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict231s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict232s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict233s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict235s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict236s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict238s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict240s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict244s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict247s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict249s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict250s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict252s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict254s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict257s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict258s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict259s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict260s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict262s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict264s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict268s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict269s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict270s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict271s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict274s.png" alt=""></td>\
        <td class="pictcell"><img class="picticon" src="/img/pict/pict280s.png" alt=""></td>\
      </tr>\
    </table>\
  </div>';

var nje_html_div = '\
  <div id="html_div" style="display:none" title="HTMLソース">\
    <textarea id="html_content" cols="120" rows="24" style="font-size: 75%;"></textarea><br>\
    <input type="button" id="html_btn" value="submit">\
  </div>';


var nje_type0_div = '\
  <div class="nje_body">\
    <table>\
      <tr>\
        <td>\
          <table class="nje_menu">\
            <tr>\
              <td colspan="4" title="フォーマット">' + nje_formatblock + '</td>\
              <td colspan="4" title="フォント">' + nje_fontname + '</td>\
              <td colspan="4" title="文字サイズ">' + nje_fontsize + '</td>\
              <td id="content_nje_subscript" title="上付き"></td>\
              <td id="content_nje_superscript" title="下付き"></td>\
            </tr>\
            <tr>\
              <td id="content_nje_bgcolor" title="背景色"></td>\
              <td id="content_nje_forecolor" title="文字色"></td>\
              <td id="content_nje_bold" title="太字"></td>\
              <td id="content_nje_italic" title="斜体"></td>\
              <td id="content_nje_underline" title="下線"></td>\
              <td id="content_nje_strikethrough" title="取り消し線"></td>\
              <td id="content_nje_justifyleft" title="左寄せ"></td>\
              <td id="content_nje_justifycenter" title="中央"></td>\
              <td id="content_nje_justifyright" title="右寄せ"></td>\
              <td id="content_nje_justifyfull" title="均等幅"></td>\
              <td id="content_nje_insertorderedlist" title="番号リスト"></td>\
              <td id="content_nje_insertunorderedlist" title="箇条書き"></td>\
              <td id="content_nje_insertHorizontalRule" title="水平線"></td>\
              <td id="content_nje_removeformat" title="書式の削除"></td>\
            </tr>\
            <tr>\
              <td id="content_nje_addlink" title="リンクの設定"></td>\
              <td id="content_nje_unlink" title="リンクの解除"></td>\
              <td id="content_nje_addtable" title="表の挿入"></td>\
              <td id="content_nje_addimage" title="画像の挿入"></td>\
              <td id="content_nje_uploadimage" title="画像のアップロード"></td>\
              <td id="content_nje_uploadfile" title="ファイルのアップロード"></td>\
              <td id="content_nje_character" title="特殊記号"></td>\
              <td id="content_nje_pict_s" title="絵文字（小）"></td>\
              <td id="content_nje_pict_m" title="絵文字（中）"></td>\
              <td id="content_nje_pict_l" title="絵文字（大）"></td>\
              <td id="content_nje_indent" title="インデント"></td>\
              <td id="content_nje_outdent" title="インデント解除"></td>\
              <td id="content_nje_html" title="HTMLソース"></td>\
            </tr>\
          </table>\
        </td>\
      </tr>\
      <tr>\
        <td class="nje_entry">\
          <iframe id="content_nje" class="nje_iframebody"></iframe>\
        </td>\
      </tr>\
    </table>\
  </div>'
  + nje_color_div
  + nje_character_div
  + nje_addtable_div
  + nje_addlink_div
  + nje_addimage_div
  + nje_uploadimage_div
  + nje_uploadfile_div
  + nje_pictgram_div
  + nje_html_div;

var nje_type3_div = '\
  <div>\
    <table class="nje_type1_body">\
      <tr>\
        <td>\
          <table class="nje_menu">\
            <tr>\
              <td colspan="4" title="フォーマット">' + nje_formatblock + '</td>\
              <td colspan="2" title="文字サイズ">' + nje_fontsize + '</td>\
              <td id="content_nje_subscript" title="上付き"></td>\
              <td id="content_nje_superscript" title="下付き"></td>\
              <td id="content_nje_bold" title="太字"></td>\
              <td id="content_nje_italic" title="斜体"></td>\
              <td id="content_nje_underline" title="下線"></td>\
              <td id="content_nje_strikethrough" title="取り消し線"></td>\
              <td id="content_nje_pict_s" title="絵文字（小）"></td>\
              <td id="content_nje_pict_m" title="絵文字（中）"></td>\
              <td id="content_nje_pict_l" title="絵文字（大）"></td>\
              <td id="content_nje_insertorderedlist" title="番号リスト"></td>\
              <td id="content_nje_insertunorderedlist" title="箇条書き"></td>\
              <td id="content_nje_insertHorizontalRule" title="水平線"></td>\
              <td id="content_nje_addlink" title="リンクの設定"></td>\
              <td id="content_nje_unlink" title="リンクの解除"></td>\
              <td id="content_nje_addtable" title="表の挿入"></td>\
              <td id="content_nje_addimage" title="画像の挿入"></td>\
              <td id="content_nje_html" title="HTMLソース"></td>\
              <td id="content_nje_removeformat" title="書式の削除"></td>\
            </tr>\
          </table>\
        </td>\
      </tr>\
    </table>\
  </div>'
  + nje_addtable_div
  + nje_addlink_div
  + nje_addimage_div
  + nje_pictgram_div
  + nje_html_div;

var nje_type1_div = '\
  <div>\
    <table class="nje_type1_body">\
      <tr>\
        <td>\
          <table class="nje_menu">\
            <tr>\
              <td colspan="4" title="フォーマット">' + nje_formatblock + '</td>\
              <td colspan="2" title="文字サイズ">' + nje_fontsize + '</td>\
              <td id="content_nje_subscript" title="上付き"></td>\
              <td id="content_nje_superscript" title="下付き"></td>\
              <td id="content_nje_bold" title="太字"></td>\
              <td id="content_nje_italic" title="斜体"></td>\
              <td id="content_nje_underline" title="下線"></td>\
              <td id="content_nje_strikethrough" title="取り消し線"></td>\
              <td id="content_nje_pict_s" title="絵文字（小）"></td>\
              <td id="content_nje_pict_m" title="絵文字（中）"></td>\
              <td id="content_nje_pict_l" title="絵文字（大）"></td>\
              <td id="content_nje_insertorderedlist" title="番号リスト"></td>\
              <td id="content_nje_insertunorderedlist" title="箇条書き"></td>\
              <td id="content_nje_insertHorizontalRule" title="水平線"></td>\
              <td id="content_nje_addlink" title="リンクの設定"></td>\
              <td id="content_nje_unlink" title="リンクの解除"></td>\
              <td id="content_nje_addtable" title="表の挿入"></td>\
              <td id="content_nje_addimage" title="画像の挿入"></td>\
              <td id="content_nje_html" title="HTMLソース"></td>\
              <td id="content_nje_removeformat" title="書式の削除"></td>\
            </tr>\
          </table>\
        </td>\
      </tr>\
      <tr>\
        <td class="nje_type1_entry">\
          <iframe id="content_nje" src="about:blank" class="nje_iframebody"></iframe>\
        </td>\
      </tr>\
    </table>\
  </div>'
  + nje_addtable_div
  + nje_addlink_div
  + nje_addimage_div
  + nje_pictgram_div
  + nje_html_div;

var nje_type2_div = '\
  <div>\
    <table class="nje_type2_body">\
      <tr>\
        <td>\
          <table class="nje_menu">\
            <tr>\
              <td colspan="2" title="文字サイズ">' + nje_fontsize + '</td>\
              <td id="content_nje_bold" title="太字"></td>\
              <td id="content_nje_italic" title="斜体"></td>\
              <td id="content_nje_underline" title="下線"></td>\
              <td id="content_nje_strikethrough" title="取り消し線"></td>\
              <td id="content_nje_pict_s" title="絵文字（小）"></td>\
              <td id="content_nje_pict_m" title="絵文字（中）"></td>\
              <td id="content_nje_pict_l" title="絵文字（大）"></td>\
              <td id="content_nje_insertorderedlist" title="番号リスト"></td>\
              <td id="content_nje_insertunorderedlist" title="箇条書き"></td>\
              <td id="content_nje_insertHorizontalRule" title="水平線"></td>\
            </tr>\
          </table>\
        </td>\
      </tr>\
      <tr>\
        <td class="nje_type2_entry">\
          <iframe id="content_nje" class="nje_iframebody"></iframe>\
        </td>\
      </tr>\
    </table>\
  </div>'
  + nje_pictgram_div;





