jQuery.noConflict();
jQuery(document).ready(function ($) {

    'use strict';

    if (typeof dtspObjects !== 'undefined') {

        if (dtspObjects.enable_suggested_products) {

            if ($.cookie('wdt-suggested-product-cookie') === 'closed') {
                $('.suggested-product-list').remove();
            }

            $('.wdt_close').on('click', function () {
                $('.suggested-product-list').remove();
                $.cookie('wdt-suggested-product-cookie', 'closed', { expires: 1, path: '/' });
            });

            var elements = $('.suggested-product-list li');
            var init_element = 0;
            var i = 0;
            elements.removeClass('active');

            function suggestedProductElement() {
                if (i % 2 === 0) {
                    var currentItem = elements.eq(init_element);
                    currentItem.addClass('active');
                    setTimeout(function () {
                        currentItem.removeClass('active');
                    }, 4000);

                    init_element++;
                    if (elements.length === init_element) {
                        init_element = 0;
                    }
                }
                i++;
            }

            setInterval(function () {
                suggestedProductElement();
            }, 4000);
        }
    }

});
