<script>
    $(document).ready(function() {
        if ($("#toc_container .toc_list").length > 0) {
            var height = ($('#toc_container .toc_list').height());
            if (height > 300) {
                $("#toc_container .toc_list").css("height", 300 + "px");
                $("#toc_container .toc_list").parent().append('<div class="vuta_toc_readmore"><a title="Mở rộng" href="javascript:void(0);">Mở rộng</a></div>');
                $("body").on("click", ".vuta_toc_readmore", function() {
                    $("#toc_container .toc_list").removeAttr("style");
                    $("body .vuta_toc_readmore").remove();
                    $("#toc_container .toc_list").parent().append('<div class="vuta_toc_expand"><a title="Thu gọn" href="javascript:void(0);">Thu gọn</a></div>');
                });
                $("body").on("click", ".vuta_toc_expand a", function() {
                    $("#toc_container .toc_list").css("height", 300 + "px");
                    $("#toc_container .toc_list").parent().append('<div class="vuta_toc_readmore"><a title="Mở rộng" href="javascript:void(0);">Mở rộng</a></div>');
                    $("body .vuta_toc_expand").remove();
                });
            }
        }

        // Add smooth scrolling to all links
        $("#toc_container a").on('click', function(event) {

            // Make sure this.hash has a value before overriding default behavior
            if (this.hash !== "") {
                // Prevent default anchor click behavior
                event.preventDefault();

                // Store hash
                var hash = this.hash;
                window.location.hash = hash;

                // Using jQuery's animate() method to add smooth page scroll
                // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
                var to_offset = $(hash).offset().top - 100;
                $('html, body').animate({
                    scrollTop: to_offset
                }, 500);
            } // End if
        });
    });
</script>