// <!-- fixed-scroll-nav-js -->

  $(window).scroll(function () {
    if ($(document).scrollTop() > 70) {
      $('nav.pagescrollfix,nav.RWDpagescrollfix').addClass('shrink');
    } else {
      $('nav.pagescrollfix,nav.RWDpagescrollfix').removeClass('shrink');
    }
  });

// <!-- smooth-scrolling-of-move-up -->

  $(document).ready(function () {
    $().UItoTop({
      easingType: 'easeOutQuart'
    });
  });


  jQuery(document).ready(function ($) {
    $(".scroll").click(function (event) {
      event.preventDefault();

      $('html,body').animate({
        scrollTop: $(this.hash).offset().top
      }, 1000);
    });
  });

// <!-- //end-smooth-scrolling -->

  // You can also use"$(window).load(function() {"
  $(function () {
    // Slideshow 4
    $("#slider3").responsiveSlides({
      auto: true,
      pager: true,
      nav: false,
      speed: 500,
      namespace: "callbacks",
      before: function () {
        $('.events').append("<li>before event fired.</li>");
      },
      after: function () {
        $('.events').append("<li>after event fired.</li>");
      }
    });

  });

// <!-- //Testimonials Responsiveslides -->
// <!-- gallery -->

let modalId = $('#image-gallery');
$(document)
.ready(function () {
  loadGallery(true, 'a.thumbnail');
  //This function disables buttons when needed
  function disableButtons(counter_max, counter_current) {
    $('#show-previous-image, #show-next-image')
      .show();
    if (counter_max === counter_current) {
      $('#show-next-image')
        .hide();
    } else if (counter_current === 1) {
      $('#show-previous-image')
        .hide();
    }
  }
  function loadGallery(setIDs, setClickAttr) {
    let current_image,
      selector,
      counter = 0;
    $('#show-next-image, #show-previous-image')
      .click(function () {
        if ($(this)
          .attr('id') === 'show-previous-image') {
          current_image--;
        } else {
          current_image++;
        }
        selector = $('[data-image-id="' + current_image + '"]');
        updateGallery(selector);
      });
    function updateGallery(selector) {
      let $sel = selector;
      current_image = $sel.data('image-id');
      $('#image-gallery-title')
        .text($sel.data('title'));
      $('#image-gallery-image')
        .attr('src', $sel.data('image'));
      disableButtons(counter, $sel.data('image-id'));
    }
    if (setIDs == true) {
      $('[data-image-id]')
        .each(function () {
          counter++;
          $(this)
            .attr('data-image-id', counter);
        });
    }
    $(setClickAttr)
      .on('click', function () {
        updateGallery($(this));
      });
  }
});
// build key actions
$(document)
.keydown(function (e) {
  switch (e.which) {
    case 37: // left
      if ((modalId.data('bs.modal') || {})._isShown && $('#show-previous-image').is(":visible")) {
        $('#show-previous-image')
          .click();
      }
      break;

    case 39: // right
      if ((modalId.data('bs.modal') || {})._isShown && $('#show-next-image').is(":visible")) {
        $('#show-next-image')
          .click();
      }
      break;

    default:
      return; // exit this handler for other keys
  }
  e.preventDefault(); // prevent the default action (scroll / move caret)
});

// <!-- //gallery -->
