class banersSliderButtonsAction {
    constructor(buttonsSetup){
        this.container = buttonsSetup.sliderContainer;
        this.catSecPostNames = buttonsSetup.nameList;
        this.catSecNamesCnt = this.catSecPostNames.length;
        this.catCurSec = 0;
        this.catNextSec = 1;
        this.catPrevSec = 1;
        this.setCatNames(this.catPrevSec, this.catNextSec);
    }

    setCatNames (prev, next) {
        //$('#span-swiper-prev', '.catalog-section-poster').html(catSecPostNames[prev]);
        $('#span-swiper-next', this.container).html(this.catSecPostNames[next]);
    }

    clickNext() {
        this.catCurSec++;
        if (this.catCurSec == this.catSecNamesCnt - 1) {
            this.catNextSec = 0;
            this.catPrevSec = this.catCurSec - 1;
        } else if (this.catCurSec > this.catSecNamesCnt - 1) {
            this.catCurSec = 0;
            this.catNextSec = this.catCurSec + 1;
            this.catPrevSec = this.catSecNamesCnt - 1;
        } else {
            this.catNextSec = this.catCurSec + 1;
            this.catPrevSec = this.catCurSec - 1;
        }
        this.setCatNames (this.catPrevSec, this.catNextSec);
    }

    clickPrev() {
        this.catCurSec--;
        if (this.catCurSec == 0) {
            this.catNextSec = 1;
            this.catPrevSec = this.catSecNamesCnt-1;
        } else if (this.catCurSec < 0) {
            this.catCurSec = this.catSecNamesCnt-1;
            this.catNextSec = 0;
            this.catPrevSec = this.catCurSec-1;
        } else {
            this.catNextSec = this.catCurSec + 1;
            this.catPrevSec = this.catCurSec - 1;
        }
        this.setCatNames (this.catPrevSec, this.catNextSec);
    }
};

jQuery(document).ready(function($) {
    var $licenceContainer = '.catalog-section-poster.licence';
    var licenceButtons =  new banersSliderButtonsAction({
        sliderContainer: $licenceContainer,
       // nameList: ['Royal Portraits', 'Custom Portraits', 'AI Technology Portraits', 'Creative kits', 'PSP Tagging tutorial']
        nameList: ['Active sales', 'Digital Marketplace', /*'Prepaid projects',*/ 'Creative kits', 'PSP Tagging tutorial']
    });
    $('.swiper-prev', $licenceContainer).click(function (e) {
        licenceButtons.clickPrev();
    });

    $('.swiper-next', $licenceContainer).click(function (e) {
        licenceButtons.clickNext();
    });

    var $shopContainer = '.catalog-section-poster.shop';
    var shopButtons = new banersSliderButtonsAction({
        sliderContainer: $shopContainer,
        //nameList: ['Royal Portraits', 'Custom Portraits', 'AI Technology Portraits', 'View store', ]
        nameList: [/*'Our store', 'PortrayMe.Art', */'Post Editor', 'Types of licenses']
    });
    $('.swiper-prev', $shopContainer).click(function (e) {
        shopButtons.clickPrev();
    });

    $('.swiper-next', $shopContainer).click(function (e) {
        shopButtons.clickNext();
    });
});