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').owlCarousel({
            items: 6,
	        loop: true,
	        navigation: false,
	        nav: false,
	        autoplay: false,
	        dots:true,
	        margin:20,
	        autoplaySpeed : 200,
			navSpeed : 200,
			dotsSpeed : 200,
			autoplayHoverPause: true,
	        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 ($('.suggestions-contents .product_list').find('article').length <= 1) {
		           this.settings.loop = false;
		        }
		    },
	        navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
        });
	},
	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();
});