1 2// mobile - counter - stats - carousel 3document.addEventListener("DOMContentLoaded", () => { 4 const notificationBar = document.getElementById("notificationBar"); 5 const closeBtn = document.getElementById("closeNotification"); 6 7 // Hide initially 8 notificationBar.style.display = "none"; 9 10 // Find hero-section and get animation duration 11 const heroSection = document.querySelector(".hero-section"); 12 const duration = heroSection ? parseInt(heroSection.getAttribute("data-aos-duration")) || 0 : 0; 13 14 // Wait for hero animation, then show bar 15 setTimeout(() => { 16 notificationBar.style.display = "block"; 17 }, duration); 18 19 // Close button action 20 closeBtn.addEventListener("click", () => { 21 notificationBar.style.display = "none"; 22 }); 23}); 24// aos-script 25require([ 26 'jquery', 27 'aos' // include AOS here 28], function ($, AOS) { 29 30 $(document).ready(function () { 31 if (typeof AOS !== 'undefined') { 32 AOS.init({ 33 once: false, 34 mirror: true 35 }); 36 AOS.refresh(); 37 } else { 38 console.error('AOS is not loaded'); 39 } 40 }); 41 42}); 43// medical coverage 44document.addEventListener("DOMContentLoaded", () => { 45 const majorSection = document.querySelector('.medical-coverage'); 46 47 const observersection = new IntersectionObserver((entries) => { 48 entries.forEach(entry => { 49 if (entry.isIntersecting) { 50 // Add class to start animation 51 entry.target.classList.add('reveal'); 52 } else { 53 // Remove class so animation can restart next time 54 entry.target.classList.remove('reveal'); 55 } 56 }); 57 }, { threshold: 0.2 }); // triggers when 30% of section is visible 58 59 observersection.observe(majorSection); 60}); 61// FAQ-Accordion Script 62document.addEventListener("DOMContentLoaded", () => { 63 document.querySelectorAll(".faq-question").forEach((btn) => { 64 btn.addEventListener("click", () => { 65 const answer = btn.nextElementSibling; 66 67 // close others first 68 document.querySelectorAll(".faq-answer").forEach((ans) => { 69 if (ans !== answer) { 70 ans.classList.remove("open"); 71 ans.previousElementSibling.classList.remove("active"); 72 } 73 }); 74 75 // toggle current 76 btn.classList.toggle("active"); 77 answer.classList.toggle("open"); 78 }); 79 }); 80}); 81// medical-coverage-script 82document.addEventListener("DOMContentLoaded", () => { 83 document.querySelectorAll(".custom-slider, .custom-slider-2").forEach((slider) => { 84 const slides = slider.querySelectorAll(".slide"); 85 const dots = slider.querySelectorAll(".dot"); 86 let currentIndex = 0; 87 let startX = 0; 88 let endX = 0; 89 90 function showSlide(index) { 91 slides.forEach((slide, i) => { 92 slide.classList.toggle("active", i === index); 93 dots[i].classList.toggle("active", i === index); 94 }); 95 currentIndex = index; 96 } 97 98 // Dot click 99 dots.forEach((dot, i) => { 100 dot.addEventListener("click", () => showSlide(i)); 101 }); 102 103 // Auto slide 104 setInterval(() => { 105 let nextIndex = (currentIndex + 1) % slides.length; 106 showSlide(nextIndex); 107 }, 3000); 108 109 // --- Swipe / Drag --- 110 // Mobile touch 111 slider.addEventListener("touchstart", (e) => { 112 startX = e.touches[0].clientX; 113 }); 114 115 slider.addEventListener("touchend", (e) => { 116 endX = e.changedTouches[0].clientX; 117 handleSwipe(); 118 }); 119 120 // Desktop mouse drag 121 slider.addEventListener("mousedown", (e) => { 122 startX = e.clientX; 123 }); 124 125 slider.addEventListener("mouseup", (e) => { 126 endX = e.clientX; 127 handleSwipe(); 128 }); 129 130 function handleSwipe() { 131 let diff = endX - startX; 132 if (Math.abs(diff) > 50) { // minimum swipe distance 133 if (diff > 0) { 134 // swipe right previous 135 let prevIndex = (currentIndex - 1 + slides.length) % slides.length; 136 showSlide(prevIndex); 137 } else { 138 // swipe left next 139 let nextIndex = (currentIndex + 1) % slides.length; 140 showSlide(nextIndex); 141 } 142 } 143 } 144 }); 145}); 146// about content 147document.addEventListener("DOMContentLoaded", () => { 148 const aboutSection = document.querySelector('.about-content'); 149 150 const observer = new IntersectionObserver((entries) => {
151 entries.forEach(entry => { 152 if (entry.isIntersecting) { 153 // Add class to start animation 154 entry.target.classList.add('reveal'); 155 } else { 156 // Remove class so animation can restart next time 157 entry.target.classList.remove('reveal'); 158 } 159 }); 160 }, { threshold: 0.3 }); // triggers when 30% of section is visible 161 162 observer.observe(aboutSection); 163}); 164// video 165document.addEventListener("DOMContentLoaded", () => { 166 const playBtn = document.getElementById("openVideo"); 167 const fullscreenVideo = document.getElementById("fullscreenVideo"); 168 const closeBtn = document.getElementById("closeBtn"); 169 const videoPlayer = document.getElementById("fullscreenVideoPlayer"); 170 171 // Open custom overlay video (not native fullscreen) 172 playBtn.addEventListener("click", () => { 173 fullscreenVideo.style.display = "flex"; 174 videoPlayer.currentTime = 0; 175 176 // Avoid native fullscreen on iOS play inline 177 videoPlayer.setAttribute("playsinline", ""); 178 videoPlayer.setAttribute("webkit-playsinline", ""); 179 180 videoPlayer.play().catch(() => { 181 console.log("Autoplay blocked waiting for user interaction."); 182 }); 183 184 document.body.style.overflow = "hidden"; 185 }); 186 187 // Close custom video overlay 188 closeBtn.addEventListener("click", () => { 189 fullscreenVideo.style.display = "none"; 190 videoPlayer.pause(); 191 document.body.style.overflow = "auto"; 192 }); 193}); 194require(['jquery', 'Magento_Ui/js/modal/modal', 'mage/url', 'jquery/jquery.cookie', 'owlcarousel'], function ($, modal, urlBuilder) { 195 $(document).ready(function () { 196 var $carouselmedical = $('.medical-slider'); 197 198 if ($carouselmedical.length) { 199 $carouselmedical.owlCarousel({ 200 loop: true, 201 margin: 24, 202 stagePadding: 0, 203 nav: false, 204 dots: true, 205 center: false, 206 autoHeight: false, 207 208 autoplay: true, 209 autoplayTimeout: 5500, 210 autoplayHoverPause: true, 211 212 responsive: { 213 0: { 214 items: 1 215 }, 216 768: { 217 items: 2 218 } 219 } 220 }); 221 } 222 223 var $carousel = $('.testi-carousel'); 224 225 if ($carousel.length) { 226 $carousel.owlCarousel({ 227 loop: true, 228 margin: 24, 229 stagePadding: 0, 230 nav: false, 231 dots: true, 232 center: false, 233 autoHeight: false, 234 235 autoplay: true, 236 autoplayTimeout: 5500, 237 autoplayHoverPause: true, 238 239 responsive: { 240 0: { 241 items: 1 242 }, 243 768: { 244 items: 2 245 } 246 } 247 }); 248 } 249 250 251 252 const openVideohome = document.getElementById("openVideohome"); 253 const closeVideohome = document.getElementById("closeVideohome"); 254 const videoPopuphome = document.getElementById("videoPopuphome"); 255 const popupVideohome = document.getElementById("popupVideo-home"); 256 257 if ( 258 !openVideohome || 259 !closeVideohome || 260 !videoPopuphome || 261 !popupVideohome 262 ) { 263 console.error("Video popup elements not found."); 264 return; 265 } 266 267 let videoLoaded = false; 268 269 openVideohome.addEventListener("click", function () { 270 271 videoPopuphome.classList.add("active"); 272 document.body.style.overflow = "hidden"; 273 274 // Load video only on first popup open 275 if (!videoLoaded) { 276 popupVideohome.src = VIDEO_URL; 277 popupVideohome.load(); 278 videoLoaded = true; 279 } 280 281 popupVideohome.currentTime = 0; 282 283 popupVideohome.play().catch(function (error) { 284 console.log("Video play error:", error); 285 }); 286 }); 287 288 closeVideohome.addEventListener("click", closePopupmenu); 289 290 videoPopuphome.addEventListener("click", function (e) { 291 if (e.target === videoPopuphome) { 292 closePopupmenu(); 293 } 294 }); 295 296 document.addEventListener("keydown", function (e) { 297 if ( 298 e.key === "Escape" && 299 videoPopuphome.classList.contains("active") 300 ) { 301 closePopupmenu(); 302 } 303 }); 304 305 function closePopupmenu() { 306 videoPopuphome.classList.remove("active"); 307 308 popupVideohome.pause(); 309 popupVideohome.currentTime = 0; 310 311 document.body.style.overflow = ""; 312 } 313 314 315 // ============================== 316 // DOB Validation (MM/DD/YYYY) 317 // ============================== 318 $('#quote_dob').on('input', function () { 319 let v = $(this).val().replace(/\D/g, ''); // only digits 320 321 // Auto format MM/DD/YYYY 322 if (v.length > 2 && v.length <= 4) { 323 v = v.slice(0, 2) + '/' + v.slice(2); 324 } else if (v.length > 4) { 325 v = v.slice(0, 2) + '/' + v.slice(2, 4) + '/' + v.slice(4, 8); 326 } 327 328 $(this).val(v); 329 }); 330 331 $('input.spouse-dob').on('input', function () { 332 let v = $(this).val().replace(/\D/g, ''); // only digits 333 334 // Auto format MM/DD/YYYY 335 if (v.length > 2 && v.length <= 4) { 336 v = v.slice(0, 2) + '/' + v.slice(2); 337 } else if (v.length > 4) { 338 v = v.slice(0, 2) + '/' + v.slice(2, 4) + '/' + v.slice(4, 8); 339 } 340 341 $(this).val(v); 342 }); 343 344 $('input.spouse-dob-mobile').on('input', function () { 345 let v = $(this).val().replace(/\D/g, ''); // only digits 346 347 // Auto format MM/DD/YYYY 348 if (v.length > 2 && v.length <= 4) { 349 v = v.slice(0, 2) + '/' + v.slice(2); 350 } else if (v.length > 4) { 351 v = v.slice(0, 2) + '/' + v.slice(2, 4) + '/' + v.slice(4, 8); 352 } 353 354 $(this).val(v); 355 }); 356 357 function validateDOB($input) { 358 const val = $input.val().trim(); 359 if (val === '') return true; // allow empty 360 361 const regex = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/(\d{4})$/; 362 if (!regex.test(val)) { 363 alert('Please enter a valid date in MM/DD/YYYY format.'); 364 $input.val(''); 365 return false;
366 } 367 368 const parts = val.split('/'); 369 let mm = parseInt(parts[0], 10); 370 let dd = parseInt(parts[1], 10); 371 let yyyy = parseInt(parts[2], 10); 372 let date = new Date(yyyy, mm - 1, dd); 373 374 let today = new Date(); 375 let currentYear = today.getFullYear(); 376 today.setHours(0, 0, 0, 0); 377 378 if ( 379 date.getFullYear() !== yyyy || 380 date.getMonth() + 1 !== mm || 381 date.getDate() !== dd || 382 yyyy < 1900 || 383 yyyy === currentYear || 384 date > today 385 ) { 386 alert('Please enter a valid date between 01/01/1900 and last year.'); 387 $input.val(''); 388 return false; 389 } 390 return true; 391 } 392 393 $('#quote_dob').on('blur', function () { 394 validateDOB($(this)); 395 }); 396 397 $('#quote_dob').on('keydown', function (e) { 398 if (e.key === 'Enter') { 399 e.preventDefault(); 400 validateDOB($(this)); 401 } 402 }); 403 404 $('input.spouse-dob').on('blur', function () { 405 validateDOB($(this)); 406 }); 407 408 $('input.spouse-dob').on('keydown', function (e) { 409 if (e.key === 'Enter') { 410 e.preventDefault(); 411 validateDOB($(this)); 412 } 413 }); 414 415 $('input.spouse-dob-mobile').on('blur', function () { 416 validateDOB($(this)); 417 }); 418 419 $('input.spouse-dob-mobile').on('keydown', function (e) { 420 if (e.key === 'Enter') { 421 e.preventDefault(); 422 validateDOB($(this)); 423 } 424 }); 425 426 // ============================== 427 // ZIP Code Validation (US) 428 // ============================== 429 $('#quote_zipCode').on('input', function () { 430 $(this).val($(this).val().replace(/[^0-9-]/g, '')); // digits + dash only 431 }); 432 433 $('#quote_zipCode').on('blur', function () { 434 const val = $(this).val().trim(); 435 if (val === '') return; // allow empty 436 437 const regex = /^\d{5}(-\d{4})?$/; // 5 digits or ZIP+4 438 if (!regex.test(val)) { 439 alert('Please enter a valid US ZIP code (e.g., 12345 or 12345-6789).'); 440 $(this).val(''); 441 } 442 }); 443 444 $(".quote-section .gender-card").on("click", function () { 445 $(this).parent().parent().find("div.gender-card").removeClass('gender-active'); 446 $(this).addClass('gender-active'); 447 $(this).find('input[type="radio"]').prop("checked", true); 448 }); 449 // Family Toggle 450 $('input#familyToggle').on('change', function () { 451 if ($(this).is(':checked') && $("input#quote_zipCode").val() && $("input#quote_dob").val() && ($("input.quote_male").is(":checked") || $("input.quote_female").is(":checked"))) { 452 dataLayer.push({ 453 event: "family_member_added" 454 }); 455 console.log("family_member_added"); 456 if ($(window).width() >= 768) { 457 // Initialize the modal on the element 458 // popup 459 var popup = $('#custom-popup'); 460 if (!popup.data('mageModal')) { 461 var options = { 462 type: 'popup', 463 title: 'Who else needs coverage?', 464 modalClass: 'custom-popup', 465 buttons: [] 466 }; 467 modal(options, popup); 468 469 popup.closest('.modal-popup').find('.modal-title').attr('id', 'mtitle').after('<p>Add your spouse or partner and any children under 26.</p>'); 470 } 471 472 popup.trigger('openModal'); 473 if ($("input#spouseToggle").is(':checked')) { 474 $('#spouseYes').removeClass("active"); 475 $('#spouseNo').addClass('active').trigger('click'); 476 $('#childYes').removeClass("active"); 477 $('#childNo').addClass("active").trigger('click'); 478 $(".spouse-gender-div").show(); 479 $(".spouse-dob-div").show(); 480 } else { 481 $('#spouseYes').removeClass("active"); 482 $('#spouseNo').addClass('active').trigger('click'); 483 484 $('#childYes').removeClass("active"); 485 $('#childNo').addClass("active").trigger('click'); 486 $(".spouse-gender-div").hide(); 487 $(".spouse-dob-div").hide(); 488 } 489 if ($("input#childToggle").is(':checked')) { 490 $(".children-number").show(); 491 } else { 492 $(".children-number").hide(); 493 } 494 495 } else { 496 $(".quote-section").hide(); 497 $(".mobile_quote_rates").show(); 498 window.scrollTo({ top: $('section.mobile-quote').offset().top, behavior: 'smooth' }); 499 if ($("input#spouseToggleMobile").is(':checked')) { 500 $('#spouseYesMobile').removeClass("active"); 501 $('#spouseNoMobile').addClass('active').trigger('click'); 502 503 $(".spouse-gender-div-mobile").show(); 504 $(".spouse-dob-div-mobile").show(); 505 } else { 506 $('#spouseYesMobile').removeClass("active"); 507 $('#spouseNoMobile').addClass('active').trigger('click'); 508 509 $(".spouse-gender-div-mobile").hide(); 510 $(".spouse-dob-div-mobile").hide(); 511 } 512 if ($("input#childToggleMobile").is(':checked')) { 513 $('#childYesMobile').removeClass("active"); 514 $('#childNoMobile').addClass("active").trigger('click'); 515 $(".children-number-mobile").show(); 516 } else { 517 $('#childYesMobile').removeClass("active"); 518 $('#childNoMobile').addClass("active").trigger('click'); 519 $(".children-number-mobile").hide(); 520 } 521 } 522 523 } else { 524 if ($("input#quote_zipCode").val() && $("input#quote_dob").val() && ($("input.quote_male").is(":checked") || $("input.quote_female").is(":checked"))) { 525 $(this).prop('checked', false); 526 } else { 527 alert('Please enter your Location, Date of Birth, and Gender details first.'); 528 $(this).prop('checked', false); 529 } 530 } 531 }); 532 533 // Spouse Toggle 534 $('input#spouseToggle').on('change', function () { 535 if ($(this).is(':checked')) { 536 $(".spouse-gender-div").show(); 537 $(".spouse-dob-div").show(); 538 } else { 539 $(".spouse-gender-div").hide(); 540 $(".spouse-dob-div").hide(); 541 } 542 }); 543 544 $('input#spouseToggleMobile').on('change', function () { 545 if ($(this).is(':checked')) { 546 $(".spouse-gender-div-mobile").show(); 547 $(".spouse-dob-div-mobile").show(); 548 } else { 549 $(".spouse-gender-div-mobile").hide(); 550 $(".spouse-dob-div-mobile").hide(); 551 } 552 }); 553 554 $("div#custom-popup .gender-card").on("click", function () { 555 $(this).parent().parent().find("div.gender-card").removeClass('gender-active'); 556 $(this).addClass('gender-active'); 557 $(this).find('input[type="radio"]').prop("checked", true); 558 }); 559 560 $(".gender-card.mobile").on("click", function () { 561 $(this).parent().parent().find("div.gender-card.mobile").removeClass('gender-active'); 562 $(this).addClass('gender-active'); 563 $(this).find('input[type="radio"]').prop("checked", true); 564 }); 565 566 // Child Toggle 567 $('input#childToggle').on('change', function () { 568 if ($(this).is(':checked')) { 569 $(".children-number").show(); 570 } else { 571 $(".children-number").hide(); 572 } 573 }); 574 575 $('input#childToggleMobile').on('change', function () { 576 if ($(this).is(':checked')) { 577 $(".children-number-mobile").show(); 578 } else { 579 $(".children-number-mobile").hide(); 580 } 581 }); 582 583 let shouldReset = true; // default reset for any close action 584 // Close Popup on Cancel button 585 $(document).on('click', '.custom-popup .custom-modal-body .popup-button button.help-btn', function () { 586 shouldReset = true; 587 $('#custom-popup').trigger('closeModal'); 588 $('input#familyToggle').prop('checked', false); 589 $("input#spouseToggle").prop('checked', false); 590 $("input#childToggle").prop('checked', false); 591 }); 592 593 let shouldResetMobile = true; // default reset for any close action 594 // Close mobile quotes rates on Cancel button 595 $(document).on('click', '.mobile_quote_rates .mobile-button button.help-btn', function () { 596 shouldResetMobile = true; 597 $('.mobile_quote_rates').hide(); 598 $('input#familyToggle').prop('checked', false); 599 $("input#spouseToggleMobile").prop('checked', false); 600 $("input#childToggleMobile").prop('checked', false); 601 $(".quote-section").show(); 602 }); 603 $(document).on('click', '.mobile_quote_rates .modal-header .back-svg', function () { 604 shouldResetMobile = true; 605 $('.mobile_quote_rates').hide(); 606 $('input#familyToggle').prop('checked', false); 607 $("input#spouseToggleMobile").prop('checked', false); 608 $("input#childToggleMobile").prop('checked', false); 609 $(".quote-section").show(); 610 }); 611 612 // Close Popup on Continue button 613 $(document).on('click', '.custom-popup .custom-modal-body .popup-button button.search-btn', function () { 614 shouldReset = true; 615 if ($("input#spouseToggle").is(':checked')) { 616 if (!$(".spouse-dob-div .input-field input.spouse-dob").val() && (!$("#custom-popup .gender-card input#male").is(":checked") || !$("#custom-popup .gender-card input#female").is(":checked"))) { 617 alert("Please add the spouse details."); 618 return false;
619 } else { 620 shouldReset = false; 621 } 622 } 623 if ($("input#childToggle").is(':checked')) { 624 if ($('.children-section label.child-option input:checked').length == 0) { 625 alert("Please select the number of children."); 626 return false; 627 } else { 628 shouldReset = false; 629 } 630 } 631 $('#custom-popup').trigger('closeModal'); 632 }); 633 634 $(document).on('click', '.mobile_quote_rates .mobile-button button.search-btn', function () { 635 if ($("input#spouseToggleMobile").is(':checked')) { 636 if (!$(".spouse-dob-div-mobile .input-field input.spouse-dob-mobile").val() && (!$(".mobile_quote_rates .gender-card.mobile input#male").is(":checked") || !$(".mobile_quote_rates .gender-card.mobile input#female").is(":checked"))) { 637 alert("Please add the spouse details."); 638 return false; 639 } 640 } 641 if ($("input#childToggleMobile").is(':checked')) { 642 if ($('.children-number-mobile label.child-option input:checked').length == 0) { 643 alert("Please select the number of children."); 644 return false; 645 } 646 } 647 shouldReset = false; 648 $('.mobile_quote_rates').hide(); 649 $(".quote-section").show(); 650 }); 651 652 // Popup Close Event 653 $('#custom-popup').on('modalclosed', function () { 654 console.log(shouldReset); 655 $('input#familyToggle').prop('checked', true); 656 if (shouldReset) { 657 $('input#familyToggle').prop('checked', false); 658 $("input#spouseToggle").prop('checked', false); 659 $("input#childToggle").prop('checked', false); 660 } 661 }); 662 // Email Validate 663 function isValidEmail(email) { 664 var regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; 665 return regex.test(email); 666 } 667 $('input#holdrate_phone').on('input', function () { 668 var input = $(this).val(); 669 // Remove all non-numeric characters 670 input = input.replace(/\D/g, ''); 671 672 // Format as 123-456-7890 673 if (input.length > 3 && input.length <= 6) { 674 input = input.slice(0, 3) + '-' + input.slice(3); 675 } else if (input.length > 6) { 676 input = input.slice(0, 3) + '-' + input.slice(3, 6) + '-' + input.slice(6, 10); 677 } 678 679 $(this).val(input); 680 }); 681 let quoteStartedFired = false; 682 function checkFields() { 683 // Field values 684 var zip = $('.quote_rates_form #quote_zipCode').val().trim(); 685 var dob = $('.quote_rates_form #quote_dob').val().trim(); 686 var gender = $('.quote_rates_form .gender-selection input[name="gender"]:checked').val(); 687 var holdrateName = $("#holdrate_firstname").val().trim(); 688 var holdrateEmail = $("#holdrate_email").val().trim(); 689 // Checkbox values 690 var privacyChecked = $("input[name='privacy_acknowledge']").is(':checked'); 691 var marketingChecked = $("input[name='marketing_consent']").is(':checked'); 692 // Body class check 693 var isRealAgentPerks = $('body').hasClass('realagentperks'); 694 // Fire quote_started when personal details are completed 695 if (zip !== '' && dob !== '' && gender !== undefined && !quoteStartedFired) { 696 dataLayer.push({ 697 event: "quote_started" 698 }); 699 700 quoteStartedFired = true; 701 console.log("quote_started"); 702 } 703 if (zip !== '' && dob !== '' && gender !== undefined) { 704 if (holdrateName == '' && holdrateEmail == '') { 705 $('.quote_rates_form .quote-btn').css({ 706 'background-color': '#4AB7FD', 707 'color': '#fff', 708 'cursor': 'pointer' 709 }); 710 } else if (isRealAgentPerks && privacyChecked && marketingChecked && holdrateName !== '' && holdrateEmail !== '') { 711 $('.quote_rates_form .quote-btn').css({ 712 'background-color': '#4AB7FD', 713 'color': '#fff', 714 'cursor': 'pointer' 715 }); 716 } else if (!isRealAgentPerks && marketingChecked && holdrateName !== '' && holdrateEmail !== '') { 717 $('.quote_rates_form .quote-btn').css({ 718 'background-color': '#4AB7FD', 719 'color': '#fff', 720 'cursor': 'pointer' 721 }); 722 } else { 723 $('.quote_rates_form .quote-btn').css({ 724 'background-color': '#e0e0e0', 725 'color': '#656565', 726 'cursor': 'not-allowed' 727 }); 728 } 729 } else { 730 $('.quote_rates_form .quote-btn').css({ 731 'background-color': '#e0e0e0', 732 'color': '#656565', 733 'cursor': 'not-allowed' 734 }); 735 } 736 } 737 // Run check on input change 738 $('.quote_rates_form #quote_zipCode, #quote_dob').on('keyup change', checkFields); 739 $('.quote_rates_form .gender-selection').on("click", checkFields); 740 if ($('body').hasClass('realagentperks')) { 741 $("input[name='privacy_acknowledge']").on("change", checkFields); 742 } 743 $("#holdrate_firstname").on("keyup change", checkFields); 744 $("#holdrate_email").on("keyup change", checkFields); 745 $("input[name='marketing_consent']").on("change", checkFields); 746 // Initial state check 747 checkFields(); 748 $(document).on("click", ".quote-section .quote_rates_form a.quote-btn", function () { 749 var isRealAgentPerks = $('body').hasClass('realagentperks'); 750 751 var holdrateName = $("#holdrate_firstname").val().trim(); 752 var holdrateEmail = $("#holdrate_email").val().trim(); 753 754 var privacyChecked = $("input[name='privacy_acknowledge']").is(':checked'); 755 var marketingChecked = $("input[name='marketing_consent']").is(':checked'); 756 757 // Run validation only when hold rate fields are filled 758 if (holdrateName !== "" && holdrateEmail !== "") { 759 760 // RealAgentPerks website 761 if (isRealAgentPerks && (!privacyChecked || !marketingChecked)) { 762 e.preventDefault(); 763 alert("Please accept the disclaimer to continue."); 764 return false;
765 } 766 767 // Other websites 768 if (!isRealAgentPerks && !marketingChecked) { 769 e.preventDefault(); 770 alert("Please accept the disclaimer to continue."); 771 return false; 772 } 773 } 774 775 if ($("input#quote_zipCode").val() && $("input#quote_dob").val() && ($("input.quote_male").is(":checked") || $("input.quote_female").is(":checked"))) { 776 var spouseDOB = ""; 777 var spouseGender = ""; 778 var childCount = 0; 779 var holdrateFullname = ""; 780 var holdratePhone = ""; 781 var holdrateEmailID = ""; 782 // family Toggle 783 if ($('input#familyToggle').is(':checked')) { 784 // Spouse Toggle 785 if ($("input#spouseToggle").is(':checked')) { 786 if ($(".spouse-dob-div .input-field input.spouse-dob").val() && ($("#custom-popup .gender-card input#male").is(":checked") || $("#custom-popup .gender-card input#female").is(":checked"))) { 787 var spouseDOB = $(".spouse-dob-div .input-field input.spouse-dob").val(); 788 var spouseGender = $("#custom-popup .gender-card input:checked").val(); 789 } else { 790 alert("Please add the spouse details."); 791 return false; 792 } 793 } 794 if ($("input#spouseToggleMobile").is(':checked')) { 795 if ($(".spouse-dob-div-mobile .input-field input.spouse-dob-mobile").val() && ($(".mobile_quote_rates .gender-card.mobile input#male").is(":checked") || $(".mobile_quote_rates .gender-card.mobile input#female").is(":checked"))) { 796 var spouseDOB = $(".spouse-dob-div-mobile .input-field input.spouse-dob-mobile").val(); 797 var spouseGender = $(".mobile_quote_rates .gender-card.mobile input:checked").val(); 798 } else { 799 alert("Please add the spouse details."); 800 return false; 801 } 802 } 803 // Child Toggle 804 if ($("input#childToggle").is(':checked')) { 805 if ($('.children-section label.child-option input:checked').length > 0) { 806 var childCount = $(".children-section label.child-option input:checked").val(); 807 } else { 808 alert("Please select the number of children."); 809 return false; 810 } 811 } 812 if ($("input#childToggleMobile").is(':checked')) { 813 if ($('.children-number-mobile label.child-option input:checked').length > 0) { 814 var childCount = $(".children-number-mobile label.child-option input:checked").val(); 815 } else { 816 alert("Please select the number of children."); 817 return false; 818 } 819 } 820 } 821 var name = $("#holdrate_firstname").val().trim(); 822 var email = $("#holdrate_email").val().trim(); 823 var phone = $("#holdrate_phone").val().trim(); 824 825 // If only email filled and name empty 826 if (email !== "" && name === "") { 827 alert("Please fill in Full Name when providing Email."); 828 return false; 829 } 830 831 // If only name filled and email empty 832 if (name !== "" && email === "") { 833 alert("Please fill in Email when providing Full Name."); 834 return false; 835 } 836 if ($("input#holdrate_email").val()) { 837 var holdrateEmailDiv = $("input#holdrate_email"); 838 var holdrateEmail = holdrateEmailDiv.val(); 839 if (!isValidEmail(holdrateEmail)) { 840 alert('Please enter a valid email address.'); 841 holdrateEmailDiv.addClass('is-invalid').focus(); 842 return false; 843 } else { 844 holdrateEmailDiv.removeClass('is-invalid'); 845 } 846 } 847 if (phone === "") { 848 phone = "Not Added"; 849 } 850 var userZipcode = $("input#quote_zipCode").val(); 851 var userDOB = $("input#quote_dob").val(); 852 var userGender = $(".quote-section .gender-card input:checked").val(); 853 console.log(userZipcode); 854 console.log(userDOB); 855 console.log(userGender); 856 console.log(spouseDOB); 857 console.log(spouseGender); 858 console.log(childCount); 859 console.log(holdrateFullname + holdrateEmailID + holdratePhone); 860 var turnstileResponse = $('input[name="cf-turnstile-response"]').val(); 861 // Ajax 862 $.ajax({ 863 url: urlBuilder.build('hbgrates/form/submit'), 864 type: 'POST', 865 dataType: 'json', 866 showLoader: true, 867 data: { 868 zipcode: userZipcode, 869 dob: userDOB, 870 gender: userGender, 871 childcount: childCount, 872 partnerGender: spouseGender, 873 partnerBirthDate: spouseDOB, 874 fullname: name, 875 email: email, 876 phone: phone, 877 turnstileResponse: turnstileResponse 878 }, 879 success: function (response) { 880 if (response.success) { 881 // Hide old quote section 882 dataLayer.push({ 883 event: "quote_generated" 884 }); 885 $(".quote_rates_form").hide(); 886 $("section.pricing-section").show(); 887 setTimeout(function () { 888 var pricingSection = document.querySelector("section.pricing-section"); 889 890 if (pricingSection) { 891 var rect = pricingSection.getBoundingClientRect(); 892 var scrollTop = window.pageYOffset || document.documentElement.scrollTop; 893 894 window.scrollTo({ 895 top: scrollTop + rect.top, 896 behavior: "smooth" 897 }); 898 } 899 }, 300); 900 $("section.pricing-section .plan3 h3").text("$" + parseFloat(response.data.genderPrice1).toLocaleStr
900ing('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })); 901 $("section.pricing-section .plan2 h2").text("$" + parseFloat(response.data.genderPrice2).toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })); 902 $("section.pricing-section .plan1 h3").text("$" + parseFloat(response.data.genderPrice3).toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })); 903 var count = "Member Only"; 904 if ($.cookie('spouse_coverage') == 'true' && $.cookie('child_count') !== "zero") { 905 count = "Member + Family"; 906 } 907 if ($.cookie('spouse_coverage') == 'true' && $.cookie('child_count') == "zero") { 908 count = "Member + Spouse"; 909 } 910 if ($.cookie('spouse_coverage') == 'false' && $.cookie('child_count') !== "zero") { 911 count = "Member + Child(ren)"; 912 } 913 $(".quote-section p.family_count").text(count); 914 $(".quote_form_field").hide(); 915 $("section.quote-section").removeClass("bg-purple-light"); 916 $("section.quote-section").removeClass("py-5"); 917 $("section.quote-section").addClass("py-0"); 918 $.cookie('product_rank', $(".quote-plans.selected div input#quote_rate_plan").val(), { expires: 7, path: '/' }); 919 var quoteName = $.cookie('quoterates_name'); 920 var quoteEmail = $.cookie('quoterates_email'); 921 922 if (quoteName && quoteName.trim() !== '' && quoteEmail && quoteEmail.trim() !== '') { 923 // Hide the section if both cookies exist and are not blank 924 $('section.pricing-section .saved-price').hide(); 925 $('section.pricing-section .emailmessage').remove(); 926 $('section.pricing-section .saved-price').after('<div class="emailmessage" style="margin-top: 20px;font-size: 30px;color: rgba(var(--bs-primary-rgb)) !important;font-weight: 700;">An email has been sent to ' + quoteEmail + ' with your saved pricing. Click the "Continue" button above to proceed to the health questions.</div>'); 927 $(".emailshare").hide(); 928 } else { 929 $('section.pricing-section .saved-price').show(); 930 $('section.pricing-section .emailmessage').remove(); 931 $(".emailshare").show(); 932 } 933 console.log($("input.impact_orderId").val() + $("input.impact_customProfileId").val() + $("input.impact_customerId").val() + $("input.impact_customerEmail").val()); 934 ire('trackConversion', 61300, { 935 orderId: $("input.impact_orderId").val(), 936 customProfileId: $("input.impact_customProfileId").val(), 937 customerId: $("input.impact_customerId").val(), 938 customerEmail: $("input.impact_customerEmail").val(), 939 currencyCode: "USD", 940 orderPromoCode: "", 941 items: [ 942 { 943 subTotal: parseFloat(response.data.genderPrice1), 944 category: "Default Category", 945 sku: "VAULT Captive V2500", 946 quantity: 1, 947 name: "VAULT Captive V2500" 948 }, 949 { 950 subTotal: parseFloat(response.data.genderPrice2), 951 category: "Default Category", 952 sku: "VAULT Captive V5000", 953 quantity: 1, 954 name: "VAULT Captive V5000" 955 }, 956 { 957 subTotal: parseFloat(response.data.genderPrice3), 958 category: "Default Category", 959 sku: "VAULT Captive V10000", 960 quantity: 1, 961 name: "VAULT Captive V10000" 962 } 963 ] 964 }, 965 { 966 verifySiteDefinitionMatch: true 967 } 968 ); 969 } else { 970 alert(response.data); 971 } 972 }, 973 error: function (xhr, status, error) { 974 alert(error); 975 } 976 }); 977 } else { 978 alert('Please enter your Location, Date of Birth, and Gender details first.'); 979 return false;
980 } 981 }); 982 983 //Select Quote Rates 984 $('section.pricing-section .quote-plans.selected input[type="radio"]').prop('checked', true); 985 // Select Quote Rates Button Click 986 $(document).on("click", "section.pricing-section .quote-plans button", function () { 987 $(this).closest("div.quote-plans").parent().find("div.quote-plans").removeClass("selected"); 988 $(this).closest("div.quote-plans").parent().find("div.quote-plans").addClass("unselected"); 989 $(this).closest("div.quote-plans").parent().find("div.quote-plans button").text("Select"); 990 $(this).closest("div.quote-plans").removeClass("unselected"); 991 $(this).closest("div.quote-plans").addClass("selected"); 992 $(this).closest("div.quote-plans").find('input[type="radio"]').prop('checked', true); 993 $(this).text("Deselect"); 994 $.cookie('product_rank', $(this).parent().find("input#quote_rate_plan").val(), { expires: 7, path: '/' }); 995 }); 996 // Select Quote Rates Section Click 997 $(document).on("click", "section.pricing-section .quote-plans", function () { 998 $(this).parent().find("div.quote-plans").removeClass("selected"); 999 $(this).parent().find("div.quote-plans").addClass("unselected"); 1000 $(this).parent().find("div.quote-plans button").text("Select"); 1001 $(this).removeClass("unselected"); 1002 $(this).addClass("selected"); 1003 $(this).find('input[type="radio"]').prop('checked', true); 1004 $(this).find("button").text("Deselect"); 1005 $.cookie('product_rank', $(this).find("input#quote_rate_plan").val(), { expires: 7, path: '/' }); 1006 }); 1007 // Recalculate 1008 $(document).on("click", "button.recalculate-btn", function () { 1009 $("section.pricing-section").hide(); 1010 $(".quote_rates_form").show(); 1011 $(".quote_rates_form input#familyToggle").prop('checked', false); 1012 $("input#spouseToggle").prop('checked', false); 1013 $("input#childToggle").prop('checked', false); 1014 $("input#spouseToggleMobile").prop('checked', false); 1015 $("input#spouseToggleMobile").prop('checked', false); 1016 $(".quote_form_field").show(); 1017 $("section.quote-section").addClass("bg-purple-light"); 1018 $("section.quote-section").removeClass("py-0"); 1019 $("section.quote-section").addClass("py-5"); 1020 }); 1021 1022 // Send Quote Rates Email 1023 $(document).on("click", "button.quote_rates_send", function (e) { 1024 e.preventDefault(); // stop form submit if inside a form 1025 var emailField = $('input.form-control.quote_rates_email'); 1026 var email = emailField.val(); 1027 1028 if (!isValidEmail(email)) { 1029 alert('Please enter a valid email address.'); 1030 emailField.addClass('is-invalid').focus(); 1031 return false; 1032 } else { 1033 emailField.removeClass('is-invalid'); 1034 } 1035 1036 $.ajax({ 1037 url: urlBuilder.build('hbgrates/form/quoteratessubmit'), 1038 type: "POST", 1039 dataType: "json", 1040 showLoader: true, 1041 data: { 1042 email: $("input.form-control.quote_rates_email").val(), 1043 rates: $.cookie('productrates') 1044 }, 1045 success: function (response) { 1046 if (response.success) { 1047 $(".emailmessage").remove(); 1048 $("button.quote_rates_send").parent().parent().after('<div class="emailmessage" style="margin-top: 20px;font-size: 30px;color: rgba(var(--bs-primary-rgb)) !important;font-weight: 700;">' + response.message + '</div>'); 1049 $.cookie('quoterates_email', $("input.form-control.quote_rates_email").val(), { expires: 7, path: '/' }); 1050 $("input.form-control.quote_rates_email").val(''); 1051 $(".emailshare").hide(); 1052 } else { 1053 $(".emailmessage").remove(); 1054 $("button.quote_rates_send").parent().parent().after('<div class="emailmessage" style="margin-top: 20px;font-size: 30px;color: rgba(var(--bs-primary-rgb)) !important;font-weight: 700;">' + response.message + '</div>'); 1055 $(".emailshare").show(); 1056 } 1057 }, 1058 error: function (xhr, status, error) { 1059 alert(error); 1060 } 1061 }); 1062 }); 1063 1064 $(document).on("click", "section.pricing-section a.continue-btn", function (e) { 1065 e.preventDefault(); 1066 1067 var url = $(this).attr('href'); 1068 var planName = $('section.pricing-section .quote-plans.selected .responsive-price-card .w-100 .card-responsive:nth-child(2) h4.deductible').text().replace('$', '').trim(); 1069 var planPrice = $('section.pricing-section .quote-plans.selected .responsive-price-card .w-100 .card-responsive:first-child h2.price').text(); 1070 1071 dataLayer.push({ 1072 event: 'plan_selected', 1073 plan_name: "V" + planName, // Replace with your variable 1074 plan_price: planPrice // Replace with your variable 1075 }); 1076 1077 setTimeout(function () { 1078 window.location.href = url; 1079 }, 200); 1080 }); 1081 // Remove Moblie Quote Rates in Desktop 1082 if ($(window).width() >= 768) { 1083 $(".mobile_quote_rates").remove(); 1084 } 1085 1086 }); 1087});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.