// source --> https://deblaere-vandemaele.be/wp-content/plugins/crmart-insu_docusearch-3d102efc246e/js/script.js?ver=7.0 
jQuery(document).ready(function ($) {
    var partner = 0;
    var category = 'all';
    var freesearch = 'all';

    $('#docusearch_form #partner').change(function (e) {
        partner = $(this).val();
        $('#documentcenter #freesearch_form').hide();
        $('#documentcenter #results').hide();
        $('#free-search').val('');
        doCount();
    });

    $('#docusearch_form #category').change(function (e) {
        category = $(this).val();
        $('#documentcenter #freesearch_form').hide();
        $('#documentcenter #results').hide();
        $('#free-search').val('');
        doCount();
    });

    $('#docusearch_form').submit(function (e) {
        e.preventDefault();

        var partner = $('#documentcenter #partner').val();
        var category = $('#documentcenter #category').val();

        if (partner != 0) {
            $('#documentcenter #loader').show();

            freesearch = $('#documentcenter #free-search').val();
            if (freesearch == '') {
                freesearch = 'all';
            }

            $.ajax({
                url: "/wp-admin/admin-ajax.php",
                type: 'post',
                data: {
                    action: 'docusearch',
                    partner: partner,
                    category: category,
                    freesearch: freesearch,
                },
                success: function (data) {
                    $('#documentcenter #loader').hide();
                    $('#documentcenter #freesearch_form').show();
                    $('#documentcenter #results').show();
                    $('#documentcenter #results').html(data);
                }
            });
        }
        else {
            alert(script_texts.select_partner);
        }
        doCount();
    });

    function doCount() {
        $('#documentcenter #loader').show();

        $.ajax({
            url: "/wp-admin/admin-ajax.php",
            type: 'post',
            data: {
                action: 'docucount',
                partner: partner,
                category: category,
                freesearch: freesearch,
            },
            success: function (data) {
                $('#documentcenter #nrresults').html(data);
                $('#documentcenter #loader').hide();
            }
        });
    }
});
// source --> https://deblaere-vandemaele.be/wp-content/plugins/crmart-news//includes/js/crmart-news.js?ver=7.0 
(function ($) {
    'use strict';

    /**
     * All of the code for your public-facing JavaScript source
     * should reside in this file.
     *
     * Note: It has been assumed you will write jQuery code here, so the
     * $ function reference has been prepared for usage within the scope
     * of this function.
     *
     * This enables you to define handlers, for when the DOM is ready:
     *
     * $(function() {
     *
     * });
     *
     * When the window is loaded:
     *
     * $( window ).load(function() {
     *
     * });
     *
     * ...and/or other possibilities.
     *
     * Ideally, it is not considered best practise to attach more than a
     * single DOM-ready or window-load handler for a particular page.
     * Although scripts in the WordPress core, Plugins and Themes may be
     * practising this, we should strive to set a better example in our own work.
     */

    $(document).ready(function ($) {

        $('.image-loader').hide();

        $('#btn-more-news').on('click', function (e) {
            e.preventDefault();
            var count = $('#btn-more-news').attr('data-count');
            var exclude = $('#btn-more-news').attr('data-exclude');

            doAjax(count, exclude);
        });

        function doAjax(count, exclude) {
            $.ajax({
                url: "/wp-admin/admin-ajax.php",
                type: 'post',
                data: {
                    action: 'crmartnews',
                    count: count,
                    exclude: exclude,
                },
                beforeSend: function(){
                    $(".image-loader").show();
                },
                success: function (response) {
                    var obj = JSON.parse(response);
                    var arr = obj.exclude;
                    var string = JSON.stringify(arr);

                    $('div.news-row').append(obj.html);
                    $('#btn-more-news').attr('data-exclude', string);

                    if (arr.length == obj.total) {
                        $('#btn-more-news').hide();
                    }

                    $('.news-view .content').equalHeights();
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    $loader.html(jqXHR + " :: " + textStatus + " :: " + errorThrown);
                },
                complete:function(data){
                    $(".image-loader").hide();
                }
            });
        }

    });

})(jQuery);