

    function render_file_xml_select() {
        $.post(xml_xsl, {
            req:"load_xml",
        }).done(function( data ) {
            var obj = JSON.parse(data).data;
            var select = "<select>";
            for(var i in obj){
                if (obj[i]!="." && obj[i]!="..") {
                    select += "<option value='"+obj[i]+"'>"+obj[i]+"</option>";
                }
            }
            select += "</select>";
            set_confirm_dialog(select,set_in_xml,500,220,"Zrušit","Vybrat");
        });
    }

    function render_xml_vers_select(json){
        var select = $('<select id="xml_vers"></select>');
        for(var i = 1 ; i <= json.length ; i++){
            var option;
            if(i == cache.loaded_version){
                 option = $('<option value="'+i+'"> verze '+i+' ( aktuálně načtena )</option>');
            }else{
                if(i == 1){
                    option = $('<option value="1"> verze 1 ( generátor )</option>');
                }else{
                    option = $('<option value="'+i+'"> verze '+i+'</option>');
                }
            }
            select.append(option);
        }
         select.val(cache.loaded_version);
        return select;
    }

    function render_block_status_select() {
        if ( cache.select_block_status=="") {
            var select = "<select>";
            var style = block_status;
            for (var j in block_status_order){
                select += "<option value='"+block_status_order[j]+"'>"+style[block_status_order[j]]+"</option>";
            }
            select += "</select>";
            cache.select_block_status = select;
            return select;
        }else{
            return  cache.select_block_status;
        }
    }


    function render_style_font_select() {
        if ( cache.select_font=="") {
            var select = "<select>";
            var style = aip_type_colors ;
            for(var i in style){
                select += "<option value='"+style[i]+"'>"+i+"</option>";
            }
            select += "</select>";
            cache.select_font = select;
            return select;
        }else{
            return  cache.select_font;
        }

    }

    function render_block_type_select() {
        if ( cache.select_block_type=="") {
            var select = "<select>";
            var type  = block_type;
            for(var i in type){
                select += "<option value='"+i+"'>"+type[i]+"</option>";
            }
            select += "</select>";
            cache.select_block_type = select;
            return select;
        }else{
            return  cache.select_block_type;
        }
    }

    function render_style_type_select() {
        if ( cache.select_type=="") {
            var select = "<select>";
            var colors  = word_type;
            for(var i in colors){
                var cc = (aip_type_colors[i]==undefined)?" rgba(0,0,0,.1)":aip_type_colors[i];
                select += "<option color='"+cc+"' value='"+i+"'>"+colors[i]+"</option>";
            }
            select += "</select>";
            cache.select_type = select;
            return select;
        }else{
            return  cache.select_type;
        }
    }

    function render_select_specify_type_select(spec) {
        var select = "<select id='spec_type' multiple>";
        var temp = type_spec[spec];
        for(var i in temp){
            var group = temp[i];
            select += "<optgroup label='"+i+"'>";
            for(var j in group){
                select += "<option value='"+j+"'>"+group[j]+"</option>";
            }
            select += "</optgroup>"

        }
        select += "</select>";
        return select;
    }

    function render_lang_trans_select() {
        if ( cache.select_type=="") {
            var select = "<select>";
            var lang  = lang_trans;
            for(var i in lang){
                select += "<option value='"+lang[i]+"'>"+i+"</option>";
            }
            select += "</select>";
            cache.select_type = select;
            return select;
        }else{
            return  cache.select_type;
        }
    }

    function prepare_block_select() {
        if ( cache.select_block_select=="") {
            var select = "<select>";
            var blocks  =    array_main_blocks();
            select += "<option value='all'>Celé heslo</option>";
            for(var i in blocks){
                select += "<option value='"+blocks[i].block+"'>"+blocks[i].span.substr(0,20)+"</option>";
            }
            select += "</select>";
            cache.select_block_select = select;
            return select;
        }else{
            return  cache.select_block_select;
        }
    }

    function render_select_font_style() {
        if ( cache.select_font_style=="") {
            var select = "<select>";
            var blocks = font_style;
            for(var i in blocks){
                select += "<option value='"+i+"'>"+blocks[i]+"</option>";
            }
            select += "</select>";
            cache.select_font_style = select;
            return select;
        }else{
            return  cache.select_font_style;
        }
    }


    function render_index_select() {
        if ( cache.select_block_index == ""  ) {
            var select = "<select>";
            for(var i in  word_index){
                select += "<option value='"+i+"'>"+word_index[i]+"</option>";
            }
            select += "</select>";
            cache.select_block_index = select;
            return select;
        }else{
            return  cache.select_block_index;
        }
    }

    function prepare_font_change_toolbar() {
        var font_change_toolbar_html = $('<div id="font_change_toolbar"></div>')
        var select_font_size = $(select).attr('wat','aip-size');
        var select_font_font = $(select).attr('wat','aip-font');
        var select_lang = $(select).attr('wat','lang');
        var font_size_arr = [];
        var font_font_arr = [];
        var font_style_arr = [];
        for(var i in text_styling){
            var font = text_styling[i];
            if (font_size_arr.indexOf(font[2])==-1) {
                font_size_arr.push(font[2]);
                select_font_size.append("<option value='"+font[2]+"'>"+font[2]+"</option>");
            }
            if (font_font_arr.indexOf(font[3])==-1) {
                font_font_arr.push(font[3]);
                select_font_font.append("<option value='"+font[3]+"'>"+font[3]+"</option>");
            }
        }
        for (var i in lang_trans ) {
            select_lang.append("<option value='"+i+"'>"+lang_trans[i]+"</option>");
        }

        var select_font_style = $(render_select_font_style()).attr('wat','aip-style');
        var select__ = $(render_index_select()).attr('wat','aip-index');
        $(top_toolbar).append(font_change_toolbar_html);
        font_change_toolbar_html.append('<i class="toolbar_ico material-icons" title="Velikost písma">format_size</i>').append(select_font_size).append('<i class="toolbar_ico material-icons" title="Styl písma">format_bold</i>').append(select_font_style).append('<i class="toolbar_ico material-icons" title="Písmo">language</i>').append(select_lang).append('<i class="toolbar_ico material-icons" id="block_index_icon" title="Nastavení indexu" >playlist_add</i>').append(select__);
        font_select_change_event(font_change_toolbar_html);
        font_change_toolbar_html.hide();
    }

    function render_record_type_select() {
        var type_change_toolbar_html = $('<div id="type_change_toolbar"><i class="toolbar_ico material-icons" title="Typ záznamu" >bookmark_border</i></div>');
        var select_ = $(select).append("<option value=''></option>");
        for(var i in record_type){
            select_.append("<option value='"+i+"'>"+record_type[i]+"</option>");
        }
        type_change_toolbar_html.append(select_);
        select_.change(function(){
            show_hint_msg("Typ hesla: "+$(this).find('option:selected').val());
            $(pageparts_div).attr('aip-type',$(this).find('option:selected').val());
        });
        $(top_toolbar).append(type_change_toolbar_html);
    }

    function render_block_author_select() {
        var type_change_toolbar_html = $('<div id="author_change_toolbar"><i class="toolbar_ico material-icons" title="Autor hesla v Dodatcích">receipt</i></div>');
        var select_ = $(select).append("<option value=''></option>");
        for(var i in block_author){
            select_.append("<option value='"+block_author[i]+"'>"+block_author[i]+"</option>");
        }
        type_change_toolbar_html.append(select_);
        select_.change(function(){
            show_hint_msg("Autor dodatku: "+$(this).find('option:selected').val());
            $('autor_dodatku').text($(this).find('option:selected').val());
        });
        $(top_toolbar).append(type_change_toolbar_html);
    }

    function render_block_editor_select() {
        var type_change_toolbar_html = $('<div id="author_change_toolbar2"><i class="toolbar_ico material-icons" title="Redaktor hesla">check_circle</i></div>');
        var select_ = $(select).append("<option value=''></option>");
        for(var i in block_editor){
            select_.append("<option value='"+block_editor[i]+"'>"+block_editor[i]+"</option>");
        }
        type_change_toolbar_html.append(select_);
        select_.change(function(){
            show_hint_msg("Redaktor hesla: "+$(this).find('option:selected').val());
            $('redaktor_hesla').text($(this).find('option:selected').val());
        });
        $(top_toolbar).append(type_change_toolbar_html);
    }

    function render_dictionary_author_select() {
        var type_change_toolbar_html = $('<div id="dictionary_author_change_toolbar"><i class="toolbar_ico material-icons" title="Autor hesla v SJS" >book</i></div>');
        var select_ = $(select);
        for(var i in dictionary_author){
            select_.append("<option value='"+dictionary_author[i]+"'>"+dictionary_author[i]+"</option>");
        }
        type_change_toolbar_html.append(select_);
        select_.change(function(){
          switch (get_url_params().dict) {
            case "MS":
                show_hint_msg("Autor hesla: "+$(this).find('option:selected').val().substr(0, 20));
                $('autor_hesla').text($(this).find('option:selected').val());
                break;
            case "RSI":
                show_hint_msg("Autor hesla: "+$(this).find('option:selected').val().substr(0, 20));
                $('autor_hesla').text($(this).find('option:selected').val());
                break;
            default:
                show_hint_msg("Autor slovniku: "+$(this).find('option:selected').val().substr(0, 20));
                $('autor_slovniku').text($(this).find('option:selected').val());
                break;
          }


        });
        $(top_toolbar).append(type_change_toolbar_html);
    }
