// source --> https://shop.ducatibarcelona.com/wp-content/plugins/fluid-responsive-slideshow/js/frs.js?ver=2.3.1 
/**
 * Tonjoo Fluid Responsive Slideshow
 * Copyright 2013, Tonjoo
 * Free to use under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 */

;(function($) {

    $.fn.frs = function(options) {

        //Defaults to extend options
        var defaults = {
            'animation': 'horizontal-slide', // horizontal-slide, vertical-slide, fade
            'animationSpeed': 600, // how fast animtions are
            'timer': false, // true or false to have the timer
            'advanceSpeed': 4000, // if timer is enabled, time between transitions 
            'pauseOnHover': true, // if you hover pauses the slider
            'startClockOnMouseOut': false, // if clock should start on MouseOut
            'startClockOnMouseOutAfter': 1000, // how long after MouseOut should the timer start again
            'directionalNav': true, // manual advancing directional navs
            'captions': true, // do you want captions?
            'captionAnimation': 'fade', // fade, slideOpen, none
            'captionAnimationSpeed': 600, // if so how quickly should they animate in
            'bullets': false, // true or false to activate the bullet navigation
            'bulletThumbs': false, // thumbnails for the bullets
            'bulletThumbLocation': '', // location from this file where thumbs will be
            'afterSlideChange': function() {}, // empty function 
            'navigationSmallTreshold': 650,
            'navigationSmall': false,
            'skinClass': 'default',
            'width': 650,
            'height': 350,
            'fullWidth': false,
            'minHeight': 300,
            'maxHeight': 0, // '0' (zero) to unlimited
            'sbullets': false,
            'sbulletsItemWidth': 200,                        
            'continousSliding': false,
            'jsOnly': false,
            'slideParameter': []
        };


        // Extend those options
        var options = $.extend(defaults, options);

        frs_id = "#" + this.attr("id") + "-slideshow";
       
        return this.each(function() {

            // ==============
            // ! SETUP   
            // ==============
            // Global Variables
            var activeSlide = 0,
                activeSlideContinous = 0,
                numberSlides = 0,
                frsWidth,
                frsHeight,
                locked,
                caption_position,
                timeout;

            // Initialize
            var slideWrapper = $(this).children('.frs-slide-img-wrapper').addClass('frs-slide-img-wrapper');
            var frs = slideWrapper.wrap('<div class="frs-slideshow-content" />').parent();            
            var frsWrapper = frs.wrap('<div id="' + $(this).attr("id") + '-slideshow" class="frs-wrapper ' + options.skinClass.toLowerCase() + '" />').parent();
            var first_run = true
            var old_responsive_class = 'responsive-full'
            var responsiveClassLock = false

            //Lock slider before all content loaded
            frs_slider_lock();

            // Initialize and show slider after all content loaded
            var imgWidth = [],
                imgHeight = [],
                imgCount = 0;

            $(slideWrapper.children()).imagesLoadedFRS()
                .progress( function( instance, image ) {
                    // collecting slide img original size
                    if($(image.img).parent().attr('class') == 'frs-slide-img')
                    {
                        imgWidth[imgCount] = image.img.width;
                        imgHeight[imgCount] = image.img.height;

                        imgCount++;
                    }
                })
                .always( function( instance ) {
                    
                    $(window).trigger('resize.frs-slideshow-container', true);

                    slideWrapper.fadeIn(function(){
                        $(this).css({"display": "block"});
                    })

                    slideWrapper.children().fadeIn(function(){
                        $(this).css({"display": "block"});
                    })
                    
                    frsWrapper.children('.frs-slideshow-content').fadeIn(function(){
                        $(this).css({"display": "block"});
                    })

                    frsWrapper.children('.frs-timer').fadeIn(function(){
                        $(this).css({"display": "block"});
                    })

                    frsWrapper.children('.frs-slider-nav').fadeIn(function(){
                        $(this).css({"display": "block"});
                    })

                    frsWrapper.children('.frs-bullets-wrapper').fadeIn(function(){
                        $(this).css({"display": "block"});

                        //unlock event in last displayed element
                        // if(options.timer) frs_slider_unlock();
                        frs_slider_unlock();

                        // hide the loader image
                        frsWrapper.children('.frs-slideshow-content').css('background-image','none');
                    })
                })


            frs.css({
                'height': options.height,
                'max-width': options.width
            });

            frsWrapper.parent().css({
                'height': options.height,
                'max-width': options.width
            });

            // Full width
            if(options.fullWidth == true)
            {
                frs.css({
                    'max-width': '100%'
                });

                frsWrapper.parent().css({
                    'max-width': '100%'
                });
            }


            frs.add(frsWidth)

            // Collect all slides and set slider size of largest image
            var slides = slideWrapper.children('div');

            // Count slide
            slides.each(function(index,slide) {

                numberSlides++;
            });

            // Animation locking functions
            function frs_slider_unlock() {
                locked = false;
            }

            function frs_slider_lock() {
                locked = true;
            }

            // If there is only a single slide remove nav, timer and bullets
            if (slides.length == 1) {
                options.directionalNav = false;
                options.timer = false;
                options.bullets = false;
            }

            // Set initial front photo z-index and fades it in
            if(options.continousSliding)
            {
                slides.eq(activeSlide)
                    .css({
                        "z-index": 3,
                        "display": "block",
                        "left": 0
                    })
                    .fadeIn(function() {
                        //brings in all other slides IF css declares a display: none
                        slides.css({
                            "display": "block"
                        })
                    });
            }



            // ====================
            // ! CALCULATE SIZE   
            // ====================
            function calculateHeightWidth() 
            {
                frsWidth = frs.innerWidth();

                var minus_resize = options.width - frsWidth;
                var percent_minus = (minus_resize / options.width) * 100;
                frsHeight = options.height - (options.height * percent_minus / 100);

                // max and min height
                if(frsHeight <= options.minHeight)
                {
                    frsHeight = options.minHeight;
                }
                else if(frsHeight >= options.maxHeight && options.maxHeight > 0)
                {
                    frsHeight = options.maxHeight;
                }

                applyImageSize() // apply image size
            }



            // ====================
            // ! APPLY IMAGE SIZE
            // ====================
            function applyImageSize()
            {
                var images = slideWrapper.find('.frs-slide-img').children('img');

                $.each(images,function(index){
                    var width = frsWidth;
                    var height = getImgHeight(width,index);

                    if(frsHeight > height) 
                    {
                        var curImgWidth = getImgWidth(frsHeight,index);
                        var curDiffWidth = (curImgWidth - width) * -1;

                        $(this).css({
                            'height': frsHeight + 'px',
                            'width': curImgWidth + 'px',
                            'max-height': frsHeight + 'px',
                            'max-width': curImgWidth + 'px',
                            'margin-left': curDiffWidth / 2  + 'px'
                        })

                        // neutralize
                        $(this).css({
                            'margin-top': ''
                        })
                    }
                    else 
                    {
                        var diff = frsHeight - height;

                        $(this).css('margin-top', (diff / 2) + 'px');

                        $(this).css({
                            'width': width + 'px',
                            'max-width': width + 'px'
                        })

                        // neutralize
                        $(this).css({
                            'height': 'auto',
                            'max-height':'none',
                            'margin-left': ''
                        })
                    }

                    // width                    
                    $(this).parent().width(width);                    
                });
            }

            /**
             * Function: getImgHeight
             */
            getImgHeight = function(width,index)
            {
                var Twidth = imgWidth[index];
                var Theight = imgHeight[index];

                var minusResize = Twidth - width;
                var percentMinus = (minusResize / Twidth) * 100;
                var height = Theight - (Theight * percentMinus / 100);
                    height = Math.round(height);

                return height
            }

            /**
             * Function: getImgWidth
             */
            getImgWidth = function(height,index)
            {
                var Twidth = imgWidth[index];
                var Theight = imgHeight[index];

                var minusResize = Theight - height;
                var percentMinus = (minusResize / Theight) * 100;
                var width = Twidth - (Twidth * percentMinus / 100);
                    width = Math.round(width);

                return width;
            }



            // ========================
            // ! CHECK AND APPLY CSS 3
            // ========================
            var vendorPrefix;

            function css3support() {
                var element = document.createElement('div'),
                    props = [ 'perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective' ];
                for ( var i in props ) {
                    if ( typeof element.style[ props[ i ] ] !== 'undefined' ) {
                        vendorPrefix = props[i].replace('Perspective', '').toLowerCase();
                        return options.jsOnly ? false : true;
                    }
                }

                return false;
            };



            // ================
            // ! SETUP LAYOUT
            // ================
            var grouped_slideshow = "";

            if(! options.continousSliding)
            {
                if(options.animation == "horizontal-slide")
                {
                    slides.css({
                        "position": "relative",
                        "float": "left",
                        "display": "block",
                        "width": frsWidth + "px",
                        "height": + "100%"
                    });
                   
                    slides.parent().css({"width": frsWidth * numberSlides + "px", "height": frsHeight + "px"});
                }
                else if(options.animation == "vertical-slide")
                {
                    slides.parent().css({"width": frsWidth + "px", "height": frsHeight * numberSlides + "px"});

                    slides.css({
                        "position": "relative",
                        "display": "block",
                        "width": frsWidth + "px",
                        "height": frsHeight + "px"
                    });
                }
                else if(options.animation == "fade")
                {
                    slides.parent().css({"width": frsWidth + "px", "height": frsHeight + "px"});

                    slides.css({
                        "z-index": 1,
                        "width": frsWidth + "px",
                        "height": frsHeight + "px"
                    });

                    slides.eq(activeSlide).css({"z-index": 3});
                }
            }



            // ==============
            // ! TIMER   
            // ==============
            date = new Date();
            milliseconds = date.getTime();
            start_seconds = milliseconds / 1000;

            function log_time() {
                date = new Date();
                milliseconds = date.getTime();
                seconds = milliseconds / 1000;
                seconds = seconds - start_seconds;         
            }

            //Timer Execution
            function startCfrs_slider_lock() {

                if (!options.timer || options.timer == 'false') {
                    return false;
                                
                /**
                 * Because in startup timer is always hidden
                 * use this if you want to change the behaviour
                 *
                 * } else if (timer.is(':hidden')) {
                 *       timerRunning = true;
                 *       clock = setInterval(function(e) {
                 *
                 *           shift("next");
                 *
                 *      }, options.advanceSpeed);
                 *
                 */

                } else if(! css3support()) {
                    timerRunning = true;
                    pause.removeClass('frs-timer-active')
                    clock = setInterval(function(e) {
                
                        shift("next");
                
                    }, options.advanceSpeed);
                } else {
                    timerRunning = true;
                    pause.removeClass('frs-timer-active')
                    clock = setInterval(function(e) {

                        var degreeCSS = "rotate(" + degrees + "deg)"
                        rotator.css('-' + vendorPrefix + '-transform', degreeCSS);
                        degrees += 1
                        if (degrees >= 180) {

                            mask.addClass('frs-timer-move')
                            rotator.addClass('frs-timer-move')
                            mask_turn.css("display", "block")

                        }
                        if (degrees >= 360) {

                            degrees = 0;
                            mask.removeClass('frs-timer-move')
                            rotator.removeClass('frs-timer-move')
                            mask_turn.css("display", "none")

                            shift("next");
                        }
                    }, options.advanceSpeed / 360);
                }
            }

            function stop_slider_lock() {
                if (!options.timer || options.timer == 'false') {
                    return false;
                } else {
                    timerRunning = false;
                    clearInterval(clock);
                    pause.addClass('frs-timer-active');
                }
            }


            // Timer Setup
            if (options.timer) {
                var timerHTML = '<div class="frs-timer"><span class="frs-timer-mask"><span class="frs-timer-rotator"></span></span><span class="frs-timer-mask-turn"></span><span class="frs-timer-pause"></span></div>'
                frsWrapper.append(timerHTML);
                var timer = frsWrapper.children('div.frs-timer'),
                    timerRunning;
                if (timer.length != 0) {
                    var rotator = $(frs_id + ' div.frs-timer span.frs-timer-rotator'),
                        mask = $(frs_id + ' div.frs-timer span.frs-timer-mask'),
                        mask_turn = $(frs_id + ' div.frs-timer span.frs-timer-mask-turn'),
                        pause = $(frs_id + ' div.frs-timer span.frs-timer-pause'),
                        degrees = 0,
                        clock;
                    startCfrs_slider_lock();
                    timer.click(function() {
                        if (!timerRunning) {
                            startCfrs_slider_lock();
                        } else {
                            stop_slider_lock();
                        }
                    });
                    if (options.startClockOnMouseOut) {
                        var outTimer;
                        frsWrapper.mouseleave(function() {

                            outTimer = setTimeout(function() {
                                if (!timerRunning) {
                                    startCfrs_slider_lock();
                                }
                            }, options.startClockOnMouseOutAfter)
                        })
                        frsWrapper.mouseenter(function() {
                            clearTimeout(outTimer);
                        })
                    }
                }
            }

            // Pause Timer on hover
            if (options.pauseOnHover) {
                frsWrapper.mouseenter(function() {

                    stop_slider_lock();
                });
            }



            // ==================
            // ! DIRECTIONAL NAV   
            // ==================
            // DirectionalNav { rightButton --> shift("next"), leftButton --> shift("prev");
            if (options.directionalNav) {
                if (options.directionalNav == "false") {
                    return false;
                }
                var directionalNavHTML = '<div class="frs-slider-nav ' + caption_position + '"><span class="frs-arrow-right">›</span><span class="frs-arrow-left">‹</span></div>';
                frsWrapper.append(directionalNavHTML);
                var leftBtn = frsWrapper.children('div.frs-slider-nav').children('span.frs-arrow-left'),
                    rightBtn = frsWrapper.children('div.frs-slider-nav').children('span.frs-arrow-right');
                leftBtn.click(function() {
                    stop_slider_lock();
                    shift("prev");
                });
                rightBtn.click(function() {
                    stop_slider_lock();
                    shift("next")
                });
            }

            if (options.navigationSmall) {

                $(window).resize(function() {
                    if ($(window).width() < options.navigationSmallTreshold) {
                        frs.siblings("div.frs-slider-nav").addClass('small')
                    } else {
                        frs.siblings("div.frs-slider-nav").removeClass('small')
                    }
                });

                if (frs.width() < options.navigationSmallTreshold) {
                    frs.siblings("div.frs-slider-nav").addClass('small')
                }
            }



            // ==================
            // ! BULLET NAV   
            // ==================
            if (options.bullets) 
            {                
                var bulletHTML = '<ul class="frs-bullets"></ul>';

                if(options.sbullets)
                {
                    bulletHTML = '<ul class="frs-bullets frs-sbullets"></ul>';
                }

                var bulletHTMLWrapper = "<div class='frs-bullet-wrapper'></div>";
                frsWrapper.append(bulletHTML);

                var bullets = frsWrapper.children('ul.frs-bullets');
                for (i = 0; i < numberSlides; i++) {
                    var liMarkup = $('<li class="frs-slideshow-nav-bullets"></li>'); // If you want default numbering, add: (i + 1)
                    if (options.bulletThumbs) {
                        var thumbName = slides.eq(i).data('thumb');
                        if (thumbName) {
                            var liMarkup = $('<li class="has-thumb">' + i + '</li>')
                            liMarkup.css({
                                "background": "url(" + options.bulletThumbLocation + thumbName + ") no-repeat"
                            });
                        }
                    }
                    frsWrapper.children('ul.frs-bullets').append(liMarkup);
                    liMarkup.data('index', i);
                    liMarkup.click(function() {
                        stop_slider_lock();
                        shift($(this).data('index'));
                    });
                }
               
                bullets.wrap("<div class='frs-bullets-wrapper " + caption_position + "' />")
                setActiveBullet();
            }



            /**
             * SLIDING BULLETS
             */
            var sbullets = 0;
            var bulletsWalkingWidth = 0;            
            var bulletsMaxShowedIndex = 0;
            var bulletsBackChild = 0;
            var bulletsNextChild = 0;
            var bulletsOffsetWidth = 0;
            var bulletsPosition = 0;                        
            var bulletsOffsetEnable = false;
            var bulletsWidth = 0;
            var bulletsMovedWidth = 0;

            var each_width = options.sbulletsItemWidth;
            var total_width = each_width * numberSlides;
            
            /** 
             * generate slide bullet 
             * this function will be recall every slideshow resized
             */
            function generate_slide_bullet()
            {
                sbullets = frsWrapper.find('ul.frs-sbullets');

                bulletsWalkingWidth = 0;
                bulletsMaxShowedIndex = 0;
                bulletsBackChild = 0;
                bulletsNextChild = 0;
                bulletsOffsetWidth = 0;
                bulletsPosition = 0;                        
                bulletsOffsetEnable = false;              
                bulletsWidth = sbullets.parent().outerWidth(true);

                if(bulletsWidth > total_width)
                {
                    each_width = bulletsWidth / numberSlides;
                    total_width = each_width * numberSlides;
                }
                                
                sbullets.parent().css('overflow', 'hidden');
                sbullets.css('background-color', sbullets.children('li').last().css("background-color"));
                sbullets.children('li.frs-slideshow-nav-bullets').css('width',each_width + 'px');                
                sbullets.css('width', total_width + 'px');

                sbullets.find('li').each(function() {
                    bulletsWalkingWidth += each_width;

                    if (bulletsWalkingWidth + each_width > bulletsWidth) 
                    {
                        bulletsNextChild = $(this).index();
                        bulletsMaxShowedIndex = bulletsNextChild;
                    }
                    
                    if (bulletsWalkingWidth > bulletsWidth) 
                    {
                        $(this).addClass('frs-bullet-sliding-next');
                        bulletsOffsetWidth = bulletsWalkingWidth - bulletsWidth;

                        /* detect if bullets offset is too large */
                        if(bulletsOffsetWidth < each_width)
                        {
                            bulletsOffsetEnable = true;
                        }

                        return false;
                    }
                });
            }

            function slide_bullet(navigate)
            {
                if(navigate == 'next')
                {
                    if(sbullets.children('li').eq(numberSlides - 1).hasClass("frs-bullet-sliding-next"))
                    {
                        bulletsNavPixelWidth = (each_width * bulletsPosition) + bulletsOffsetWidth;
                    }
                    else
                    {
                        sbullets.children('li').removeClass('frs-bullet-sliding-back').removeClass('frs-bullet-sliding-next');

                        bulletsPosition++;
                        bulletsBackChild++;
                        bulletsNextChild++;

                        bulletsNavPixelWidth = (each_width * bulletsPosition) + bulletsOffsetWidth;
                    }

                    slide_bullet_add_class('sliding_one','frs-bullet-sliding-one-back',bulletsBackChild + 1)            
                }
                else if(navigate == 'back')
                {
                    sbullets.children('li').removeClass('frs-bullet-sliding-back').removeClass('frs-bullet-sliding-next');

                    bulletsPosition--;
                    bulletsBackChild--;
                    bulletsNextChild--;

                    bulletsNavPixelWidth = each_width * bulletsPosition;

                    slide_bullet_add_class('sliding_one','frs-bullet-sliding-one-next',bulletsNextChild - 1)
                }
                else if(navigate == 'first')
                {
                    sbullets.children('li').removeClass('frs-bullet-sliding-back').removeClass('frs-bullet-sliding-next');

                    bulletsPosition = 0;
                    bulletsBackChild = 0;                    
                    bulletsNextChild = bulletsMaxShowedIndex;

                    bulletsNavPixelWidth = each_width * bulletsPosition;

                    slide_bullet_add_class('sliding_one','frs-bullet-sliding-one-next',bulletsNextChild - 1)
                }
                else if(navigate == 'last')
                {
                    sbullets.children('li').removeClass('frs-bullet-sliding-back').removeClass('frs-bullet-sliding-next');

                    var numberBulletsByIndex = numberSlides - 1;

                    bulletsPosition = numberBulletsByIndex - bulletsMaxShowedIndex;
                    bulletsBackChild = numberBulletsByIndex - bulletsMaxShowedIndex;
                    bulletsNextChild = numberBulletsByIndex;

                    bulletsNavPixelWidth = (each_width * bulletsPosition) + bulletsOffsetWidth;

                    slide_bullet_add_class('sliding_one','frs-bullet-sliding-one-back',bulletsBackChild + 1)
                }

                /**
                 * Track moved width
                 */
                bulletsMovedWidth = bulletsNavPixelWidth;
                
                if(css3support())
                {
                    var properties = {};
                    properties[ '-' + vendorPrefix + '-transition-duration' ] = options.animationSpeed + 'ms';
                    properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d(-' + bulletsNavPixelWidth + 'px, 0, 0)';

                    sbullets.css(properties);
                }
                else
                {
                    sbullets
                        .animate({
                            "left": '-' + bulletsNavPixelWidth + 'px'
                        }, options.animationSpeed);
                }
                
                // Apply class to bullet
                slide_bullet_add_class('sliding', 'frs-bullet-sliding-back', bulletsBackChild)
                slide_bullet_add_class('sliding', 'frs-bullet-sliding-next', bulletsNextChild)
            }

            function slide_bullet_add_class(li_type, li_class, li_index)
            {
                if(li_type == 'sliding_one')
                {
                    if(bulletsOffsetEnable == true)
                    {
                        sbullets.children('li').removeClass('frs-bullet-sliding-one-back').removeClass('frs-bullet-sliding-one-next');
                        
                        var addClassTo = sbullets.children('li').eq(li_index)

                        if(addClassTo.attr('class') == "frs-slideshow-nav-bullets")
                        {
                            addClassTo.addClass(li_class);
                        }                        
                    }
                }  
                else if(li_type == 'sliding')
                {
                    if(sbullets.children('li').eq(li_index).attr('class') == 'frs-slideshow-nav-bullets frs-bullets-active' && li_index > 0 )
                    {
                        if(li_class == 'frs-bullet-sliding-back')
                        {
                            li_index--
                        }
                        else if(li_class == 'frs-bullet-sliding-next')
                        {
                            li_index++
                        }
                    }

                    sbullets.children('li').eq(li_index).removeClass('frs-bullet-sliding-one-back')
                    sbullets.children('li').eq(li_index).removeClass('frs-bullet-sliding-one-next')
                    sbullets.children('li').eq(li_index).addClass(li_class)
                }              
            }

            function slide_bullet_one(type)
            {
                var oneMove = 0;

                sbullets.children('li').removeClass('frs-bullet-sliding-one-back').removeClass('frs-bullet-sliding-one-next');

                if(type == 'back')
                {
                    sbullets.children('li').eq(bulletsNextChild - 1).addClass('frs-bullet-sliding-one-next');

                    oneMove = bulletsMovedWidth - bulletsOffsetWidth;
                }
                else
                {
                    sbullets.children('li').eq(bulletsBackChild + 1).addClass('frs-bullet-sliding-one-back');

                    oneMove = bulletsMovedWidth + bulletsOffsetWidth;
                }

                /**
                 * Track moved width
                 */
                bulletsMovedWidth = oneMove;

                if(css3support())
                {
                    var properties = {};
                    properties[ '-' + vendorPrefix + '-transition-duration' ] = options.animationSpeed + 'ms';
                    properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d(-' + oneMove + 'px, 0, 0)';

                    sbullets.css(properties);
                }
                else
                {
                    sbullets
                        .animate({
                            "left": '-' + oneMove + 'px'
                        }, options.animationSpeed);
                }
            }


            /**
             * SET ACTIVE BULLETS
             */
            function setActiveBullet() {
                if (!options.bullets) {
                    return false;
                } else {
                    bullets.children('li').removeClass('frs-bullets-active').eq(activeSlide).addClass('frs-bullets-active');

                    /**
                     * begin slide bullets
                     */
                    if(options.sbullets)
                    {
                        if(bullets.children('li.frs-bullets-active').hasClass('frs-bullet-sliding-next'))
                        {
                            if(bullets.children('li.frs-bullets-active').index() == (numberSlides-1))
                            {
                                slide_bullet('last');
                            }
                            else
                            {
                                slide_bullet('next');
                            }
                        }
                        else if(bullets.children('li.frs-bullets-active').hasClass('frs-bullet-sliding-back'))
                        {
                            if(bullets.children('li.frs-bullets-active').index() > 0)
                            {
                                slide_bullet('back');
                            }
                            else
                            {
                                slide_bullet('first');
                            }
                        }
                        else if(bullets.children('li.frs-bullets-active').hasClass('frs-bullet-sliding-one-next'))
                        {
                            slide_bullet_one('next')
                        }
                        else if(bullets.children('li.frs-bullets-active').hasClass('frs-bullet-sliding-one-back'))
                        {
                            slide_bullet_one('back')
                        }
                        else
                        {
                            if(bulletsMaxShowedIndex > 0)
                            {
                                if(bullets.children('li.frs-bullets-active').index() == 0)
                                {
                                    slide_bullet('first');
                                }
                                else if(bullets.children('li.frs-bullets-active').index() == (numberSlides-1))
                                {
                                    slide_bullet('last');
                                }
                            }
                        }
                    }
                }
            }


            // ====================
            // ! CAPTION POSITION   
            // ====================
            function set_caption_position()
            {
                caption_position = slides.eq(activeSlide).find('div.frs-caption');

                if(caption_position.length)
                {
                    caption_position = caption_position.attr('class').replace('frs-caption ','');
                }
                else
                {
                    caption_position = "undefined";
                }

                //set active caption position to bullet and navigation
                frsWrapper.find('div.frs-bullets-wrapper').attr('class', 'frs-bullets-wrapper ' + caption_position);
                frsWrapper.find('div.frs-slider-nav').attr('class', 'frs-slider-nav ' + caption_position);
            }


            // ====================
            // ! SHIFT ANIMATIONS  
            // ====================
            function shift(direction) 
            {
                // remember previous activeSlide
                var prevActiveSlide = activeSlide,
                    slideDirection = direction;
                // exit function if bullet clicked is same as the current image
                if (prevActiveSlide == slideDirection) {
                    return false;
                }
                // reset Z & Unlock
                function resetAndUnlock() {
                    if(options.continousSliding)
                    {
                        slides
                            .eq(prevActiveSlide)
                            .css({
                                "z-index": 1
                            });
                    }
                   
                    frs_slider_unlock();
                    options.afterSlideChange.call(this);                    
                }

                if (slides.length == "1") {
                    return false;
                }
                if (!locked) {
                    frs_slider_lock();
                    //deduce the proper activeImage
                    if (direction == "next") {
                        activeSlide++
                        activeSlideContinous++
                        if (activeSlide == numberSlides) {
                            activeSlide = 0;
                        }
                    } else if (direction == "prev") {
                        activeSlide--
                        activeSlideContinous--
                        if (activeSlide < 0) {
                            activeSlide = numberSlides - 1;
                        }
                    } else {
                        activeSlide = direction;
                        if (prevActiveSlide < activeSlide) {
                            slideDirection = "next";
                        } else if (prevActiveSlide > activeSlide) {
                            slideDirection = "prev"
                        }
                    }
                    // set to correct bullet
                    setActiveBullet();

                    // set previous slide z-index to one below what new activeSlide will be
                    if(options.continousSliding)
                    {
                        slides
                            .eq(prevActiveSlide)
                            .css({
                                "z-index": 2
                            });
                    }
                    

                    if(options.heightResize==true){

                    $(slides).parent('.frs-slideshow-content').animate(
                        {'height':frsHeight},
                        options.animationSpeed)
                    }

                    
                    /**
                     * Horizontal Slide
                     */
                    if (options.animation == "horizontal-slide") 
                    {                    
                        if(options.continousSliding)
                        {
                            var cssWidth = slideDirection == "next" ? frsWidth : -frsWidth;
                            var aniWidth = slideDirection == "next" ? -frsWidth : frsWidth;                                

                            if(css3support())
                            {
                                /**
                                 * belum jadi yang css 3 continous slide
                                 */

                                slides
                                    .eq(activeSlide)
                                    .css({
                                        "left": cssWidth,
                                        "z-index": 3
                                    })
                                    .animate({
                                        "left": 0

                                    }, options.animationSpeed, resetAndUnlock);

                                slides
                                    .eq(prevActiveSlide)
                                    .animate({
                                        "left": aniWidth
                                    }, options.animationSpeed);


                                // var properties = {};
                                // properties[ 'z-index' ] = 3;
                                // properties[ 'left' ] = cssWidth;

                                // slides.eq(activeSlide).css(properties);

                                // var properties = {};
                                // properties[ 'left' ] = 0;

                                // slides.eq(prevActiveSlide).css(properties);

                                // if(slides.eq(activeSlide).css('left') == cssWidth + 'px')
                                // {
                                //     var properties = {};
                                //     properties[ '-' + vendorPrefix + '-transition-duration' ] = options.animationSpeed + 'ms';
                                //     properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d(-'+ cssWidth +'px, 0, 0)';

                                //     slides.eq(activeSlide).css(properties);

                                //     var properties = {};
                                //     properties[ 'left' ] = 0;
                                //     properties[ '-' + vendorPrefix + '-transition-duration' ] = options.animationSpeed + 'ms';
                                //     properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d('+ aniWidth +'px, 0, 0)';

                                //     slides.eq(prevActiveSlide).css(properties);

                                //     resetAndUnlock();
                                // }                                    
                            }
                            else
                            {
                                slides
                                    .eq(activeSlide)
                                    .css({
                                        "left": cssWidth,
                                        "z-index": 3
                                    })
                                    .animate({
                                        "left": 0

                                    }, options.animationSpeed, resetAndUnlock);

                                slides
                                    .eq(prevActiveSlide)
                                    .animate({
                                        "left": aniWidth
                                    }, options.animationSpeed);
                            }  
                        }
                        else
                        {
                            var slide_action = frsWidth * activeSlide < numberSlides * frsWidth ? '-' + frsWidth * activeSlide : 0 ;

                            if(css3support())
                            {
                                // Get the properties to transition
                                var properties = {};
                                properties[ '-' + vendorPrefix + '-transition-duration' ] = options.animationSpeed + 'ms';
                                properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d('+ slide_action +'px, 0, 0)';

                                // Do the CSS3 transition
                                slides.parent().css(properties);
                                resetAndUnlock();
                            }
                            else
                            {
                                slides.parent()
                                    .animate({
                                        "left": slide_action + 'px'
                                    }, options.animationSpeed, resetAndUnlock);
                            }
                        }
                    }

                    /**
                     * Vertical Slide
                     */
                    if (options.animation == "vertical-slide") 
                    {
                        var slide_action = frsHeight * activeSlide < numberSlides * frsHeight ? '-' + frsHeight * activeSlide : 0 ;

                        if(options.continousSliding)
                        {
                            /**
                             * BELUM JADI
                             */
                            if (slideDirection == "prev") {
                                if(css3support())
                                {
                                    // Get the properties to transition
                                    var properties = {};
                                    properties[ '-' + vendorPrefix + '-transition-duration' ] = options.animationSpeed + 'ms';
                                    properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d(0, '+ slide_action +'px, 0)';

                                    // Do the CSS3 transition
                                    slides.parent().css(properties);
                                    resetAndUnlock();
                                }
                                else
                                {
                                    slides
                                        .eq(activeSlide)
                                        .css({
                                            "top": frsHeight,
                                            "z-index": 3
                                        })
                                        .animate({
                                            "top": 0
                                        }, options.animationSpeed, resetAndUnlock);
                                }
                            }
                            if (slideDirection == "next") {
                                if(css3support())
                                {
                                    // Get the properties to transition
                                    var properties = {};
                                    properties[ '-' + vendorPrefix + '-transition-duration' ] = options.animationSpeed + 'ms';
                                    properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d(0, '+ slide_action +'px, 0)';

                                    // Do the CSS3 transition
                                    slides.parent().css(properties);
                                    resetAndUnlock();
                                }
                                else
                                {
                                    slides
                                        .eq(activeSlide)
                                        .css({
                                            "top": -frsHeight,
                                            "z-index": 3
                                        })
                                        .animate({
                                            "top": 0
                                        }, options.animationSpeed, resetAndUnlock);
                                }
                            }
                        }
                        else
                        {
                            if(css3support())
                            {
                                // Get the properties to transition
                                var properties = {};
                                properties[ '-' + vendorPrefix + '-transition-duration' ] = options.animationSpeed + 'ms';
                                properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d(0, '+ slide_action +'px, 0)';

                                // Do the CSS3 transition
                                slides.parent().css(properties);
                                resetAndUnlock();
                            }
                            else
                            {
                                slides.parent()
                                    .animate({
                                        "top": slide_action + 'px'
                                    }, options.animationSpeed, resetAndUnlock);
                            }
                        }
                        
                    }

                    /**
                     * Fade
                     */
                    if (options.animation == "fade") 
                    {
                        if(css3support())
                        {                            
                            slides.eq(activeSlide).css({'z-index': 2});

                            // Get the properties to transition
                            var properties = {};
                            properties[ 'opacity' ] = 0;
                            properties[ '-' + vendorPrefix + '-transition' ] = 'all ' + options.animationSpeed + 'ms ease';

                            slides.eq(prevActiveSlide).css(properties);

                            clearTimeout(timeout);
                            timeout = setTimeout(function() {
                                slides.eq(activeSlide).css({'z-index': 3});

                                // Get the properties to transition
                                var properties = {};
                                properties[ 'opacity' ] = 1;
                                properties[ 'z-index' ] = 1;
                                properties[ '-' + vendorPrefix + '-transition' ] = '';
                                
                                slides.eq(prevActiveSlide).css(properties);
                            }, options.animationSpeed - (options.animationSpeed * 20 / 100));                            

                            resetAndUnlock();
                        }
                        else
                        {
                            slides
                                .eq(activeSlide)
                                .css({
                                    "opacity": 0,
                                    "z-index": 3
                                })
                                .animate({
                                    "opacity": 1,
                                }, options.animationSpeed, resetAndUnlock);
                        }
                    }

                    set_caption_position();
                } //lock                                
            } //frs function

            // set caption position
            set_caption_position();



            // ====================================
            // ! RESIZE WINDOWS EVENT: RESPONSIVE   
            // ====================================            
            $(window).bind('resize.frs-slideshow-container', function(event, force) {
                calculateHeightWidth();

                /**
                 * resize elements
                 */
                slides.width(frsWidth);                
                slides.height(frsHeight);

                // resize wrapper
                frs.css({'height': frsHeight + 'px'});
                frsWrapper.parent().css({'height': frsHeight + 'px'});

                if(! options.continousSliding)
                {
                    if(options.animation == "horizontal-slide")
                    {
                        slideWrapper.css({
                            'width': frsWidth * numberSlides + 'px'
                        });

                        var slide_action = frsWidth * activeSlide < numberSlides * frsWidth ? '-' + frsWidth * activeSlide : 0 ;

                        // Stabilize slide position
                        if(css3support())
                        {
                            var properties = {};
                            properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d('+ slide_action +'px, 0, 0)';

                            slides.parent().css(properties);
                        }
                        else
                        {
                            slides.parent()
                                .animate({
                                    "left": slide_action + 'px'
                                });
                        }

                    }
                    else if(options.animation == "vertical-slide")
                    {
                        slideWrapper.css({
                            'height': frsHeight * numberSlides + 'px'
                        });

                        var slide_action = frsHeight * activeSlide < numberSlides * frsHeight ? '-' + frsHeight * activeSlide : 0 ;

                        /** Stabilize slide position */
                        var properties = {};
                        properties[ '-' + vendorPrefix + '-transform' ] = 'translate3d(0, '+ slide_action +'px, 0)';

                        slides.parent().css(properties);
                    }

                    /**
                     * Slide bullets
                     */
                    if(options.sbullets)
                    {
                        generate_slide_bullet();
                        slide_bullet('first');
                        shift(0);
                    }
                }


                /**
                 * Resposive Class
                 * - frs-responsive-mobile-small (width <= 369)
                 * - frs-responsive-mobile-medium (width <= 499 && width <= frsWidth)
                 * - frs-responsive-full
                 */

                 if(370 <= frsWidth && frsWidth <= 499) {
                    doResponsiveClassStart('frs-responsive-mobile-medium')
                 }
                 else if(369 >= frsWidth ) {
                    doResponsiveClassStart('frs-responsive-mobile-small')
                 }
                 else {
                    // Desktop Mode
                    doResponsiveClassStart('frs-responsive-full')
                 }
            });

            function doResponsiveClassStart(responsiveClass){
                // if it is the first run dont do animation
                if(first_run)
                {
                    first_run = false
                    frsWrapper.attr('class','frs-wrapper ' + options.skinClass)
                    frsWrapper.addClass(responsiveClass)
                    return
                }

                if(old_responsive_class == responsiveClass) return

                old_responsive_class = responsiveClass

                // Do the loading animation
                frsWrapper.children('.frs-slideshow-content').css('background-image','');
                slideWrapper.hide()

                // Restore & change responsive class
                setTimeout(function() {
                    frsWrapper.attr('class','frs-wrapper ' + options.skinClass)
                    frsWrapper.addClass(responsiveClass)
                    slideWrapper.css('display','block')

                    frsWrapper.children('.frs-slideshow-content').css('background-image','none');
                }, 1000);                
            }

        }); // Each call
    } // Frs plugin call

})(jQuery);
// source --> https://shop.ducatibarcelona.com/wp-content/plugins/fluid-responsive-slideshow/js/jquery.touchSwipe.min.js?ver=6.9.4 
(function(a){if(typeof define==="function"&&define.amd&&define.amd.jQuery){define(["jquery"],a)}else{a(jQuery)}}(function(e){var o="left",n="right",d="up",v="down",c="in",w="out",l="none",r="auto",k="swipe",s="pinch",x="tap",i="doubletap",b="longtap",A="horizontal",t="vertical",h="all",q=10,f="start",j="move",g="end",p="cancel",a="ontouchstart" in window,y="TouchSwipe";var m={fingers:1,threshold:75,cancelThreshold:null,pinchThreshold:20,maxTimeThreshold:null,fingerReleaseThreshold:250,longTapThreshold:500,doubleTapThreshold:200,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,pinchIn:null,pinchOut:null,pinchStatus:null,click:null,tap:null,doubleTap:null,longTap:null,triggerOnTouchEnd:true,triggerOnTouchLeave:false,allowPageScroll:"auto",fallbackToMouseEvents:true,excludedElements:"label, button, input, select, textarea, a, .noSwipe"};e.fn.swipe=function(D){var C=e(this),B=C.data(y);if(B&&typeof D==="string"){if(B[D]){return B[D].apply(this,Array.prototype.slice.call(arguments,1))}else{e.error("Method "+D+" does not exist on jQuery.swipe")}}else{if(!B&&(typeof D==="object"||!D)){return u.apply(this,arguments)}}return C};e.fn.swipe.defaults=m;e.fn.swipe.phases={PHASE_START:f,PHASE_MOVE:j,PHASE_END:g,PHASE_CANCEL:p};e.fn.swipe.directions={LEFT:o,RIGHT:n,UP:d,DOWN:v,IN:c,OUT:w};e.fn.swipe.pageScroll={NONE:l,HORIZONTAL:A,VERTICAL:t,AUTO:r};e.fn.swipe.fingers={ONE:1,TWO:2,THREE:3,ALL:h};function u(B){if(B&&(B.allowPageScroll===undefined&&(B.swipe!==undefined||B.swipeStatus!==undefined))){B.allowPageScroll=l}if(B.click!==undefined&&B.tap===undefined){B.tap=B.click}if(!B){B={}}B=e.extend({},e.fn.swipe.defaults,B);return this.each(function(){var D=e(this);var C=D.data(y);if(!C){C=new z(this,B);D.data(y,C)}})}function z(a0,aq){var av=(a||!aq.fallbackToMouseEvents),G=av?"touchstart":"mousedown",au=av?"touchmove":"mousemove",R=av?"touchend":"mouseup",P=av?null:"mouseleave",az="touchcancel";var ac=0,aL=null,Y=0,aX=0,aV=0,D=1,am=0,aF=0,J=null;var aN=e(a0);var W="start";var T=0;var aM=null;var Q=0,aY=0,a1=0,aa=0,K=0;var aS=null;try{aN.bind(G,aJ);aN.bind(az,a5)}catch(ag){e.error("events not supported "+G+","+az+" on jQuery.swipe")}this.enable=function(){aN.bind(G,aJ);aN.bind(az,a5);return aN};this.disable=function(){aG();return aN};this.destroy=function(){aG();aN.data(y,null);return aN};this.option=function(a8,a7){if(aq[a8]!==undefined){if(a7===undefined){return aq[a8]}else{aq[a8]=a7}}else{e.error("Option "+a8+" does not exist on jQuery.swipe.options")}return null};function aJ(a9){if(ax()){return}if(e(a9.target).closest(aq.excludedElements,aN).length>0){return}var ba=a9.originalEvent?a9.originalEvent:a9;var a8,a7=a?ba.touches[0]:ba;W=f;if(a){T=ba.touches.length}else{a9.preventDefault()}ac=0;aL=null;aF=null;Y=0;aX=0;aV=0;D=1;am=0;aM=af();J=X();O();if(!a||(T===aq.fingers||aq.fingers===h)||aT()){ae(0,a7);Q=ao();if(T==2){ae(1,ba.touches[1]);aX=aV=ap(aM[0].start,aM[1].start)}if(aq.swipeStatus||aq.pinchStatus){a8=L(ba,W)}}else{a8=false}if(a8===false){W=p;L(ba,W);return a8}else{ak(true)}return null}function aZ(ba){var bd=ba.originalEvent?ba.originalEvent:ba;if(W===g||W===p||ai()){return}var a9,a8=a?bd.touches[0]:bd;var bb=aD(a8);aY=ao();if(a){T=bd.touches.length}W=j;if(T==2){if(aX==0){ae(1,bd.touches[1]);aX=aV=ap(aM[0].start,aM[1].start)}else{aD(bd.touches[1]);aV=ap(aM[0].end,aM[1].end);aF=an(aM[0].end,aM[1].end)}D=a3(aX,aV);am=Math.abs(aX-aV)}if((T===aq.fingers||aq.fingers===h)||!a||aT()){aL=aH(bb.start,bb.end);ah(ba,aL);ac=aO(bb.start,bb.end);Y=aI();aE(aL,ac);if(aq.swipeStatus||aq.pinchStatus){a9=L(bd,W)}if(!aq.triggerOnTouchEnd||aq.triggerOnTouchLeave){var a7=true;if(aq.triggerOnTouchLeave){var bc=aU(this);a7=B(bb.end,bc)}if(!aq.triggerOnTouchEnd&&a7){W=ay(j)}else{if(aq.triggerOnTouchLeave&&!a7){W=ay(g)}}if(W==p||W==g){L(bd,W)}}}else{W=p;L(bd,W)}if(a9===false){W=p;L(bd,W)}}function I(a7){var a8=a7.originalEvent;if(a){if(a8.touches.length>0){C();return true}}if(ai()){T=aa}a7.preventDefault();aY=ao();Y=aI();if(a6()){W=p;L(a8,W)}else{if(aq.triggerOnTouchEnd||(aq.triggerOnTouchEnd==false&&W===j)){W=g;L(a8,W)}else{if(!aq.triggerOnTouchEnd&&a2()){W=g;aB(a8,W,x)}else{if(W===j){W=p;L(a8,W)}}}}ak(false);return null}function a5(){T=0;aY=0;Q=0;aX=0;aV=0;D=1;O();ak(false)}function H(a7){var a8=a7.originalEvent;if(aq.triggerOnTouchLeave){W=ay(g);L(a8,W)}}function aG(){aN.unbind(G,aJ);aN.unbind(az,a5);aN.unbind(au,aZ);aN.unbind(R,I);if(P){aN.unbind(P,H)}ak(false)}function ay(bb){var ba=bb;var a9=aw();var a8=aj();var a7=a6();if(!a9||a7){ba=p}else{if(a8&&bb==j&&(!aq.triggerOnTouchEnd||aq.triggerOnTouchLeave)){ba=g}else{if(!a8&&bb==g&&aq.triggerOnTouchLeave){ba=p}}}return ba}function L(a9,a7){var a8=undefined;if(F()||S()){a8=aB(a9,a7,k)}else{if((M()||aT())&&a8!==false){a8=aB(a9,a7,s)}}if(aC()&&a8!==false){a8=aB(a9,a7,i)}else{if(al()&&a8!==false){a8=aB(a9,a7,b)}else{if(ad()&&a8!==false){a8=aB(a9,a7,x)}}}if(a7===p){a5(a9)}if(a7===g){if(a){if(a9.touches.length==0){a5(a9)}}else{a5(a9)}}return a8}function aB(ba,a7,a9){var a8=undefined;if(a9==k){aN.trigger("swipeStatus",[a7,aL||null,ac||0,Y||0,T]);if(aq.swipeStatus){a8=aq.swipeStatus.call(aN,ba,a7,aL||null,ac||0,Y||0,T);if(a8===false){return false}}if(a7==g&&aR()){aN.trigger("swipe",[aL,ac,Y,T]);if(aq.swipe){a8=aq.swipe.call(aN,ba,aL,ac,Y,T);if(a8===false){return false}}switch(aL){case o:aN.trigger("swipeLeft",[aL,ac,Y,T]);if(aq.swipeLeft){a8=aq.swipeLeft.call(aN,ba,aL,ac,Y,T)}break;case n:aN.trigger("swipeRight",[aL,ac,Y,T]);if(aq.swipeRight){a8=aq.swipeRight.call(aN,ba,aL,ac,Y,T)}break;case d:aN.trigger("swipeUp",[aL,ac,Y,T]);if(aq.swipeUp){a8=aq.swipeUp.call(aN,ba,aL,ac,Y,T)}break;case v:aN.trigger("swipeDown",[aL,ac,Y,T]);if(aq.swipeDown){a8=aq.swipeDown.call(aN,ba,aL,ac,Y,T)}break}}}if(a9==s){aN.trigger("pinchStatus",[a7,aF||null,am||0,Y||0,T,D]);if(aq.pinchStatus){a8=aq.pinchStatus.call(aN,ba,a7,aF||null,am||0,Y||0,T,D);if(a8===false){return false}}if(a7==g&&a4()){switch(aF){case c:aN.trigger("pinchIn",[aF||null,am||0,Y||0,T,D]);if(aq.pinchIn){a8=aq.pinchIn.call(aN,ba,aF||null,am||0,Y||0,T,D)}break;case w:aN.trigger("pinchOut",[aF||null,am||0,Y||0,T,D]);if(aq.pinchOut){a8=aq.pinchOut.call(aN,ba,aF||null,am||0,Y||0,T,D)}break}}}if(a9==x){if(a7===p||a7===g){clearTimeout(aS);if(V()&&!E()){K=ao();aS=setTimeout(e.proxy(function(){K=null;aN.trigger("tap",[ba.target]);if(aq.tap){a8=aq.tap.call(aN,ba,ba.target)}},this),aq.doubleTapThreshold)}else{K=null;aN.trigger("tap",[ba.target]);if(aq.tap){a8=aq.tap.call(aN,ba,ba.target)}}}}else{if(a9==i){if(a7===p||a7===g){clearTimeout(aS);K=null;aN.trigger("doubletap",[ba.target]);if(aq.doubleTap){a8=aq.doubleTap.call(aN,ba,ba.target)}}}else{if(a9==b){if(a7===p||a7===g){clearTimeout(aS);K=null;aN.trigger("longtap",[ba.target]);if(aq.longTap){a8=aq.longTap.call(aN,ba,ba.target)}}}}}return a8}function aj(){var a7=true;if(aq.threshold!==null){a7=ac>=aq.threshold}return a7}function a6(){var a7=false;if(aq.cancelThreshold!==null&&aL!==null){a7=(aP(aL)-ac)>=aq.cancelThreshold}return a7}function ab(){if(aq.pinchThreshold!==null){return am>=aq.pinchThreshold}return true}function aw(){var a7;if(aq.maxTimeThreshold){if(Y>=aq.maxTimeThreshold){a7=false}else{a7=true}}else{a7=true}return a7}function ah(a7,a8){if(aq.allowPageScroll===l||aT()){a7.preventDefault()}else{var a9=aq.allowPageScroll===r;switch(a8){case o:if((aq.swipeLeft&&a9)||(!a9&&aq.allowPageScroll!=A)){a7.preventDefault()}break;case n:if((aq.swipeRight&&a9)||(!a9&&aq.allowPageScroll!=A)){a7.preventDefault()}break;case d:if((aq.swipeUp&&a9)||(!a9&&aq.allowPageScroll!=t)){a7.preventDefault()}break;case v:if((aq.swipeDown&&a9)||(!a9&&aq.allowPageScroll!=t)){a7.preventDefault()}break}}}function a4(){var a8=aK();var a7=U();var a9=ab();return a8&&a7&&a9}function aT(){return !!(aq.pinchStatus||aq.pinchIn||aq.pinchOut)}function M(){return !!(a4()&&aT())}function aR(){var ba=aw();var bc=aj();var a9=aK();var a7=U();var a8=a6();var bb=!a8&&a7&&a9&&bc&&ba;return bb}function S(){return !!(aq.swipe||aq.swipeStatus||aq.swipeLeft||aq.swipeRight||aq.swipeUp||aq.swipeDown)}function F(){return !!(aR()&&S())}function aK(){return((T===aq.fingers||aq.fingers===h)||!a)}function U(){return aM[0].end.x!==0}function a2(){return !!(aq.tap)}function V(){return !!(aq.doubleTap)}function aQ(){return !!(aq.longTap)}function N(){if(K==null){return false}var a7=ao();return(V()&&((a7-K)<=aq.doubleTapThreshold))}function E(){return N()}function at(){return((T===1||!a)&&(isNaN(ac)||ac===0))}function aW(){return((Y>aq.longTapThreshold)&&(ac<q))}function ad(){return !!(at()&&a2())}function aC(){return !!(N()&&V())}function al(){return !!(aW()&&aQ())}function C(){a1=ao();aa=event.touches.length+1}function O(){a1=0;aa=0}function ai(){var a7=false;if(a1){var a8=ao()-a1;if(a8<=aq.fingerReleaseThreshold){a7=true}}return a7}function ax(){return !!(aN.data(y+"_intouch")===true)}function ak(a7){if(a7===true){aN.bind(au,aZ);aN.bind(R,I);if(P){aN.bind(P,H)}}else{aN.unbind(au,aZ,false);aN.unbind(R,I,false);if(P){aN.unbind(P,H,false)}}aN.data(y+"_intouch",a7===true)}function ae(a8,a7){var a9=a7.identifier!==undefined?a7.identifier:0;aM[a8].identifier=a9;aM[a8].start.x=aM[a8].end.x=a7.pageX||a7.clientX;aM[a8].start.y=aM[a8].end.y=a7.pageY||a7.clientY;return aM[a8]}function aD(a7){var a9=a7.identifier!==undefined?a7.identifier:0;var a8=Z(a9);a8.end.x=a7.pageX||a7.clientX;a8.end.y=a7.pageY||a7.clientY;return a8}function Z(a8){for(var a7=0;a7<aM.length;a7++){if(aM[a7].identifier==a8){return aM[a7]}}}function af(){var a7=[];for(var a8=0;a8<=5;a8++){a7.push({start:{x:0,y:0},end:{x:0,y:0},identifier:0})}return a7}function aE(a7,a8){a8=Math.max(a8,aP(a7));J[a7].distance=a8}function aP(a7){if(J[a7]){return J[a7].distance}return undefined}function X(){var a7={};a7[o]=ar(o);a7[n]=ar(n);a7[d]=ar(d);a7[v]=ar(v);return a7}function ar(a7){return{direction:a7,distance:0}}function aI(){return aY-Q}function ap(ba,a9){var a8=Math.abs(ba.x-a9.x);var a7=Math.abs(ba.y-a9.y);return Math.round(Math.sqrt(a8*a8+a7*a7))}function a3(a7,a8){var a9=(a8/a7)*1;return a9.toFixed(2)}function an(){if(D<1){return w}else{return c}}function aO(a8,a7){return Math.round(Math.sqrt(Math.pow(a7.x-a8.x,2)+Math.pow(a7.y-a8.y,2)))}function aA(ba,a8){var a7=ba.x-a8.x;var bc=a8.y-ba.y;var a9=Math.atan2(bc,a7);var bb=Math.round(a9*180/Math.PI);if(bb<0){bb=360-Math.abs(bb)}return bb}function aH(a8,a7){var a9=aA(a8,a7);if((a9<=45)&&(a9>=0)){return o}else{if((a9<=360)&&(a9>=315)){return o}else{if((a9>=135)&&(a9<=225)){return n}else{if((a9>45)&&(a9<135)){return v}else{return d}}}}}function ao(){var a7=new Date();return a7.getTime()}function aU(a7){a7=e(a7);var a9=a7.offset();var a8={left:a9.left,right:a9.left+a7.outerWidth(),top:a9.top,bottom:a9.top+a7.outerHeight()};return a8}function B(a7,a8){return(a7.x>a8.left&&a7.x<a8.right&&a7.y>a8.top&&a7.y<a8.bottom)}}}));
// source --> https://shop.ducatibarcelona.com/wp-content/plugins/fluid-responsive-slideshow/js/imagesloaded.min.js?ver=2.3.1 
/*!
 * imagesLoaded PACKAGED v3.1.6
 * JavaScript is all like "You images are done yet or what?"
 * MIT License
 * Renamed into imagesLoadedFRS because of frequently conflict with others
 */

(function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("eventEmitter"),require("eventie")):e.imagesLoadedFRS=t(e,e.EventEmitter,e.eventie)}(this,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function c(e){this.img=e}function f(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);var i=n.nodeType;if(i&&(1===i||9===i||11===i))for(var r=n.querySelectorAll("img"),o=0,s=r.length;s>o;o++){var c=r[o];this.addImage(c)}}},s.prototype.addImage=function(e){var t=new c(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoadedFRS=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),c.prototype=new t,c.prototype.check=function(){var e=v[this.img.src]||new f(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},c.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return f.prototype=new t,f.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},f.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},f.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},f.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},f.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},f.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});