    function log_history() {
        console.log('___________________');
        console.log(edit_history);
        console.log(edit_history[edit_history_stat].msg);
        console.log(edit_history_stat);
    }
    function add_history_step(msg) {
        var temp = {};
        temp.msg = msg;
        temp.block_view = active_block_view;
        temp.zoom = page_zoom_edit;
        var temp_html = $($(pageparts).html());
        if (temp_html.find(input).length>0) {
            var clone = cache.input_span_replace.clone();
            var val = temp_html.find(input ).val();
            clone.text(val);
            temp_html.find(input).replaceWith(clone);
        }
        temp.state = temp_html;
        if (edit_history[edit_history_stat] != undefined) {
            edit_history[edit_history_stat] = temp;
        }else{
            edit_history.push(temp);
        }
        edit_history_stat++;
    }
    function history_prev(button) {
        if (button!="") {
            button_highlight(button);
        }
        if (edit_history_stat-1 > -1) {
            $(pageparts).html('');
            var html = $(edit_history[edit_history_stat-1].state);
            $(pageparts).html(html)
            edit_history_stat--;
            page_zoom_edit = edit_history[edit_history_stat].zoom;
            html.find(span).each(function(){
                if ($(this).attr('aip-editable')=="true") {
                    block_part_set_events($(this));
                }else{
                    block_part_set_events($(this),false);
                }
                $(this).removeClass('selected_span');
            });
            set_key_bind_events();
            set_sortable_pageparts();
            show_layer_tools(edit_history[edit_history_stat].block_view);
        }
    }
    function history_next(button) {
        if (button!="") {
            button_highlight(button);
        }
        if (edit_history[edit_history_stat+1] != undefined) {
            $(pageparts).html('');
            var html = $(edit_history[edit_history_stat+1].state);
            $(pageparts).html(html)
            edit_history_stat++;
            page_zoom_edit = edit_history[edit_history_stat].zoom;
            html.find(span).each(function(){
                if ($(this).attr('aip-editable')=="true") {
                    block_part_set_events($(this));
                }else{
                    block_part_set_events($(this),false);
                }
                $(this).removeClass('selected_span');
            });
            set_key_bind_events();
            set_sortable_pageparts();
            if (edit_history[edit_history_stat] != undefined) {
                show_layer_tools(edit_history[edit_history_stat].block_view);
            }
        }else{
            console.log(edit_history[edit_history_stat]);
        }
    }
    function history_restore(button) {
        button_highlight(button);
        set_confirm_dialog("<span>Obnovit ? </span>",history_restore_confirm,300,200,"Zrušit","Obnovit");
    }
    function history_restore_confirm() {
        cache.first_loaded_xml = false;
        cache.load_mysql_backup =  undefined;
        start_full_loader(true);
        $('pageparts').html('');
        $(arround_page).html('');
        load_record(cache.load_record_id);
        if (edit_history[0]!=undefined) {
            page_zoom_edit = 0;
            edit_history_stat = -1;

            edit_history = [];
            add_history_step('refresh');
        }
    }
