////sticky-menu

$('#well').on('scroll', function() {
  if ($(this).scrollTop() > 1) {
    $('.site-navigation').addClass("stickyHeader");
    $(".site-navigation-menu").addClass('stickySite-navigation-menu')
    $(".site-navigation-menu-lang-menu").addClass('sticky-site-navigation-menu-lang-menu')
  } else {
    $('.site-navigation').removeClass("stickyHeader");
    $(".site-navigation-menu").removeClass('stickySite-navigation-menu')
    $(".site-navigation-menu-lang-menu").removeClass('sticky-site-navigation-menu-lang-menu')
  }
});

/// Page Loader
$(window).on('load', function () {
});
setTimeout(function () {
  $("#loader-wrapper").fadeOut();
  $("#loader-wrapper").delay(200).fadeOut("slow");
}, 200);
////mobil-sticky-menu
$(window).scroll(function() {
    if ($(this).scrollTop() > 1){  
        $('.mobil-site-navigation ').addClass("mobile-sticky");
      }
      else{
        $('.mobil-site-navigation ').removeClass("mobile-sticky");
      }
  }); 
/// go-up button
$(window).scroll(function () {
      if ($(this).scrollTop() > 100) {
         $('.scrollup').fadeIn();
         } else {
            $('.scrollup').fadeOut();
}});
 $('.scrollup').click(function () {
      $("html, body").animate({
      scrollTop: 0}, 50);
         return false;   
});
//// acordion-menu-js
var Accordion = function(el, multiple) {
  this.el = el || {};
  this.multiple = multiple || false;
  var links = this.el.find('.link');
  links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown)
}
Accordion.prototype.dropdown = function(e) {
  var $el = e.data.el;
      $this = $(this),
      $next = $this.next();
  $next.slideToggle();
  $this.parent().toggleClass('open');
  if (!e.data.multiple) {
      $el.find('.submenu').not($next).slideUp().parent().removeClass('open');
  };
}	
var accordion = new Accordion($('#accordion'), false);
////wow.js
new WOW().init();
///fancybox
$('[data-fancybox="gallery"]').fancybox({
    loop: true, 
    arrows: true, 
    infobar: true, 
    buttons: ['zoom', 'slideShow', 'thumbs', 'close'], 
    protect: true 
});
$(document).ready(function() {
  var owl = $('#owl-slider');
  owl.owlCarousel({
    loop: false,  
    nav: true,  
    navText: ['', ''], 
    items: 1,
    autoplay:false,
    autoplaySpeed:7000,
  });
  var slideNames = [];
  var slideElements = [];
  $('#owl-slider .item').each(function(index) {
    var slideName = $(this).data('slide-name');
    slideNames.push(slideName);
    slideElements.push($(this));
  });
  var listHtml = '<ul>';
  slideNames.forEach(function(name, index) {
    listHtml += '<li class="slide-name" data-slide-index="' + index + '">' + name + '</li>';
  });
  listHtml += '</ul>';
  $('#slide-names-list').html(listHtml);
  $('.slide-name').click(function() {
    var slideIndex = $(this).data('slide-index');
    owl.trigger('to.owl.carousel', [slideIndex, 500]);
  });
  owl.on('changed.owl.carousel', function(event) {
    var currentIndex = event.item.index;
    $('.slide-name').removeClass('active-border');
    $('.slide-name').eq(currentIndex).addClass('active-border');
  });
  $('.slide-name').eq(0).addClass('active-border');
});
///////// Scroll Counter
$(document).ready(function () {
  const listItems = $('#featuresList ul li');
  let scrolling = false;
  $(window).scroll(function () {
      scrolling = true;
  });
  setInterval(function () {
  if (scrolling) {
  const scrollPosition = $(window).scrollTop() + 350;
  listItems.each(function () {
  const liOffsetTop = $(this).offset().top;
  if (scrollPosition >= liOffsetTop && scrollPosition < liOffsetTop + $(this).outerHeight()) {
  $(this).addClass('active').siblings().removeClass('active');
  var imagesEach =  $('#featuresList .active').attr('data-img');
  $('#featuresImg').css('background-image', 'url("' + imagesEach + '")');
  return false;
  }
  });
  scrolling = false;
  }
  }, 75);
});

/** Owl Slider */
$('#owl-slider').owlCarousel({
  loop: true,
  margin: 10,
  nav: false,
  autoplay: true, // This enables autoplay
  autoplayTimeout: 3000, // Time between slides (in milliseconds)
  autoplayHoverPause: true, // Pauses autoplay on hover
  touchDrag: false,
  mouseDrag: false,
  responsive: {
      0: {
          items: 1
      },
      600: {
          items: 1
      },
      1000: {
          items: 1
      }
  }
})
/** Owl Mobil Slider */
$('#owl-mobil-slider').owlCarousel({
  loop: true,
  margin: 0,
  nav: false,
  autoplay: true, // This enables autoplay
  autoplayTimeout: 3000, // Time between slides (in milliseconds)
  autoplayHoverPause: true, // Pauses autoplay on hover
  responsive: {
      0: {
          items: 1
      },
      600: {
          items: 1
      }
  }
})
///////// counter.js 
$('.counting').each(function() {
  var $this = $(this),
      countTo = $this.attr('data-count');
  
  $({ countNum: $this.text()}).animate({
    countNum: countTo
  },

  {
    duration: 10000,
    easing:'linear',
    step: function() {
      $this.text(Math.floor(this.countNum));
    },
    complete: function() {
      $this.text(this.countNum);
      //alert('finished');
    }

  });
  /**Pop up show */
  $('.popup-btn').hide();
  $(window).scroll(function () {
    if ($(this).scrollTop() > 100) {
       $('.popup-btn').fadeIn(10);
       } else {
          $('.popup-btn').fadeOut(10);
  }});  
});
/*****************/
