jQuery(document).ready(function($) {
	
	(function() {
		
		jqElemNavSentinel = $('#ch-ggs-web-suite-landing-nav-trigger');
		jqElemNav = $('#ch-ggs-web-suite-landing-nav');
		
		if (jqElemNavSentinel.length === 0 || jqElemNav.length === 0) return;
			
		const sentinelEl = jqElemNavSentinel[0];
		const navEl = jqElemNav[0];
		
		
		const stuckClass = 'stuck';
		
		if ("IntersectionObserver" in window &&
				"IntersectionObserverEntry" in window &&
				"intersectionRatio" in window.IntersectionObserverEntry.prototype) {
		
			const handler = function(entries) {
			  if (navEl) {
			    if (!entries[0].isIntersecting) {
			      navEl.classList.add(stuckClass);
			    } else {
			      navEl.classList.remove(stuckClass);
			    }
			  }
			}
			
			const observer = new window.IntersectionObserver(handler);
			observer.observe(sentinelEl);
		}
	})();
})