");
}
function submitPagingForm() {
setObituaryLoading();
form.submit();
var top = $('#obituaries-search').offset().top;
var topNavigation = $('.head-menu');
if (topNavigation.length > 0 && topNavigation.css("position") === 'fixed') {
top = top - topNavigation.outerHeight();
}
if ($(window).scrollTop() > top-30) {
$('html, body').animate({ scrollTop: top-30 }, 300);
}
}
if (location.hash.length > 1) {
var pageNum = location.hash.replace('#', '');
if (pageNum != '1') {
currentPage.val(pageNum);
submitPagingForm();
}
}
searchInput.keypress(function(e){
if (e.which == 13){
currentPage.val("1");
location.hash = 1;
submitPagingForm();
}
});
$("#obituaries-search .button").click(function () {
currentPage.val("1");
location.hash = 1;
submitPagingForm();
});
$(".obituaries-nav .prev").click(function () {
if (currentPage.val() > 1) {
var newPageNum = currentPage.val() - 1;
currentPage.val(newPageNum);
location.hash = newPageNum;
submitPagingForm();
}
});
$(".obituaries-nav .next").click(function () {
var hasNextPage = $("#hdnHasNextPage").val() === 'True';
if (hasNextPage) {
var newPageNum = currentPage.val() * 1 + 1;
currentPage.val(newPageNum);
location.hash = newPageNum;
submitPagingForm();
}
});
refreshObButtons();
$(".inputContainer").parent().find("select").on("change", function(e) {
submitPagingForm();
});
});
function updateStoreParams() {
const storeCTAs = Array.from(document.querySelectorAll(".obituariesList a.addCdxParamToLink"));
const uuid = "getGAuuid" in window && window.getGAuuid();
storeCTAs.forEach((element) => {
let href = element.href;
if (href) {
const storeUrl = new URL(href);
const params = new URLSearchParams(storeUrl.searchParams);
if (uuid) {
params.set("tcouuid", uuid);
}
href = `${storeUrl.origin}${storeUrl.pathname}?${params.toString()}`;
}
element.href = href;
});
}
function refreshObButtons() {
var currentPage = $("#hdnCurrentPage");
if (currentPage.val() > 1) {
$(".obituaries-nav .prev").removeClass("disabled");
} else {
$(".obituaries-nav .prev").addClass("disabled");
}
var hasNextPage = $("#hdnHasNextPage").val() === 'True';
if (hasNextPage) {
$(".obituaries-nav .next").removeClass("disabled");
} else {
$(".obituaries-nav .next").addClass("disabled");
}
updateStoreParams();
}