$(document).ready(function() {


    if ($(".offer_slider").length) {
        $('.offer_slider').slick({
            dots: true,
            infinite: true,
            speed: 300,
            slidesToShow: 1,
            variableWidth: true,
            arrows: false
        });
    }
    if ($(".promotion-wrapper-items").length) {
        $(".promotion-wrapper-items").slick({
            dots: false,
            infinite: true,
            speed: 300,
            slidesToShow: 5,
            arrows: true,
            responsive: [

                {
                    breakpoint: 640,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 2
                    }
                },
                {
                    breakpoint: 480,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 2
                    }
                },
                {
                    breakpoint: 380,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1
                    }
                }

            ]
        });
    }
    $('.dropdown-menu > a').click(function() {
            $(this).closest('.dropdown').find('.custom-dropdown').text($(this).text());
        })
        // show less and more content
    var showChar = 300;
    var ellipsestext = "...";
    var moretext = "show more";
    var lesstext = "show less";
    $('.content_paragraph').each(function() {
        var content = $(this).html();

        if (content.length > showChar) {

            var c = content.substr(0, showChar);
            var h = content.substr(showChar - 1, content.length - showChar);

            var html = c + '<span class="moreellipses">' + ellipsestext + '&nbsp;</span><span class="morecontent"><span>' + h + '</span>&nbsp;&nbsp;<a href="" class="morelink text-uppercase">' + moretext + '</a></span>';

            $(this).html(html);
        }

    });

    $(".morelink").click(function() {
        if ($(this).hasClass("less")) {
            $(this).removeClass("less");
            $(this).html(moretext);
        } else {
            $(this).addClass("less");
            $(this).html(lesstext);
        }
        $(this).closest('.content_paragraph').find('.morecontent span').toggle();
        //$(this).prev().toggle();
        return false;
    });
    $(".data-view-type .btn").click(function() {
        $(".data-view-type .btn").removeClass('active');
        $(this).addClass('active');
        if ($(this).hasClass('map')) {

            $(".location_data-map").show();
            $("body").removeClass('list-view');
            $(this).addClass('active');
        } else {

            $(".location_data-map").hide();
            $("body").addClass('list-view');

        }
    })
    $(".m-options .btn").click(function() {
        if ($(this).closest('.searchbar').hasClass('showmore')) {
            $(this).closest('.searchbar').removeClass('showmore');
            $(this).find('.mdi').removeClass('mdi-chevron-up');
            $(this).find('.txt').text($(this).attr('data-show'));
        } else {
            $(this).closest('.searchbar').addClass('showmore');
            $(this).find('.mdi').addClass('mdi-chevron-up');
            $(this).find('.txt').text($(this).attr('data-less'));
        }

    })



})