NProgress.start();
$(function () {
    $('.body').imagesLoaded({background: true}, function () {
        setTimeout(function () {
            $('.body').removeClass('unloaded').addClass('loaded');
            $('.preloading').css('opacity', 0).css('z-index', -1);
            NProgress.done();
        }, 500);
    });
    new WOW().init(
        {
            mobile: false
        }
    );

});


function kk_ajax(request, callback, data, type, async) {
    if (typeof(type) === 'undefined') {
        type = 'json';
    }
    if (typeof (async) === 'undefined') {
        async = true;
    }
    $.ajax({
        cache: false,
        async: async,
        xhrFields: {withCredentials: true},
        url:  "https://www.opencerthub.com/wp-content/themes/kkleo-theme-child/ajax.php",
        data: {request: request, data: data},
        type: "POST",
        dataType: type,
        withCredentials:true,
        success: function (msg) {
            if (type === 'html') {
                callback(msg);
            } else {
                callback(msg.response);
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
        }
    });
}

function getParameterByName(name, url) {
    if (!name) {
        return false;
    }
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}
