(function($) {
$(document).ready(function() {
    
        $(".blogs-widget-wrapper").each(function(){
                var $this = $(this);
                var options = $this.data("owl-options");
                if (options !== undefined) {

                    var autoplay_option             = ("true" == options.autoplay) ? true : false,
                        autoplay_timeout_option     = (options.autoplayTimeout) ? options.autoplayTimeout : "5000",
                        items_option                = options.items,
                        nav_option                  = ("true" == options.nav) ? true : false,
                        dots_option                  = ("true" == options.dots) ? true : false,
                        hover_pause_option          = ("true" == options.autoplayHoverPause) ? true : false,                        
                        tablet_option               = (options.tablet_cols) ? options.tablet_cols : $this.attr('data-cols-md'),
                        rtl_option                  = ("true" == options.rtl) ? true : false,
                        loop_option                 = ("true" == options.loop) ? true : false,                    
                        margin_option               = (options.margin !== undefined) ? parseInt(options.margin) : 30,

                    carousel_args = {
                        navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
                        margin: margin_option,
                        dots: dots_option,
                        loop: loop_option,
                        nav: nav_option,
                        autoplay: autoplay_option,
                        autoplayTimeout: autoplay_timeout_option,
                        autoplayHoverPause: hover_pause_option,
                        rtl: rtl_option,
                    };


                    carousel_args.responsive = {
                        0:{
                            items:1,
                        },
                        576:{
                            items: 2,
                        },
                        768:{
                            items: tablet_option,
                        },
                        992:{
                            items: items_option,
                        },
                        1200:{
                            items: items_option,
                        },
                    }
                    
                    $this.vcOwlCarousel(carousel_args)
                }
        });



});
}(jQuery));
(function($) {
$(document).ready(function() {
    $(document).on('vc-full-width-row', function() {
        $(".nb-fw-vccarousel").each(function(){
                var $this = $(this);
                var options = $this.data("owl-options");
                if (options !== undefined) {

                    var autoplay_option             = ("true" == options.autoplay) ? true : false,
                        autoplay_timeout_option     = (options.autoplayTimeout) ? options.autoplayTimeout : "5000",
                        items_option                = options.items,
                        nav_option                  = ("true" == options.nav) ? true : false,
                        dots_option                  = ("true" == options.dots) ? true : false,
                        hover_pause_option          = ("true" == options.autoplayHoverPause) ? true : false,                        
                        tablet_option               = (options.tablet_cols) ? options.tablet_cols : $this.attr('data-cols-md'),
                        rtl_option                  = ("true" == options.rtl) ? true : false,
                        loop_option                 = ("true" == options.loop) ? true : false,                    
                        margin_option               = (options.margin !== undefined) ? parseInt(options.margin) : 30,

                    carousel_args = {
                        navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
                        margin: margin_option,
                        dots: dots_option,
                        loop: loop_option,
                        nav: nav_option,
                        autoplay: autoplay_option,
                        autoplayTimeout: autoplay_timeout_option,
                        autoplayHoverPause: hover_pause_option,
                        rtl: rtl_option,
                    };


                    carousel_args.responsive = {
                        0:{
                            items:1,
                        },
                        576:{
                            items: 2,
                        },
                        768:{
                            items: tablet_option,
                        },
                        992:{
                            items: items_option,
                        },
                        1200:{
                            items: items_option,
                        },
                    }
                    
                    $this.vcOwlCarousel(carousel_args)
                }
        });


        

    });

});
}(jQuery));
function wpt_loadTabContent(tab_id, tab_name, page_num, container, args_obj) {
    
    var container = jQuery(container);
    var tab_content = container.find('#' + tab_id + '-' + tab_name + '-tab-content');
        
    // only load content if it wasn't already loaded

    
    var isLoaded = tab_content.data('loaded');
    
    if(tab_name == 0) {
        isLoaded = true;
    }
    
    if (!isLoaded || page_num != 1) {
        if (!container.hasClass('wpt-loading')) {
            container.addClass('wpt-loading');
            
            tab_content.load(wpt.rest_api_url + 'product_tabs', {
                    tab: tab_name,
                    page: page_num,
                    args: args_obj
                }, function() {
                    container.removeClass('wpt-loading');
                    tab_content.data('loaded', 1).hide().fadeIn().siblings().hide();
                }
            );
        }
    } else {
        tab_content.fadeIn().siblings().hide();
    }
}

//apply carousel to product tab content
(function($) {

    $(document).ready(function() {

        //call carousel after vc full width row loaded
        $(document).on('vc-full-width-row', function() {

            var dir = $('html').attr('dir');
            $('.vktab_widget_content').each(function() {

                var $this               = $(this),
                    args                = $this.data('args'),
                    wpt_tabs_modern     = $this.find('.modern-style .wpt-tabs'),
                    tab_item            = $this.find('.wpt-tabs .tab_title a'),
                    rtl_option          = ("rtl" == dir) ? true : false,
                    owl_items           = $this.find('.wpt-tabs .owl-item .tab_title'),
                    first_owl_item      = owl_items.first();

                // load tab modern style header carousel
                wpt_tabs_modern.vcOwlCarousel({
                    items: 6,
                    navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
                    nav: true,
                    rtl: rtl_option,
                    responsive: {
                        0:{
                            items:1,
                        },
                        576:{
                            items: 2,
                        },
                        768:{
                            items: 3,
                        },
                        992:{
                            items: 4,
                        },
                        1200:{
                            items: 6,
                        },
                    }
                });
                
                // load tab content on click
                tab_item.click(function(e) {
                    e.preventDefault();

                    var tab_id_parts    = this.id.split('-');
                    var tab_name        = tab_id_parts[1] || 0;
                    var tab_id          = tab_id_parts[0] || '';
                    var owl_item        = $(this).parent().parent();

                    if(owl_item.hasClass('owl-item')){
                        owl_item.addClass('selected').siblings().removeClass('selected');
                    }
                    else {
                        $(this).parent().addClass('selected').siblings().removeClass('selected');
                    }

                    $this   = $(this).parents('.vktab_widget_content');
                    args    = $this.data('args');

                    wpt_loadTabContent(tab_id, tab_name, 1, $this, args);
                    
                });
                
                first_owl_item.removeClass('selected');
                first_owl_item.parent().addClass('selected');
                
            });
            
        });
    });

    $(document).ajaxComplete(function( event, request, settings ) {

        $(".vk-tabcontent .nb_wc-products.nb-fw-carousel").each(function(){

            var $this = $(this);

            var options = $this.data("owl-options");

            if (options !== undefined) {

                var autoplay_option             = ("true" == options.autoplay) ? true : false,
                    autoplay_timeout_option     = (options.autoplayTimeout) ? options.autoplayTimeout : "5000",
                    items_option                = options.items,
                    nav_option                  = ("true" == options.nav) ? true : false,
                    dots_option                 = ("true" == options.dots) ? true : false,
                    hover_pause_option          = ("true" == options.autoplayHoverPause) ? true : false,                        
                    tablet_option               = (options.tablet_cols) ? options.tablet_cols : $this.attr('data-cols-md'),
                    rtl_option                  = ("true" == options.rtl) ? true : false,
                    loop_option                 = ("true" == options.loop) ? true : false,                    
                    margin_option               = (options.margin !== undefined) ? parseInt(options.margin) : 0,

                carousel_args = {
                    navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
                    margin: margin_option,
                    stagePadding: 15,
                    dots: dots_option,
                    loop: loop_option,
                    nav: nav_option,
                    autoplay: autoplay_option,
                    autoplayTimeout: autoplay_timeout_option,
                    autoplayHoverPause: hover_pause_option,
                    rtl: rtl_option,
                };

                carousel_args.responsive = {
                    0:{
                        items:1,
                    },
                    576:{
                        items: $this.attr('data-cols-sm'),
                    },
                    768:{
                        items: tablet_option,
                    },
                    992:{
                        items: items_option,
                    },
                    1200:{
                        items: items_option,
                    },
                }
                $this.addClass('imr-'+ margin_option);
                
                $this.vcOwlCarousel(carousel_args);
            }
        });
    });

}(jQuery));