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},
	            300: {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: 5,
	        slidesToScroll: 5,
	        rows:1,
	        responsive: [
	        {
	          breakpoint: 1199,
	          settings: {
	            slidesToShow: 5,
	            slidesToScroll: 5,
	            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: 350,
	          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'
			        });
					if(typeof OREGON != "undefined" && typeof OREGON.ToolTipBootstrap == "function"){
						OREGON.ToolTipBootstrap();
					}
					if(typeof OREGON != "undefined" && typeof OREGON.NewProductHome == "function"){
						OREGON.NewProductHome();
					}
					if(typeof OREGON.DorQuantity != "undefined" && typeof OREGON.DorQuantity == "function"){
	            		OREGON.DorQuantity();
	            	}
	            	if(typeof DORCORE != "undefined" && typeof DORCORE.LazyLoad != "undefined" && typeof DORCORE.LazyLoad == "function"){
	            		DORCORE.LazyLoad();
	            	}
            	},600);
                return false;
            }
        });
	},
}
jQuery(document).ready(function(){
	SUGGESTION.init();
});