var DORCATEGORY = {
	init:function(){
		window.addEventListener('load', function (){
		    DORCATEGORY.AjaxLoadData();
		});
	},
	ReloadProcess:function(){
		var html = "";
		html += '<div class="graph__preloader">';
	        html += '<div class="js-preloader preloader">';
	          html += '<b class="preloader__bar -bar1"></b>';
	          html += '<b class="preloader__bar -bar2"></b>';
	          html += '<b class="preloader__bar -bar3"></b>';
	          html += '<b class="preloader__bar -bar4"></b>';
	          html += '<b class="preloader__bar -bar5"></b>';
	        html += '</div>';
	    html += '</div>';
	    return html;
	},
	
	AjaxLoadData:function(){
		var checkAjax = jQuery(".tab_category_container").attr("data-ajaxload");
		var processHtml = DORCATEGORY.ReloadProcess();
		if(typeof checkAjax == "undefined") return false;
		
		jQuery(".tab_category_container").css("min-height",365);
		jQuery(".tab_category_container .graph__preloader").remove();
		jQuery(".tab_category_container").append(processHtml);
		var urlAjax = jQuery(".tab_category_container").attr("data-ajaxurl");
		var params = {}
		jQuery.ajax({
            url: urlAjax,
            data:params,
            type:"POST",
            success:function(data){
            	setTimeout(function(){
            		var results = JSON.parse(data);
	            	jQuery(".tab_category_container .graph__preloader").remove();
	            	jQuery(".tab_category_container").html(results);
	            	jQuery(".tab_category_container").css("min-height","auto");
					DORCATEGORY.CategoryCarousel(".lists_category");
            	},300);
                return false;
            }
        });
	},
	CategoryCarousel:function(objElement){
		$(objElement).slick({
	        dots: false,
	        arrows: true,
	        infinite: true,
	        rows:1,
	        slidesToShow: 5,
	        slidesToScroll: 5,
	        prevArrow:"<button type='button' class='slick-prev slick-arrow'><i class='fa fa-angle-left' aria-hidden='true'></i></button>",
            nextArrow:"<button type='button' class='slick-next slick-arrow'><i class='fa fa-angle-right' aria-hidden='true'></i></button>",
	        responsive: [
	        {
	          breakpoint: 1450,
	          settings: {
	            slidesToShow: 5,
	            slidesToScroll: 5,
	            infinite: true,
	            dots: false
	          }
	        },
	        {
	          breakpoint: 992,
	          settings: {
	            slidesToShow: 4,
	            slidesToScroll: 4
	          }
	        },
	        {
	          breakpoint: 768,
	          settings: {
	            slidesToShow: 3,
	            slidesToScroll: 3
	          }
	        },
	        {
	          breakpoint: 531,
	          settings: {
	            slidesToShow: 2,
	            slidesToScroll: 2
	          }
	        },
	        {
	          breakpoint: 321,
	          settings: {
	            slidesToShow: 1,
	            slidesToScroll: 1
	          }
	        }]
	    });
	},
}
jQuery(document).ready(function(){
	DORCATEGORY.init();
});