jQuery(function ($){
$(document).on('click', '.pb-faq__toggle', function (event){
event.preventDefault();
var button=$(this);
var item=button.closest('.pb-faq');
var panel=item.find('.pb-faq__panel');
var open=item.hasClass('is-open');
item.toggleClass('is-open', !open);
button.attr('aria-expanded', open ? 'false':'true');
panel.stop(true, true)[open ? 'slideUp':'slideDown'](180);
});
$(document).on('click', '.pb-process__trigger', function (){
var stage=$(this).closest('.pb-process__stage');
var section=stage.closest('.pb-process');
if(stage.hasClass('is-active')){
return;
}
section.find('.pb-process__stage.is-active').removeClass('is-active').find('.pb-process__body').stop(true, true).slideUp(180);
stage.addClass('is-active');
stage.find('.pb-process__body').stop(true, true).slideDown(180);
var src=stage.attr('data-image');
var photo=section.find('.pb-process__photo');
if(src&&photo.attr('src')!==src){
photo.stop(true, true).animate({ opacity: 0 }, 200, function (){
var reveal=function (){
photo.animate({ opacity: 1 }, 280);
};
photo.attr('src', src);
if(photo[0].complete){
reveal();
}else{
photo.one('load error', reveal);
}});
}});
var stats=document.querySelectorAll('.pb-stat__value[data-count]');
if(stats.length){
var reduced=window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var formatStat=function (value, target){
var text=String(target);
var decimals=text.indexOf('.')===-1 ? 0:text.length - text.indexOf('.') - 1;
return decimals ? value.toFixed(decimals):String(Math.round(value));
};
var runStat=function (el){
if(el.getAttribute('data-counted')==='1'){
return;
}
el.setAttribute('data-counted', '1');
var target=parseFloat(el.getAttribute('data-count'));
if(isNaN(target)||reduced){
return;
}
var started=null;
var duration=1100;
var step=function (now){
if(started===null){
started=now;
}
var progress=Math.min(1, (now - started) / duration);
var eased=1 - Math.pow(1 - progress, 3);
el.textContent=formatStat(target * eased, target);
if(progress < 1){
window.requestAnimationFrame(step);
}};
window.requestAnimationFrame(step);
};
if('IntersectionObserver' in window&&!reduced){
var seen=new IntersectionObserver(function (entries, observer){
entries.forEach(function (entry){
if(!entry.isIntersecting){
return;
}
runStat(entry.target);
observer.unobserve(entry.target);
});
}, { threshold: 0.5 });
Array.prototype.forEach.call(stats, function (el){
seen.observe(el);
});
}}
$('[data-message-placeholder]').each(function (){
var text=$(this).attr('data-message-placeholder');
if(text){
$(this).find('textarea').attr('placeholder', text);
}});
var card=document.querySelector('.pb-popup');
if(!card){
return;
}
var key='pbPromoPopup_' + card.getAttribute('data-page');
if(window.localStorage.getItem(key)){
return;
}
window.setTimeout(function (){
card.hidden=false;
card.classList.add('is-visible');
}, 800);
var dismiss=card.querySelector('.pb-popup__dismiss');
if(dismiss){
dismiss.addEventListener('click', function (){
card.classList.remove('is-visible');
card.hidden=true;
window.localStorage.setItem(key, '1');
});
}});