let split = null;
function niceScrollResult() {
    if ($('.gutter.gutter-horizontal').length) {
        return;
    }
    if ($('.api').length) {
        if (window.innerWidth <= 991) {
            var split = Split(['#slpit-one', '#slpit-two'], {
                sizes: [50, 50],
                minSize: 0,
                direction: 'vertical',
                onDrag: function () {
                    $(".split-item").getNiceScroll().resize();
                    changeNavbarWidthDrag();
                },
            });

        }
        else {
            var split = Split(['#slpit-one', '#slpit-two'], {
                sizes: [50, 50],
                minSize: 0,
                onDrag: function () {
                    $("#slpit-one").getNiceScroll().resize();
                    $("#slpit-two").getNiceScroll().resize();
                    changeNavbarWidthDrag();
                },
            });

        }
        //changeNavbarWidth();

        setTimeout(function () {
            $("#slpit-one").getNiceScroll().resize();
            $("#slpit-two").getNiceScroll().resize();
        }, 400);


        $(window).bind('resize', function () {
            //changeNavbarWidth();

            var width = window.innerWidth;
            var splitDirection = (width <= 991) ? 'vertical' : 'horizontal';
            split.destroy();
            split = Split(['#slpit-one', '#slpit-two'], {
                sizes: [50, 50],
                minSize: 20,
                direction: splitDirection,
                onDrag: function () {
                    $(".split-item").getNiceScroll().resize();
                    //changeNavbarWidthDrag();
                },
            });
        }).trigger('resize');
    }
    //split
    $(".split-item").niceScroll({
        autohidemode: 'false'
    });

    //*** Split vertical/horizontal screen for test pages
    if (window.innerWidth <= 991) {
        $('.question-panel .qp-items').niceScroll({
            autohidemode: 'true'
        });
    }

    $("a.explanation-click").each(function () {
        $(this).click(function () {
            var currentPosition = $("#slpit-one").scrollTop();
            setTimeout(function () {
                if ($(window).width() > 768) {
                    $(".split-item").getNiceScroll().resize();
                    $("#slpit-one").scrollTop(currentPosition);
                }
            }, 500);
        });
    });

}

niceScrollResult();

