    var start_html = '<div class="div_list hidden-md hidden-lg container" style="padding: 0px !important;">%s</div>',
            div_html = {
                'headers': '<div class="text-center headers" style=" display: table;width: 100%;"><img src="%s" class="img-rounded"><h4>%s</h4></div>',
                'content_data': '<div class="row row_list" style="margin: 0px !important;"><div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 content_tr">%s</div><div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 pull-left content_td">%s</div></div>',
                'content_data_row': '<div class="row row_list content_data_row" style="margin: 0px !important;"><div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 content_tr">%s</div></div>',
                'controls': '<div class="controls" style=" display: table;width: 100%;">%s</div>',
                'nav_html': '<nav class="navbar navbar-default emcan_navbar"><div class="container-fluid"><div class="navbar-header"><button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#emcan-navbar" aria-expanded="false"><span class="sr-only"></span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button></div><div class="collapse navbar-collapse" id="emcan-navbar"><ul class="nav navbar-nav">%s</ul></div></div></nav>',
                'nav_dropdown': '<li class="dropdown"><a href="%s" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">%s</a><ul class="dropdown-menu">%s</ul></li>',
                'nav_link': '<li><a href="%s">%s</a></li>',
            };


    $(document).ready(function () {

        var $trim = function (str) {
            str = new String(str);
            return str.replace(/^\s+|\s+$/g, '');
        };

        var $sprintf = function (format, etc) {
            var text_format = new String(format);
            var parameters = arguments;
            var i = 1;
            return text_format.replace(/%((%)|s)/g, function (b) {
                return $trim(b[2] || parameters[i++]);
            });
        };

        $('table').each(function (table_index) {
            var tbody_html_list = [], th_list = [], i = 0;

            $('table:eq(' + table_index + ') thead tr th').each(function (th_index) {
                var $_content_tr = $('table:eq(' + table_index + ') thead tr th').eq(th_index).text();
                th_list[i] = $_content_tr;
                i++;
            });
            i = 0;
            $('table:eq(' + table_index + ') tbody tr td').each(function (td_index) {
                var $_content_tr = (Boolean(th_list[i]) != false ? th_list[i] : '');

                var $_content_td = $('table:eq(' + table_index + ') tbody tr td').eq(td_index).html();
                if ($trim($_content_tr) == '') {
                    tbody_html_list[td_index] = $sprintf(div_html.content_data_row, $_content_td) + '<hr>';
                } else {
                    tbody_html_list[td_index] = $sprintf(div_html.content_data, $_content_tr, $_content_td) + '<hr>';
                }
                i++;
                if (i == ($('table:eq(' + table_index + ') tbody tr:eq(0) td').length)) {
                    i = 0;
                }

            });

//            $('table').eq(table_index).addClass('hidden-xs');
//            $('table').eq(table_index).addClass('hidden-sm');
//            var table_html = $sprintf(start_html, tbody_html_list.join(' '));
//            $('table').eq(table_index).after(table_html);
//            tbody_html_list = [];
        });


        var link_html_list = [];
        $('#cssmenu > ul > li').each(function (link_index) {

            var link_list = [], i = 0;
            if ($('#cssmenu > ul > li').eq(link_index).hasClass('has-sub')) {
                link_list = [];
                $('#cssmenu > ul > li:eq(' + link_index + ') a').each(function (index_link) {
                    var $link = $('#cssmenu > ul > li:eq(' + link_index + ') a').eq(index_link);
                    var $link_html = $sprintf(div_html.nav_link, $link.attr('href'), $link.text());
                    link_list.push($link_html);
                });
                var $dropdown_text = $('#cssmenu > ul > li:eq(' + link_index + ') a').eq(0).text();
                var $dropdown_href = $('#cssmenu > ul > li:eq(' + link_index + ') a').eq(0).attr('href');
                if (link_list.length > 1) {
                    link_html_list.push($sprintf(div_html.nav_dropdown, $dropdown_href, $dropdown_text, link_list.slice(1).join(' ')));
                } else {
                    link_html_list.push($sprintf(div_html.nav_link, $dropdown_href, $dropdown_text, link_list.slice(1).join(' ')));
                }
            } else {
                var $link = $('#cssmenu > ul > li:eq(' + link_index + ') a').eq(0);
                link_html_list.push($sprintf(div_html.nav_link, $link.attr('href'), $link.text()));
            }
        });

        $('.navbar.navbar-default').addClass('old-navbar');
//        $('#cssmenu').html('');
        $('#cssmenu').after($sprintf(div_html.nav_html, link_html_list.join(' ')));

        $('.emcan_navbar').css({
            'background-color': $('#cssmenu').css('background-color'),
            'position': $('#cssmenu').css('position'),
            'top': '60px',
            'z-index': $('#cssmenu').css('z-index'),
        });
    });