/*$j(document).ready(function() {
    $j('#fast_search_url').keyup(
        function(e) {
            $j('#setting_body_container .setting_title_cnt').each(function(el) {$j(this).removeClass('hidden');});
            if(document.getElementById('fast_search_url').value){
                document.getElementById('setting_body_container').className = 'setting_body_container hide_superfluous';
            }else document.getElementById('setting_body_container').className = 'setting_body_container';

            let all_group = [...document.querySelectorAll('#setting_container_settings [id^="setting_block_"]')].map(elm => elm.id);
            let text = $j(this).val().replace(/( |<([^>]+)>)/ig, "").replace(/\r?\n/g, "").toLowerCase();
            if (text){ // Получаем все объекты содержащие поисковые фразы - search_value
                all_group.forEach((element) => {document.getElementById('container_'+ element).style.display = 'block';})
                $j('.search_cnt .search_block').each(function(el) {
                    let desired = $j(this).find('.search_value').text().replace(/( |<([^>]+)>)/ig, "").replace(/\r?\n/g, "").toLowerCase();
                    if (desired.includes(text)){
                        $j(this).removeClass('hidden')
                    }else $j(this).addClass('hidden');
                });

                // Проверяем есть ли что показывать в категории, если нет скрываем заголовки
                all_group.forEach((element) => {
                    let hidden_title = 1;
                    $j('#container_'+ element +' .search_block').each(function(el) {if($j(this).attr('class') === 'search_block'){hidden_title = 0;}});
                    if (hidden_title) $j('#container_'+ element +' .setting_title_cnt').each(function(el) {
                        if (element != 'setting_block_1'){
                            $j(this).addClass('hidden');
                        }else $j(this).removeClass('hidden')
                    });
                })

            }else{
                $j('#setting_body_container .setting_title_cnt').each(function(el) {
                    $j(this).removeClass('hidden');
                });


                all_group.forEach((element) => {document.getElementById('container_'+ element).style.display = 'none';});
                document.getElementById('container_setting_block_1').style.display = 'block';
                $j('.search_cnt .search_block').each(function(el) {$j(this).removeClass('hidden');}); // Показать всё, поиск пуст
            }
        }
    );



    $j('#fast_search_url').click(
        function(e) {
            if(document.getElementById('fast_search_url').value){
                document.getElementById('setting_body_container').className = 'setting_body_container hide_superfluous';
            }else{
                document.getElementById('setting_body_container').className = 'setting_body_container';
            }
            let all_group = [...document.querySelectorAll('#setting_container_settings [id^="setting_block_"]')].map(elm => elm.id);
            let text = $j(this).val().replace(/( |<([^>]+)>)/ig, "").replace(/\r?\n/g, "").toLowerCase();
            if (text){ // Получаем все объекты содержащие поисковые фразы - search_value
                all_group.forEach((element) => {document.getElementById('container_'+ element).style.display = 'block';})
                $j('.search_cnt .search_block').each(function(el) {
                        let desired = $j(this).find('.search_value').text().replace(/( |<([^>]+)>)/ig, "").replace(/\r?\n/g, "").toLowerCase();
                        if (desired.includes(text)){
                            $j(this).removeClass('hidden')
                        }else $j(this).addClass('hidden');
                    }
                );
            }else{
                $j('#setting_body_container .setting_title_cnt').each(function(el) {
                    $j(this).removeClass('hidden');
                });
                all_group.forEach((element) => {document.getElementById('container_'+ element).style.display = 'none';});
                document.getElementById('container_setting_block_1').style.display = 'block';
                $j('.search_cnt .search_block').each(function(el) {$j(this).removeClass('hidden');}); // Показать всё, поиск пуст
            }
        }
    );
});*/


function bring_back(){
    document.getElementById('setting_body_container').className = 'setting_body_container';
    let all_group = [...document.querySelectorAll('#setting_container_settings [id^="container_setting_block_"]')].map(elm => elm.id);
    all_group.forEach((element) => {
        document.getElementById(element).style.display = 'block';
    })
}

function sel_setting_block(el){
    if (document.getElementById('fast_search_url')){
        bring_back()
        document.getElementById('fast_search_url').value = '';
        document.getElementById('fast_search_url').click();
    }
    let all_group = [...document.querySelectorAll('#setting_container_settings [id^="setting_block_"]')].map(elm => elm.id);
    all_group.forEach((element) => {
        document.getElementById(element).className = '';
        document.getElementById('container_'+ element).style.display = 'none';
    })
    document.getElementById(el.id).className = 'select_group';
    document.getElementById('container_'+ el.id).style.display = 'block';
}


function sel_setting_tabs(cnt, el, id, n){
    let all_bt = [...document.querySelectorAll('#tabs_cnt_'+ id +' [id^="bt_tabs_tabs_cnt_"]')].map(elm => elm.id);
    all_bt.forEach((element) => {document.getElementById(element).className = 'setting_body_tabs';})
    let all_group = [...document.querySelectorAll('#'+ cnt +' [id^="block_tabs_cnt_"]')].map(elm => elm.id); // Список контейнеров с полями ввода
    all_group.forEach((element) => {document.getElementById(element).style.display = 'none';})
    document.getElementById(el.id).className = 'setting_body_tabs select_button';
    document.getElementById('block_tabs_cnt_'+ id +'_'+ n).style.display = 'block';
}
