(function($, Drupal, PhotoSwipe, PhotoSwipeUI_Default) {
  Drupal.behaviors.photoswipe = {
    /**
     * PhotoSwipe Options, coming from Drupal.settings.
     */
    photoSwipeOptions: {},
    /**
     * Instantiated galleries.
     */
    galleries: [],
    /**
     * Load PhotoSwipe once page is ready
     */
    attach: function(context, settings) {
      // Send to GA.
      function psSendToGA(category, action, label, value) {
        if (typeof ga != 'undefined') {
          if (label === undefined) {
            label = 0;
          }


          if (value === undefined) {
            value = 0;
          }

          ga('send', {
            'hitType': 'event',
            'eventCategory': category,
            'eventAction': action,
            'eventLabel': label,
            'eventValue': value
          });
        }
      }

      this.photoSwipeOptions = settings.photoswipe ? settings.photoswipe.options : {};

      var images = [];
      if (settings.RelaProperty !== undefined) {
        if (settings.RelaProperty.DLRestricted == true) {
          $('body').addClass('nodl');
        }
        else {
         $('body').removeClass('nodl');
        }

        PSImages = settings.RelaProperty.imageListPS[settings.RelaProperty.nid];
        Object.keys(PSImages).forEach(function(key) {
          image = {};

          image['src'] = PSImages[key]['url'];
          image['w'] = PSImages[key]['w'];
          image['h'] = PSImages[key]['h'];
          image['title'] = PSImages[key]['title'];
          image['pid'] = PSImages[key]['pid'];
          image['property'] = PSImages[key]['property'];
          images.push(image);
        });
      }

      var floorplans = [];
      if (settings.RelaPropertyFloorplan !== undefined) {
        PSFloorplans = settings.RelaPropertyFloorplan.floorplanListPS;

        if (settings.RelaPropertyFloorplan.DLRestricted == true) {
          $('body').addClass('nodl');
        }
        else {
          $('body').removeClass('nodl');
        }

        Object.keys(PSFloorplans).forEach(function(key) {
          image = {};

          image['src'] = PSFloorplans[key]['url'];
          image['w'] = PSFloorplans[key]['w'];
          image['h'] = PSFloorplans[key]['h'];
          image['title'] = PSFloorplans[key]['title'];
          image['pid'] = PSFloorplans[key]['pid'];
          image['property'] = PSFloorplans[key]['property'];
          floorplans.push(image);
        });
      }

      if (!images.length && !floorplans.length) {
        return;
      }

      // define options (if needed)
      var options = {
        index: 0,
        bgOpacity: 1,
        closeOnScroll: false,
        clickToCloseNonZoomable: false,
        tapToClose: false,
        closeElClasses: [],
        galleryPIDs: true,
        shareEl: false,
      };

      var ssRunning = false,
        ssOnce = false,
        ssDelay = 4500 /*ms*/ ,
        ssButtonClass = '.pswp-custom-button--playpause';

      var gallery = null;
      // Initializes and opens PhotoSwipe
      $('[data="ps-open"]', context).click(function() {
        var pswpElement = document.querySelectorAll('.pswp')[0];

        options['index'] = 0;
        var pid = $(this).attr('data-pid');
        if (pid !== undefined) {
          options['index'] = parseInt(pid);
        }

        var content = images;

        if ($(this).hasClass('floorplan-gallery-link')) {
          content = floorplans;
          $('.pswp-custom-button--photogrid').hide();
        }
        else {
          $('.pswp-custom-button--photogrid').show();
        }


        gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, content, options);

        /* not running from the start */
        setSlideshowState(ssButtonClass, false);
        // start timer for the next slide in slideshow after prior image has loaded

        gallery.init();

        $(pswpElement).data('pswp', gallery);

        psSendToGA('Images', gallery.currItem.property, gallery.currItem.pid, 0);
        gallery.listen('afterChange', function() {
          if (ssRunning && ssOnce) {
            ssOnce = false;
            setTimeout(gotoNextSlide, ssDelay);
          }
          psSendToGA('Images', gallery.currItem.property, gallery.currItem.pid, 0);
        });

        Drupal.settings.RelaProperty.currentPSgallery = gallery;
        gallery.listen('close', function() {
          $('body').removeClass('ps-grid-open');
          $('#pspw-gallery-thumbs').hide();
          if ($('#gallery-thumbs-ph').length > 0) {
            $('#gallery-thumbs-ph').hide();
          }
        });
        return false;
      })

      // $('div[data="ps-open"]', context).click(function() {
      //   var pswpElement = document.querySelectorAll('.pswp')[0];

      //   options['index'] = 0;
      //   var pid = $(this).attr('data-pid');
      //   if (pid !== undefined) {
      //     options['index'] = parseInt(pid);
      //   }

      //   gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, images, options);

      //   /* not running from the start */
      //   setSlideshowState(ssButtonClass, false );
      //   // start timer for the next slide in slideshow after prior image has loaded

      //   gallery.init();

      //   $(pswpElement).data('pswp', gallery);

      //   psSendToGA('Images', gallery.currItem.property, gallery.currItem.pid, 0);
      //   gallery.listen('afterChange', function() {
      //     if (ssRunning && ssOnce) {
      //       ssOnce = false;
      //       setTimeout(gotoNextSlide, ssDelay);
      //     }
      //     psSendToGA('Images', gallery.currItem.property, gallery.currItem.pid, 0);
      //   });
      //   Drupal.settings.RelaProperty.currentPSgallery = gallery;

      //   gallery.listen('close', function() {
      //     $('body').removeClass('ps-grid-open');
      //     $('#pspw-gallery-thumbs').hide();
      //     if ($('#gallery-thumbs-ph').length > 0) {
      //       $('#gallery-thumbs-ph').hide();
      //     }
      //   });

      //   return false;
      // })

      /* slideshow management */
      $(ssButtonClass, context).on('click tap', function(e) {
        // toggle slideshow on/off
        setSlideshowState(this, !ssRunning);

      });

      $('.pswp-custom-button--photogrid', context).click(function(){
        if (Drupal.settings.RelaProperty) {
          var propertyNID = Drupal.settings.RelaProperty.nid;
          if ($('body').hasClass('ps-grid-open')) {
            $('body').removeClass('ps-grid-open');
            $('#pspw-gallery-thumbs').hide();
            window.dispatchEvent(new Event('resize'));
          }

          else {
            $('body').addClass('ps-grid-open');
            if ($('body').hasClass('ps-grid-processed')) {
              $('#pspw-gallery-thumbs').show();
              window.dispatchEvent(new Event('resize'));
            }

            else {
              $('body').addClass('ps-grid-processed');
              if ($('#gallery-thumbs-ph').length > 0) {
                 $('#gallery-thumbs-ph').show();
              }
              relaAjaxLink('/relajax/nojs/property/' + propertyNID + '/gallery-thumbs');

              if (typeof settings.multiGallerylazyloader !== 'undefined') {
                var waitForEl = function(selector, callback) {
                if (jQuery(selector).length) {
                  callback();
                }
                else {
                  setTimeout(function() {
                    waitForEl(selector, callback);
                  }, 100);
                }};

                waitForEl('#pspw-gallery-thumbs', function() {
                  $('#pspw-gallery-thumbs .thumb img', context).each(function(){
                    var pswp_pid = $(this).parent().data('pid');
                    var img_replace = $(".multi-gallery-image[data-pid='" + pswp_pid + "'] .inner").data('src');
                    $(this).attr('src', img_replace);
                  });
                });
              }

              window.dispatchEvent(new Event('resize'));
            }
          }
        }
      });

      $('#pspw-close-thumbs', context).click(function(){
         $('body').removeClass('ps-grid-open');
         $('#pspw-gallery-thumbs').hide();
         window.dispatchEvent(new Event('resize'));
      });


      $('#pspw-gallery-thumbs .thumb').unbind('click');
      $('#pspw-gallery-thumbs .thumb').click(function(){
        var thumbIndex = $(this).data('pid');
        var currentGal = settings.RelaProperty.currentPSgallery
        currentGal.goTo(parseInt(thumbIndex));
      });

      function setSlideshowState(el, running) {
        if (running) {
          $(ssButtonClass + ' i').removeClass('fa-play');
          $(ssButtonClass + ' i').addClass('fa-pause');
          setTimeout(gotoNextSlide, ssDelay / 2.0 /* first time wait less */ );
        }
        else {
          $(ssButtonClass + ' i').addClass('fa-play');
          $(ssButtonClass + ' i').removeClass('fa-pause');
        }
        var title = running ? "Pause Slideshow" : "Play Slideshow";
        // $(el).removeClass(running ? "play" : "pause") // change icons defined in css
        //   .addClass(running ? "pause" : "play")
        //   .prop('title', title);
        ssRunning = running;
      }

      function gotoNextSlide() {
        if (ssRunning && !!gallery) {
          ssOnce = true;
          var n = '.pswp__scroll-wrap';
          $(n).addClass("animated fadeOut");
          setTimeout(function() {
            $(n).addClass("invisible").removeClass("animated fadeOut");
            gallery.next();
            $(n).removeClass("invisible").addClass("animated fadeIn");
            setTimeout(function() {
              $(n).removeClass("animated fadeIn");
            }, 700)
            }, 700)
          //gallery.next();
          // start counter for next slide in 'afterChange' listener
        }
      }

    },
    /**
     * Triggers when user clicks on thumbnail.
     *
     * Code taken from http://photoswipe.com/documentation/getting-started.html
     * and adjusted accordingly.
     */
    onThumbnailsClick: function(e) {
      e = e || window.event;

      e.preventDefault ? e.preventDefault() : e.returnValue = false;

      var $clickedGallery = $(this);

      var eTarget = e.target || e.srcElement;
      var $eTarget = $(eTarget);

      // find root element of slide
      var clickedListItem = $eTarget.closest('.photoswipe');

      if (!clickedListItem) {

        return;
      }

      // get the index of the clicked element
      index = clickedListItem.index('.photoswipe');

      if (index >= 0) {
        // open PhotoSwipe if valid index found
        Drupal.behaviors.photoswipe.openPhotoSwipe(index, $clickedGallery);
      }
      return false;
    },
    /**
     * Code taken from http://photoswipe.com/documentation/getting-started.html
     * and adjusted accordingly.
     */
    openPhotoSwipe: function(index, galleryElement, options) {
      var pswpElement = $('.pswp')[0];
      var images = [];
      options = options || Drupal.behaviors.photoswipe.photoSwipeOptions;

      var images = galleryElement.find('a.photoswipe');
      images.each(function(index) {
        var $image = $(this);
        size = $image.data('size') ? $image.data('size').split('x') : ['', ''];
        images.push({
          src: $image.attr('href'),
          w: size[0],
          h: size[1],
          title: $image.data('overlay-title')
        });
      })

      // define options
      options.index = index;
      // define gallery index (for URL)
      options.galleryUID = galleryElement.data('pswp-uid');

      // Pass data to PhotoSwipe and initialize it
      var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, images, options);
      gallery.init();
      this.galleries.push(gallery);
      $(pswpElement).data('pswp', gallery);
    },
    /**
     * Parse picture index and gallery index from URL (#&pid=1&gid=2)
     *
     * Code taken from http://photoswipe.com/documentation/getting-started.html
     * and adjusted accordingly.
     */
    parseHash: function() {
      var hash = window.location.hash.substring(1),
        params = {};

      if (hash.length < 5) {
        return params;
      }

      var vars = hash.split('&');
      for (var i = 0; i < vars.length; i++) {
        if (!vars[i]) {
          continue;
        }
        var pair = vars[i].split('=');
        if (pair.length < 2) {
          continue;
        }
        params[pair[0]] = pair[1];
      }

      if (params.gid) {
        params.gid = parseInt(params.gid, 10);
      }

      if (!params.hasOwnProperty('pid')) {
        return params;
      }
      params.pid = parseInt(params.pid, 10);

      return params;
    }
  };
})(jQuery, Drupal, PhotoSwipe, PhotoSwipeUI_Default);
;/*})'"*/;/*})'"*/
/*!
 * @name        easyzoom
 * @author       <>
 * @modified    Friday, May 15th, 2020
 * @version     2.5.2
 */
! function(t, e) {
  "use strict";
  "function" == typeof define && define.amd ? define(["jquery"], function(t) {
    e(t)
  }) : "object" == typeof module && module.exports ? module.exports = t.EasyZoom = e(require("jquery")) : t.EasyZoom = e(t.jQuery)
}(this, function(o) {
  "use strict";
  var c, l, d, p, u, f, i = {
    loadingNotice: "Loading image",
    errorNotice: "The image could not be loaded",
    errorDuration: 2500,
    linkAttribute: "href",
    preventClicks: !0,
    beforeShow: o.noop,
    beforeHide: o.noop,
    onShow: o.noop,
    onHide: o.noop,
    onMove: o.noop
  };

  function s(t, e) {
    this.$target = o(t), this.opts = o.extend({}, i, e, this.$target.data()), void 0 === this.isOpen && this._init()
  }
  return s.prototype._init = function() {
    this.$link = this.$target.find("a"), this.$image = this.$target.find("img"), this.$flyout = o('<div class="easyzoom-flyout" />'), this.$notice = o('<div class="easyzoom-notice" />'), this.$target.on({
      "mousemove.easyzoom touchmove.easyzoom": o.proxy(this._onMove, this),
      "mouseleave.easyzoom touchend.easyzoom": o.proxy(this._onLeave, this),
      "mouseenter.easyzoom touchstart.easyzoom": o.proxy(this._onEnter, this)
    }), this.opts.preventClicks && this.$target.on("click.easyzoom", function(t) {
      t.preventDefault()
    })
  }, s.prototype.show = function(t, e) {
    var i = this;
    if (!1 !== this.opts.beforeShow.call(this)) {
      if (!this.isReady) return this._loadImage(this.$link.attr(this.opts.linkAttribute), function() {
        !i.isMouseOver && e || i.show(t)
      });
      this.$target.append(this.$flyout);
      var o = this.$target.outerWidth(),
        s = this.$target.outerHeight(),
        h = this.$flyout.width(),
        n = this.$flyout.height(),
        a = this.$zoom.width(),
        r = this.$zoom.height();
      c = Math.ceil(a - h), l = Math.ceil(r - n), c < 0 && (c = 0), l < 0 && (l = 0), d = c / o, p = l / s, this.isOpen = !0, this.opts.onShow.call(this), t && this._move(t)
    }
  }, s.prototype._onEnter = function(t) {
    var e = t.originalEvent.touches;
    this.isMouseOver = !0, e && 1 != e.length || (t.preventDefault(), this.show(t, !0))
  }, s.prototype._onMove = function(t) {
    this.isOpen && (t.preventDefault(), this._move(t))
  }, s.prototype._onLeave = function() {
    this.isMouseOver = !1, this.isOpen && this.hide()
  }, s.prototype._onLoad = function(t) {
    t.currentTarget.width && (this.isReady = !0, this.$notice.detach(), this.$flyout.html(this.$zoom), this.$target.removeClass("is-loading").addClass("is-ready"), t.data.call && t.data())
  }, s.prototype._onError = function() {
    var t = this;
    this.$notice.text(this.opts.errorNotice), this.$target.removeClass("is-loading").addClass("is-error"), this.detachNotice = setTimeout(function() {
      t.$notice.detach(), t.detachNotice = null
    }, this.opts.errorDuration)
  }, s.prototype._loadImage = function(t, e) {
    var i = new Image;
    this.$target.addClass("is-loading").append(this.$notice.text(this.opts.loadingNotice)), this.$zoom = o(i).on("error", o.proxy(this._onError, this)).on("load", e, o.proxy(this._onLoad, this)), i.style.position = "absolute", i.src = t
  }, s.prototype._move = function(t) {
    if (0 === t.type.indexOf("touch")) {
      var e = t.touches || t.originalEvent.touches;
      u = e[0].pageX, f = e[0].pageY
    } else u = t.pageX || u, f = t.pageY || f;
    var i = this.$target.offset(),
      o = u - i.left,
      s = f - i.top,
      h = Math.ceil(o * d),
      n = Math.ceil(s * p);
    if (h < 0 || n < 0 || c < h || l < n) this.hide();
    else {
      var a = -1 * n,
        r = -1 * h;
      this.$zoom.css({
        top: a,
        left: r
      }), this.opts.onMove.call(this, a, r)
    }
  }, s.prototype.hide = function() {
    this.isOpen && !1 !== this.opts.beforeHide.call(this) && (this.$flyout.detach(), this.isOpen = !1, this.opts.onHide.call(this))
  }, s.prototype.swap = function(t, e, i) {
    this.hide(), this.isReady = !1, this.detachNotice && clearTimeout(this.detachNotice), this.$notice.parent().length && this.$notice.detach(), this.$target.removeClass("is-loading is-ready is-error"), this.$image.attr({
      src: t,
      srcset: o.isArray(i) ? i.join() : i
    }), this.$link.attr(this.opts.linkAttribute, e)
  }, s.prototype.teardown = function() {
    this.hide(), this.$target.off(".easyzoom").removeClass("is-loading is-ready is-error"), this.detachNotice && clearTimeout(this.detachNotice), delete this.$link, delete this.$zoom, delete this.$image, delete this.$notice, delete this.$flyout, delete this.isOpen, delete this.isReady
  }, o.fn.easyZoom = function(e) {
    return this.each(function() {
      var t = o.data(this, "easyZoom");
      t ? void 0 === t.isOpen && t._init() : o.data(this, "easyZoom", new s(this, e))
    })
  }, s
});
;/*})'"*/;/*})'"*/
(function($) {
  /**
   * Initialize easy zoom functionality.
   */
  Drupal.behaviors.easyzoom = {
    attach: function(context, settings) {

      // Instantiate EasyZoom instances.
      var $easyzoom = $('.easyzoom').easyZoom();

      // Setup thumbnails.
      var api1 = $easyzoom.filter('.easyzoom--with-thumbnails').data('easyZoom');
      $('.easyzoom-thumbnails').on('click', 'a', function(e) {
        var $this = $(this);

        e.preventDefault();

        // Use EasyZoom's `swap` method
        api1.swap($this.data('standard'), $this.attr('href'));
      });

    }
  }

})(jQuery);
;/*})'"*/;/*})'"*/
(function(){
  var fnIndex = 0;
  var fnSwitch = {};
  var fnList = {};
  var breakpoints = [];

    function setSwitch() {
      var onItems = fnSwitch[breaky.value].on;
      var onItemsLength = onItems.length;
      var offItems = fnSwitch[breaky.value].off;
      var offItemsLength = offItems.length;

      for ( var i = 0; i < onItemsLength; i++ ) {
        if(!fnList[onItems[i]].active) {
          fnList[onItems[i]].fn();
          fnList[onItems[i]].active = true;
        }
      }
      for ( var i = 0; i < offItemsLength; i++ ) {
        fnList[offItems[i]].active = false;
      }
    }

     function readValue( el ) {
      return window.getComputedStyle(
          document.querySelector(el), ':before'
        ).getPropertyValue( 'content' ).replace( /\"/g, '' ).replace( /\'/g, '' );
    }

    function appendFunction( fn ) {
      fnIndex++;
      fnList[fnIndex] = {};
      fnList[fnIndex]["fn"] = fn;
      fnList[fnIndex]["active"] = false;
    }
    function indexOf (collection, value) {
        if (Array.prototype.indexOf) {
            return collection.indexOf( value );
        }
        for (var i = 0, l = collection.length; i < l; i++) {
            if(value === collection[i]) {
                return i;
            }
        }
    }
    function connectFunction( view1, direction, view2 ) {
      var viewIndex1 = indexOf(breakpoints, view1);
      var viewIndex2 = indexOf(breakpoints, view2);

      for( var i = 0; i < breakpoints.length; i++ ) {
          if( i == viewIndex1 && direction == "at"
          || i <= viewIndex1 && direction == "below"
          || i >= viewIndex1 && direction == "above"
          || viewIndex1 <= i && i <= viewIndex2 &&  direction == "between" ) {
            fnSwitch[breakpoints[i]].on.push( fnIndex );
          } else {
            fnSwitch[breakpoints[i]].off.push( fnIndex );
          }
      }
      setSwitch();
    }

    function createFnSwitch() {
      breakpointsLength = breakpoints.length;
      for(var i = 0; i < breakpointsLength; i++ ) {
        fnSwitch[breakpoints[i]] = {};
        fnSwitch[breakpoints[i]].on = [];
        fnSwitch[breakpoints[i]].off = [];
      }
    }

    function connectAndAppendFn( fn, view1, direction, view2 ) {
      appendFunction( fn );
      connectFunction( view1, direction, view2 );
    }

    window.breaky = {
      below: function( view, fn ) {
        connectAndAppendFn( fn, view, "below" );
      },
      above: function( view, fn ) {
        connectAndAppendFn( fn, view, "above" );
      },
      between: function( view1, view2, fn ) {
        connectAndAppendFn( fn, view1, "between", view2 );
      },
      at : function( view, fn ) {
        connectAndAppendFn( fn, view, "at" );
      },
      initIE8 : function(bp, value) {
          if(!window.getComputedStyle) {
            breakpoints = bp;
            createFnSwitch();
            breaky.value = value;
          }
      },
      init : function() {
        breakpoints = readValue( "html" ).split( "," );
        createFnSwitch();
        breaky.value = readValue( "body" );
        window.onresize = function () {
          if(breaky.value !== readValue( "body" )) {
            breaky.value = readValue( "body" );
            setSwitch();
          }
        }
      }
     }
    if(window.getComputedStyle) {
      breaky.init();
    }
})();
;/*})'"*/;/*})'"*/
/**
 * @file
 * bootstrap.js
 *
 * Provides general enhancements and fixes to Bootstrap's JS files.
 */

var Drupal = Drupal || {};

(function($, Drupal){
  "use strict";

  Drupal.behaviors.bootstrap = {
    attach: function(context) {
      // Provide some Bootstrap tab/Drupal integration.
      $(context).find('.tabbable').once('bootstrap-tabs', function () {
        var $wrapper = $(this);
        var $tabs = $wrapper.find('.nav-tabs');
        var $content = $wrapper.find('.tab-content');
        var borderRadius = parseInt($content.css('borderBottomRightRadius'), 10);
        var bootstrapTabResize = function() {
          if ($wrapper.hasClass('tabs-left') || $wrapper.hasClass('tabs-right')) {
            $content.css('min-height', $tabs.outerHeight());
          }
        };
        // Add min-height on content for left and right tabs.
        bootstrapTabResize();
        // Detect tab switch.
        if ($wrapper.hasClass('tabs-left') || $wrapper.hasClass('tabs-right')) {
          $tabs.on('shown.bs.tab', 'a[data-toggle="tab"]', function (e) {
            bootstrapTabResize();
            if ($wrapper.hasClass('tabs-left')) {
              if ($(e.target).parent().is(':first-child')) {
                $content.css('borderTopLeftRadius', '0');
              }
              else {
                $content.css('borderTopLeftRadius', borderRadius + 'px');
              }
            }
            else {
              if ($(e.target).parent().is(':first-child')) {
                $content.css('borderTopRightRadius', '0');
              }
              else {
                $content.css('borderTopRightRadius', borderRadius + 'px');
              }
            }
          });
        }
      });
    }
  };

  /**
   * Bootstrap Popovers.
   */
  Drupal.behaviors.bootstrapPopovers = {
    attach: function (context, settings) {
      if (settings.bootstrap && settings.bootstrap.popoverEnabled) {
        var elements = $(context).find('[data-toggle="popover"]').toArray();
        for (var i = 0; i < elements.length; i++) {
          var $element = $(elements[i]);
          var options = $.extend(true, {}, settings.bootstrap.popoverOptions, $element.data());
          $element.popover(options);
        }
      }
    }
  };

  /**
   * Bootstrap Tooltips.
   */
  Drupal.behaviors.bootstrapTooltips = {
    attach: function (context, settings) {
      if (settings.bootstrap && settings.bootstrap.tooltipEnabled) {
        var elements = $(context).find('[data-toggle="tooltip"]').toArray();
        for (var i = 0; i < elements.length; i++) {
          var $element = $(elements[i]);
          var options = $.extend(true, {}, settings.bootstrap.tooltipOptions, $element.data());
          $element.tooltip(options);
        }
      }
    }
  };

  /**
   * Anchor fixes.
   */
  var $scrollableElement = $();
  Drupal.behaviors.bootstrapAnchors = {
    attach: function(context, settings) {
      var i, elements = ['html', 'body'];
      if (!$scrollableElement.length) {
        for (i = 0; i < elements.length; i++) {
          var $element = $(elements[i]);
          if ($element.scrollTop() > 0) {
            $scrollableElement = $element;
            break;
          }
          else {
            $element.scrollTop(1);
            if ($element.scrollTop() > 0) {
              $element.scrollTop(0);
              $scrollableElement = $element;
              break;
            }
          }
        }
      }
      if (!settings.bootstrap || !settings.bootstrap.anchorsFix) {
        return;
      }
      var anchors = $(context).find('a').toArray();
      for (i = 0; i < anchors.length; i++) {
        if (!anchors[i].scrollTo) {
          this.bootstrapAnchor(anchors[i]);
        }
      }
      $scrollableElement.once('bootstrap-anchors', function () {
        $scrollableElement.on('click.bootstrap-anchors', 'a[href*="#"]:not([data-toggle],[data-target])', function(e) {
          this.scrollTo(e);
        });
      });
    },
    bootstrapAnchor: function (element) {
      element.validAnchor = element.nodeName === 'A' && (location.hostname === element.hostname || !element.hostname) && element.hash.replace(/#/,'').length;
      element.scrollTo = function(event) {
        var attr = 'id';
        var $target = $(element.hash);
        if (!$target.length) {
          attr = 'name';
          $target = $('[name="' + element.hash.replace('#', '') + '"');
        }
        var offset = $target.offset().top - parseInt($scrollableElement.css('paddingTop'), 10) - parseInt($scrollableElement.css('marginTop'), 10);
        if (this.validAnchor && $target.length && offset > 0) {
          if (event) {
            event.preventDefault();
          }
          var $fakeAnchor = $('<div/>')
            .addClass('element-invisible')
            .attr(attr, $target.attr(attr))
            .css({
              position: 'absolute',
              top: offset + 'px',
              zIndex: -1000
            })
            .appendTo(document);
          $target.removeAttr(attr);
          var complete = function () {
            location.hash = element.hash;
            $fakeAnchor.remove();
            $target.attr(attr, element.hash.replace('#', ''));
          };
          if (Drupal.settings.bootstrap.anchorsSmoothScrolling) {
            $scrollableElement.animate({ scrollTop: offset, avoidTransforms: true }, 400, complete);
          }
          else {
            $scrollableElement.scrollTop(offset);
            complete();
          }
        }
      };
    }
  };

})(jQuery, Drupal);
;/*})'"*/;/*})'"*/
