var SUGGESTION = {
	init:function(){
		SUGGESTION.AlsoLike();
		SUGGESTION.SuggestionsCarousel();
		SUGGESTION.LoadDefault();
	},
	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;
    },
	AlsoLike:function(){
		$('.product_list_alsolike').owlCarousel({
            items: 6,
	        loop: true,
	        navigation: true,
	        nav: true,
	        autoplay: true,
	        margin:20,
	        responsive: {
	            0: {items: 1},
	            1200: {items: 6},
	            992: {items: 4},
	            650: {items: 3, margin:20},
	            370: {items: 2, margin:20},
	            320: {items: 1, margin:20}
	        },
	        onInitialize: function (event) {
		        if ($('.product_list_alsolike').find('article').length <= 1) {
		           this.settings.loop = false;
		        }
		    },
	        navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
        });
	},
	SuggestionsCarousel:function(){
        $('.suggestions-contents .product_list').slick({
	        dots: true,
	        arrows: false,
	        infinite: true,
	        slidesToShow: 4,
	        slidesToScroll: 4,
	        rows:1,
	        responsive: [
	        {
	          breakpoint: 1199,
	          settings: {
	            slidesToShow: 4,
	            slidesToScroll: 4,
	            infinite: true,
	            dots: true
	          }
	        },
	        {
	          breakpoint: 991,
	          settings: {
	            slidesToShow: 3,
	            slidesToScroll: 3
	          }
	        },
	        {
	          breakpoint: 767,
	          settings: {
	            slidesToShow: 3,
	            slidesToScroll: 3
	          }
	        },
	        {
	          breakpoint: 580,
	          settings: {
	            slidesToShow: 2,
	            slidesToScroll: 2
	          }
	        },
	        {
	          breakpoint: 320,
	          settings: {
	            slidesToShow: 1,
	            slidesToScroll: 1
	          }
	        }]
	      });
	},
	LoadDefault:function(){
		var checkStatus = jQuery(".suggestions-contents").attr("data-ajaxload");
		if(typeof checkStatus == "undefined" || checkStatus == 0) return false;
		var processHtml = SUGGESTION.ReloadProcess();
		jQuery(".suggestions-contents .graph__preloader").remove();
		jQuery(".suggestions-contents").append(processHtml);
		jQuery(".suggestions-contents").css({
            'position':'relative',
            'min-height':350
        });
		var urlAjax = jQuery(".suggestions-contents").attr("data-ajaxurl");
		var params = {}
		jQuery.ajax({
            url: urlAjax,
            data:params,
            type:"POST",
            success:function(data){
            	setTimeout(function(){
            		var results = JSON.parse(data);
            		jQuery(".suggestions-contents .graph__preloader").remove();
            		jQuery(".suggestions-contents").html(results);
            		jQuery(".suggestions-contents").css({
			            'position':'relative',
			            'min-height':'auto'
			        });
					SUGGESTION.SuggestionsCarousel();
            	},600);
                return false;
            }
        });
	},
}
jQuery(document).ready(function(){
	SUGGESTION.init();
});