// For Header sticky functionality
if (document.querySelector('.neatnote-fixedheader')) {
  window.addEventListener('scroll', function () {
    const headerSection = document.querySelector('.NeatNote-headerSection');
    // const bannerElmain = this.document.querySelector('#neatnote-main-content');
    if (window.scrollY > 50) {
      headerSection.classList.add('neatnote-fixed-header');
      // bannerElmain.classList.add('NeatNote-BannerViewport');
    } else {
      headerSection.classList.remove('neatnote-fixed-header');
      // bannerElmain.classList.remove('NeatNote-BannerViewport');
    }
  });
}

// Animation
AOS.init({
  offset: 100,
  duration: 1500,
  delay: 100,
  once: true
});
window.addEventListener('load', function () {
  AOS.refresh();
});


jQuery(window).on('load', function () {
  equalheight('.neatnote_equal_title');
  equalheight('.neatnote_equal_content');
  equalheight('.neatnote_equal_height');
});

jQuery(window).on('resize', function () {
  equalheight('.neatnote_equal_title');
  equalheight('.neatnote_equal_content');
  equalheight('.neatnote_equal_height');
});

// Equal Height Function
equalheight = function (container) {
  var currentTallest = 0, currentRowStart = 0, rowDivs = new Array(), $el, topPosition = 0;
  jQuery(container).each(function () {
    $el = jQuery(this);
    jQuery($el).height('auto')
    topPostion = $el.position().top;
    if (currentRowStart != topPostion) {
      for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
        rowDivs[currentDiv].height(currentTallest);
      }
      rowDivs.length = 0; // empty the array
      currentRowStart = topPostion;
      currentTallest = $el.outerHeight();
      rowDivs.push($el);
    } else {
      rowDivs.push($el);
      currentTallest = (currentTallest < $el.outerHeight()) ? ($el.outerHeight()) : (currentTallest);
    }
    for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
      rowDivs[currentDiv].height(currentTallest);
    }
  });
}



