$(function(){function disableAlertsByCookies(type,aItems){var allCookies=$.cookie();var $alertItems=aItems;var matchingCookies={};$.each(allCookies,function(key,value){var elemId='#'+key;if(type=="popup"&&key.includes("alert-modal-")){$alertItems.has(elemId).remove();} if(type=="banner"&&key.includes("alert-banner-")){if(window.matchMedia('(prefers-reduced-motion: reduce)').matches){$(elemId).hide(0,HeaderAdjustHeight);}else{$(elemId).hide(0,HeaderAdjustHeight);}}});return matchingCookies;} let $bannerAlerts=$('.umb--alerts--banners');if($bannerAlerts.is('*')){HeaderAdjustHeight();$(document).on('scroll',function(){HeaderAdjustHeight();});$(window).on('resize',function(){HeaderAdjustHeight();});var $alertBanners=$bannerAlerts.find(".umb--alert");disableAlertsByCookies("banner",$alertBanners);$bannerAlerts.find('.umb--alert__close').click(function(event){event.preventDefault();if(window.matchMedia('(prefers-reduced-motion: reduce)').matches){$(this).parents('.umb--alert').hide(400,HeaderAdjustHeight);}else{$(this).parents('.umb--alert').slideUp(400,HeaderAdjustHeight);} var bannerId=$(this).parents('.umb--alert').attr('id');$.cookie(bannerId,1,{path:"/"});});} function HeaderAdjustHeight(){if($('body.show_header-on-scroll-lg').is('*')&&$(window).width()>=$('body').attr('data-large-breakpoint')){if($(window).scrollTop()==0){$('header').css('top',$('.umb--alerts--banners').height());}else if($(window).scrollTop()==40){$('header').css('top',$('.umb--alerts--banners').height()-40);}else{$('header').css('top','0');}} if($('body.show_header-on-scroll-sm').is('*')&&$(window).width()<$('body').attr('data-large-breakpoint')){if($(window).scrollTop()==0){$('header').css('top',$('.umb--alerts--banners').height());}else if($(window).scrollTop()==40){$('header').css('top',$('.umb--alerts--banners').height()-40);}else{$('header').css('top','0');}} if($('body.hide_header-on-scroll-lg').is('*')&&$(window).width()>=$('body').attr('data-large-breakpoint')){$('header').css('top','');} if($('body.hide_header-on-scroll-sm').is('*')&&$(window).width()<$('body').attr('data-large-breakpoint')){$('header').css('top','');}} let $modalAlerts=$('.umb--alerts--modals');const $dissmissAllButton=$modalAlerts.find('.umb--alerts__dismiss');if($modalAlerts.length){var $alertPopupCells=$modalAlerts.find(".ghd--carousel__cell");disableAlertsByCookies("popup",$alertPopupCells);jQueryBridget('flickity',Flickity,$);let $alertsCarousel=$modalAlerts.find('.ghd--carousel'),flktyOptions=$alertsCarousel.data('flickity-options');if(window.matchMedia('(prefers-reduced-motion: reduce)').matches){flktyOptions.friction=1;flktyOptions.selectedAttraction=1;} $alertsCarousel.flickity(flktyOptions);let focusableEls={},firstFocusableEl={},lastFocusableEl={},$dissmissAll={};let $activeModal=$('.ghd--carousel__cell.is-selected');trapFocus($activeModal);if(!$alertsCarousel.find('.ghd--carousel__cell').length){hideModalAlerts();} $('.flickity-button.previous').on('click',function(e){defineFocusable($activeModal);focusableEls.each(function(key,value){$(this).removeAttr('tabindex');});$activeModal=$('.ghd--carousel__cell.is-selected');trapFocus($activeModal);});$('.flickity-button.next').on('click',function(e){defineFocusable($activeModal);focusableEls.each(function(key,value){$(this).removeAttr('tabindex');});$activeModal=$('.ghd--carousel__cell.is-selected');trapFocus($activeModal);}) var seenAlertModalCookie=getCookie("seenAlertModal");if(seenAlertModalCookie!=null&&seenAlertModalCookie!=""){hideModalAlerts();} $dissmissAllButton.click(function(){$.cookie("seenAlertModal",1,{path:"/"});hideModalAlerts();});$alertsCarousel.find('.bx--modal-close').click(function(event){event.preventDefault();defineFocusable($activeModal);focusableEls.each(function(key,value){$(this).removeAttr('tabindex');});var flkty=$alertsCarousel.data('flickity');var alertId=flkty.selectedElement.firstElementChild.id;$.cookie(alertId,1,{path:"/"});$alertsCarousel.flickity('remove',flkty.selectedElement);$activeModal=$('.ghd--carousel__cell.is-selected');trapFocus($activeModal);if(!$alertsCarousel.find('.ghd--carousel__cell').length){hideModalAlerts();}});$alertsCarousel.find('.bx--btn.bx--btn--primary').click(function(event){defineFocusable($activeModal);focusableEls.each(function(key,value){$(this).removeAttr('tabindex');});var flkty=$alertsCarousel.data('flickity');var alertId=flkty.selectedElement.firstElementChild.id;$.cookie(alertId,1,{path:"/"});$alertsCarousel.flickity('remove',flkty.selectedElement);$activeModal=$('.ghd--carousel__cell.is-selected');trapFocus($activeModal);if(!$alertsCarousel.find('.ghd--carousel__cell').length){hideModalAlerts();}});function hideModalAlerts(){$alertsCarousel.flickity('destroy');if(window.matchMedia('(prefers-reduced-motion: reduce)').matches){$modalAlerts.remove();}else{$modalAlerts.fadeOut(function(){$modalAlerts.remove();});}} function hideBannerAlerts(){if(window.matchMedia('(prefers-reduced-motion: reduce)').matches){$bannerAlerts.remove();}else{$bannerAlerts.slideUp(function(){$bannerAlerts.remove();});}} function defineFocusable(element){focusableEls=element.find('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])');};function trapFocus(element){defineFocusable(element);$dissmissAll=$('.umb--alerts__dismiss:not([disabled])').get(0);if($dissmissAll){focusableEls=focusableEls.add($dissmissAll);} $previousAlert=$alertsCarousel.find('.flickity-button.previous:not([disabled])').get(0);focusableEls=focusableEls.add($previousAlert);$nextAlert=$alertsCarousel.find('.flickity-button.next:not([disabled])').get(0);focusableEls=focusableEls.add($nextAlert);focusableEls.each(function(key,value){$(this).attr('tabindex',key+1)});firstFocusableEl=focusableEls.first();lastFocusableEl=focusableEls.last();firstFocusableEl.focus();lastFocusableEl.on('keydown',function(e){if((e.which===9&&!e.shiftKey)){e.preventDefault();firstFocusableEl.focus();}});firstFocusableEl.on('keydown',function(e){if((e.which===9&&e.shiftKey)){e.preventDefault();lastFocusableEl.focus();}});element.on('keyup',function(e){if(e.keyCode===27){hideModalAlerts();}});}}});;;