const isTestQuote = true; const companyLogoURLs = {'AMGE': 'https://www.compulifeapi.com/images/logosapi/AMGE-small.png', 'ASSU': 'https://www.compulifeapi.com/images/logosapi/ASSU-small.png', 'BANN': 'https://www.compulifeapi.com/images/logosapi/BANN-small.png', 'BETT': 'https://www.compulifeapi.com/images/logosapi/BETT-small.png', 'JOHU': 'https://www.compulifeapi.com/images/logosapi/JOHU-small.png', 'JOHY': 'https://www.compulifeapi.com/images/logosapi/JOHY-small.png', 'LNNA': 'https://www.compulifeapi.com/images/logosapi/LNNA-small.png', 'MASM': 'https://www.compulifeapi.com/images/logosapi/MASM-small.png', 'MINM': 'https://www.compulifeapi.com/images/logosapi/MINM-small.png', 'NATW': 'https://www.compulifeapi.com/images/logosapi/NATW-small.png', 'NATY': 'https://www.compulifeapi.com/images/logosapi/NATY-small.png', 'NORA': 'https://www.compulifeapi.com/images/logosapi/NORA-small.png', 'PACL': 'https://www.compulifeapi.com/images/logosapi/PACL-small.png', 'PRIN': 'https://www.compulifeapi.com/images/logosapi/PRIN-small.png', 'PRIP': 'https://www.compulifeapi.com/images/logosapi/PRIP-small.png', 'PROA': 'https://www.compulifeapi.com/images/logosapi/PROA-small.png', 'PROT': 'https://www.compulifeapi.com/images/logosapi/PROT-small.png', 'PRUC': 'https://www.compulifeapi.com/images/logosapi/PRUC-small.png', 'PRUJ': 'https://www.compulifeapi.com/images/logosapi/PRUJ-small.png', 'SYME': 'https://www.compulifeapi.com/images/logosapi/SYME-small.png', 'TRAN': 'https://www.compulifeapi.com/images/logosapi/TRAN-small.png', 'UTOM': 'https://www.compulifeapi.com/images/logosapi/UTOM-small.png', 'UTST': 'https://www.compulifeapi.com/images/logosapi/UTST-small.png', 'WILP': 'https://www.compulifeapi.com/images/logosapi/WILP-small.png'} const productAliases = { "OPTerm": "OPTerm", "Classic Choice": "Classic Choice" }; document.querySelectorAll('.gender-button').forEach(button => { button.addEventListener('click', function () { document.querySelectorAll('.gender-button').forEach(btn => btn.classList.remove('active')); this.classList.add('active'); }); }); // This function is responsible for dynamically generating and inserting quote rows function displayQuotes(lookup, quotes) { const quoteOptionsBody = document.getElementById("quoteOptionsBody"); quoteOptionsBody.classList.remove('hidden'); const lookup_row = `
`; if (quotes.length <= 1) { quoteOptionsBody.innerHTML = `
${lookup_row}

No quotes found for your selected priorities.

Talk to an agent
`; transitionToResults(); return; } quoteOptionsBody.innerHTML = `
${lookup_row}

Select the plan below that most interests you

The costs listed are estimates of your monthly premium payments based on the information you've provided to this point.
A real rate will be provided upon carrier approval.

`; document.getElementById("termLengthLookup").value = `${document.getElementById('termLength').value}`; document.getElementById("faceAmountLookup").value = `${document.getElementById('faceAmount').value}`; let rerunQuoteButton = document.getElementById("rerunQuoteButton"); let quoteLoadAnimation = document.getElementById("quoteLoadAnimation"); rerunQuoteButton.addEventListener('click', function () { document.getElementById('termLength').value = document.getElementById('termLengthLookup').value; document.getElementById('faceAmount').value = document.getElementById('faceAmountLookup').value; returnToPreviousQuestion(questionSequence.indexOf('quoteOptions')); //quoteOptionsBody.classList.add("hidden"); //quoteLoadAnimation.classList.remove("hidden"); //quoteLoadAnimation.classList.remove('fade'); runQuote(); //displayQuotes(lookup, quotes); }); const quoteCardGallery = document.getElementById("quoteCardGallery"); // Create a feature label card const featureLabelContainer = document.createElement("div"); featureLabelContainer.classList.add("sticky", "left-0", "z-10"); const featureLabelCard = document.createElement("div"); featureLabelCard.classList.add("quote-card", "min-w-24", "mt-2"); featureLabelContainer.appendChild(featureLabelCard); const priorityList = document.getElementById('priorityList'); let selectedPriorities = Array.from(priorityList.querySelectorAll('.priority-button.selected')).map(button => button.textContent.trim()); const defaultPriorities = ["Payments pause if you become disabled", "Additional coverage for children", "Return of premium if you outlive your policy"]; while (selectedPriorities.length < 3) { const defaultPriority = defaultPriorities.find(priority => !selectedPriorities.includes(priority)); if (defaultPriority) { selectedPriorities.push(defaultPriority); } else { break; } } const featureLabels = ["Cost", ...selectedPriorities.map(priority => priorityToRider[priority].tag)]; featureLabelCard.innerHTML = `
Company
${featureLabels.map((label, index) => `
${label}
`).join('')}
`; const features = ["Cost", ...selectedPriorities.map(priority => priorityToRider[priority].tag)]; const rows = []; const addedCompprodcodes = new Set(); quotes.forEach((quote, index) => { if (addedCompprodcodes.has(quote.Compulife_product.trim())) { return; // Skip this quote if its compprodcode is already added } addedCompprodcodes.add(quote.Compulife_product.trim()); const trimmedProductName = quote.Compulife_product.trim(); let productName = trimmedProductName; for (const [keyword, alias] of Object.entries(productAliases)) { if (trimmedProductName.includes(keyword)) { productName = alias; break; } } const compCode = quote.Compulife_compprodcode.substring(0, 4); const logoURL = companyLogoURLs[compCode]; const cost = `$${quote.Compulife_premiumM}/mo`; const healthCategory = quote.Compulife_healthcat; const companyName = quote.Compulife_company; // Create singleQuoteCard for each quote const singleQuoteCard = document.createElement("div"); singleQuoteCard.classList.add("quote-card", "min-w-32", "mt-2", "bg-white", "shadow-lg", "border-gray-200", "border-2", "flex", "flex-col", "rounded-3xl"); if (index === 0) { quoteCardGallery.appendChild(featureLabelContainer); } if (index >= 3) { singleQuoteCard.classList.add("hidden"); } const availableRiders = compprodcodeToRiders[quote.Compulife_compprodcode] || []; singleQuoteCard.innerHTML = `
${companyName} logo
${cost}
${selectedPriorities.map(priority => `
${availableRiders.includes(priorityToRider[priority].tag) ? ` ` : ` ` }
`).join('')}
`; quoteCardGallery.appendChild(singleQuoteCard); }); // Add event listener to "Apply now" buttons document.querySelectorAll('#quoteCardGallery .form-button').forEach(button => { button.addEventListener('click', function () { const quoteOptions = document.getElementById('quoteOptions'); const applyPanelSubtext = document.getElementById('applyPanelSubtext'); quoteOptions.classList.add('fade'); const url = "https://dynamique.tfaforms.net/127?tfa_3473=tfa_3474&tfa_3795=" + button.getAttribute('data-compprodcode'); const appFrame = document.getElementById('appFrame'); if (appFrame.src !== url) { appFrame.src = url; } applyPanelSubtext.textContent = "Initiate your application by providing some additional information. Our experts will review your submission, discuss your selected plan with you, and submit it to the insurance carrier."; setTimeout(() => { quoteOptions.classList.add('hidden'); showNextDiv(questionSequence.indexOf('quoteOptions') + 1); }, 500); }); }); transitionToResults(); } function transitionToResults() { //after 1 second, show the first 2 quotes const loadAnimation = document.getElementById('quoteLoadAnimation'); setTimeout(() => { loadAnimation.classList.add('fade'); setTimeout(() => { loadAnimation.classList.add('hidden'); showNextDiv(questionSequence.indexOf('quoteOptions')); connectTooltipIcons(); }, 500); }, 1000); } function goBackToQuestions() { const quoteOptions = document.getElementById('quoteOptions'); quoteOptions.classList.add('fade'); setTimeout(() => { quoteOptions.classList.add('hidden'); const quoteLoadAnimation = document.getElementById('quoteLoadAnimation'); quoteLoadAnimation.classList.remove('fade'); showPreviousDiv(questionSequence.indexOf('quoteLoadAnimation')); }, 500); } function returnToQuoteFromApp() { const appDiv = document.getElementById('appDiv'); appDiv.classList.add('fade'); setTimeout(() => { appDiv.classList.add('hidden'); showPreviousDiv(questionSequence.indexOf('appDiv')); }, 500); } function validateQuoteForm() { if (isTestQuote === false) { const genderSelected = document.querySelector('.gender-button.active'); const birthday = document.getElementById('birthday').value; const state = document.getElementById('state').value; if (!genderSelected || !birthday || !state) { alert('Please fill in all required fields: gender, date of birth, and state.'); return false; } } return true; } function validateContactInput() { if (isTestQuote === false) { const email = document.getElementById('email').value; const phone = document.getElementById('phone').value; if (!email) { alert('Please fill in your email.'); return false; } } submitContactInfo(); return true; } function validateAndSubmitContactPanelInput() { const name = document.getElementById('contactPanelName').value; const email = document.getElementById('contactPanelEmail').value; submitContactPanelInfo(name, email); return true; } function onApplyPanelStartButtonClick() { advanceToQuestion(questionSequence.indexOf('nextStepsDiv'), 'appDiv'); const url = "https://dynamique.tfaforms.net/127?tfa_5666=tfa_5667&tfa_7299=tfa_7300&tfa_7301=tfa_7302&tfa_7305=tfa_7306&tfa_7311=tfa_7312&tfa_7313=tfa_7314&tfa_7316=tfa_7317&tfa_7320=tfa_7321&tfa_7322=tfa_7323&tfa_7325=tfa_7326&tfa_7400=tfa_7401&tfa_7331=tfa_7332"; const appFrame = document.getElementById('appFrame'); if (appFrame.src !== url) { appFrame.src = url; } } function submitContactPanelInfo(name, email) { // Collect form data const data = {"name": name, "email": email}; const apiEndpoint = '/api/submitContactPanelInfo'; fetch(apiEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { if (data.status === "success") { const contactPanelSubmitButton = document.getElementById('contactPanelSubmitButton'); contactPanelSubmitButton.textContent = "Thanks!"; contactPanelSubmitButton.classList.add('disabled'); } }) .catch((error) => { console.error('Error:', error); }); }; function validateHeightWeightInput() { if (isTestQuote === false) { const heightFeet = document.getElementById('heightFeet').value; const heightInches = document.getElementById('heightInches').value; const weight = document.getElementById('weight').value; if (!heightFeet || !heightInches || !weight) { alert('Please fill in all required fields: height and weight.'); return false; } } return true; } function advanceToNextQuestion(currentDivIndex) { const currentDiv = document.getElementById(questionSequence[currentDivIndex]); currentDiv.classList.add('fade'); setTimeout(() => { currentDiv.classList.add('hidden'); showNextDiv(currentDivIndex + 1); }, 500); } function advanceToQuestion(currentDivIndex, divToShowId) { const currentDiv = document.getElementById(questionSequence[currentDivIndex]); currentDiv.classList.add('fade'); setTimeout(() => { currentDiv.classList.add('hidden'); showDiv(divToShowId); }, 500); } function returnToPreviousQuestion(currentDivIndex) { const currentDiv = document.getElementById(questionSequence[currentDivIndex]); currentDiv.classList.add('fade'); setTimeout(() => { currentDiv.classList.add('hidden'); showPreviousDiv(currentDivIndex); }, 500); } const divHeaders = { "quoteForm": { title: "Need Life Insurance?", subtext: "Let's start with some basic questions to estimate your cost" }, "quoteParamForm": { title: "Define Your Coverage", subtext: "How much coverage do you need and for how long?" }, "priorityForm": { title: "What matters most to you?", subtext: "Select up to 3 policy add-ons that best suit your needs" }, "impairmentForm": { title: "Medical conditions", subtext: "Please select all that apply to you." }, "contactInfoQuestion": { title: "Contact Information", subtext: "Please provide your contact details" }, "quoteLoadAnimation": { title: "Finding your product matches", subtext: "Please wait while we find the best options for you" }, "quoteOptions": { title: "Your Quote Options", subtext: `Here are the best matches based on your preferences` }, "heightWeightQuestion": { title: "Let's make sure you qualify", subtext: "This information will help us determine your eligibility" }, "tobaccoQuestion": { title: "Let's make sure you qualify", subtext: "Check each tobacco product that you have EVER smoked or used" }, "tobaccoForm": { title: "Let's make sure you qualify", subtext: "Select each tobacco product you have used in the last 5 years" }, "smokerQuestion": { title: "Smoking", subtext: "Are you or have you been a smoker in the last 5 years?", }, "appDiv": { title: "Apply Now", subtext: "Complete your application to get started" }, "fitToTypeForm": { title: "", subtext: "Which life scenario fits you best?" }, "relationshipForm": { title: "", subtext: "What's your relationship status?" }, "dependentsForm": { title: "", subtext: "Do you have any children under 18 or other dependents?" }, "fitToNeedsForm": { title: "", subtext: "What are your needs for life insurance?" }, "termBestBlurb": { title:"", subtext:"It looks like term life insurance is going to be best for you" }, "gulBlurb": { title:"", subtext:"It looks like Guaranteed Universal Life (GUL) insurance is the best option for you." }, "nextStepsDiv": { title: "", subtext: "What would you like to do next?" }, "termSliderScreen":{ title:"", subtext:"How long would you like your coverage to last?" }, "faceAmountSliderScreen":{ title:"", subtext:"How much coverage will you need?" } }; //const questionSequence = ["quoteForm", "relationshipForm", "dependentsForm", "fitToNeedsForm", "termBestBlurb","termSliderScreen", "faceAmountSliderScreen", "priorityForm", "heightWeightQuestion", "tobaccoForm", "contactInfoQuestion", "quoteLoadAnimation", "quoteOptions", "appDiv"]; const questionSequence = ["quoteForm", "heightWeightQuestion", /*"tobaccoForm",*/ "smokerQuestion", "termSliderScreen", "faceAmountSliderScreen", "termBestBlurb", /*"gulBlurb",*/ "priorityForm", "quoteLoadAnimation", "quoteOptions", "nextStepsDiv", "appDiv"]; const questionConditions = {'termBestBlurb': termBlurbConditional, 'gulBlurb': gulBlurbConditional}; //const questionSequence = ["quoteForm", "tobaccoForm"] function termBlurbConditional() { return document.getElementById('termLength').value !== 'GUL'; } function gulBlurbConditional() { return document.getElementById('termLength').value === 'GUL'; } const validationMap = { "quoteForm": validateQuoteForm, "contactInfoQuestion": validateContactInput, "heightWeightQuestion": validateHeightWeightInput, "tobaccoForm": validateTobaccoQuestion }; const questionConditionalMap = { "dependentsForm": filterDependentsOptions }; function filterDependentsOptions() { console.log("Filtering dependents options"); } // Add event listener to all back buttons document.querySelectorAll('.back-button').forEach(button => { button.addEventListener('click', function() { const parentWithId = this.closest('.fade-div[id]'); const currentQuestionId = parentWithId ? parentWithId.id : null; const currentIndex = questionSequence.indexOf(currentQuestionId); console.log(currentIndex); returnToPreviousQuestion(currentIndex); scrollToGetMyQuote(); }); }); // Add event listener to all next buttons document.querySelectorAll('.next-button').forEach(button => { button.addEventListener('click', function() { const parentWithId = button.closest('.fade-div[id]'); const currentQuestionId = parentWithId ? parentWithId.id : null; onNextButtonClick(currentQuestionId); }); }); function onNextButtonClick(currentQuestionId) { const currentIndex = questionSequence.indexOf(currentQuestionId); // If the current question has a validation function, run it. If the validation function returns false, don't advance to the next question. Otherwise, advance to the next question. if (validationMap[currentQuestionId]) { let isValid = validationMap[currentQuestionId](); if (isValid) { advanceToNextQuestion(currentIndex); scrollToGetMyQuote(); } } else { advanceToNextQuestion(currentIndex); scrollToGetMyQuote(); } } function showDiv(divId){ if (questionConditions[divId]) { if (!questionConditions[divId]()) { return; } } const divToShow = document.getElementById(divId); if (divId === "quoteLoadAnimation") { const loadAnimation = document.getElementById('quoteLoadAnimation'); loadAnimation.classList.remove('hidden'); loadAnimation.classList.remove('fade'); runQuote(); } else { divToShow.classList.remove('fade'); divToShow.classList.remove('hidden'); } // Update header and subtext const headerText = document.getElementById('headerText'); const subText = document.getElementById('subText'); headerText.textContent = divHeaders[divId].title; if (typeof divHeaders[divId].subtext === 'function') { const faceAmount = document.getElementById('faceAmount').value; // Replace with actual value if dynamic const termLength = document.getElementById('termLength').value; // Replace with actual value if dynamic subText.textContent = divHeaders[divId].subtext(faceAmount, termLength); } else { subText.textContent = divHeaders[divId].subtext; } } function showNextDiv(currentIndex) { if (currentIndex < questionSequence.length) { const currentDivId = questionSequence[currentIndex]; if (questionConditions[currentDivId]) { if (!questionConditions[currentDivId]()) { showNextDiv(currentIndex + 1); return; } } showDiv(currentDivId) } } function showPreviousDiv(currentIndex) { if (currentIndex > 0) { const currentDivId = questionSequence[currentIndex]; const previousDivId = questionSequence[currentIndex - 1]; const currentDiv = document.getElementById(currentDivId); const previousDiv = document.getElementById(previousDivId); previousDiv.classList.remove('fade'); previousDiv.classList.remove('hidden'); // Update header and subtext const headerText = document.getElementById('headerText'); const subText = document.getElementById('subText'); headerText.textContent = divHeaders[previousDivId].title; if (typeof divHeaders[previousDivId].subtext === 'function') { const faceAmount = document.getElementById('faceAmount').value; // Replace with actual value if dynamic const termLength = document.getElementById('termLength').value; // Replace with actual value if dynamic subText.textContent = divHeaders[currentDivId].subtext(faceAmount, termLength); } else { subText.textContent = divHeaders[previousDivId].subtext; } } } document.querySelectorAll('.quote-run-button').forEach(button => { button.addEventListener('click', function () { const fadeDiv = button.closest('.fade-div'); if (fadeDiv) { fadeDiv.classList.add('hidden'); } document.getElementById('backButton').classList.add('hidden'); runQuote(); }); }); function getFormInputAsObject() { const gender = document.querySelector('input[name="gender"]:checked')?.value === 'Male' ? 'M' : 'F'; const birthdayInput = document.getElementById('birthday').value; const [year, month, day] = birthdayInput.split('-'); const birthday = `${month}/${day}/${year}`; const state = document.getElementById('state').value; //const selectedTobaccoButton = document.querySelector('.tobacco-button.selected'); const selectedSmokerButton = document.querySelector('.smoker-button.selected'); const smoker = selectedSmokerButton && selectedSmokerButton.textContent.trim() === 'Yes' ? 'Y' : 'N'; //const tobacco = selectedTobaccoButton && selectedTobaccoButton.textContent.trim() === 'None' ? 'N' : 'Y'; //const tobacco = 'Y'; const weightInput = parseInt(document.getElementById('weight').value, 10); const weight = weightInput ? weightInput : null; const heightFeet = parseInt(document.getElementById('heightFeet').value, 10); const heightInches = parseInt(document.getElementById('heightInches').value, 10); const state_map = { "AL": "1", "AK": "2", "AZ": "3", "AR": "4", "CA": "5", "CO": "6", "CT": "7", "DE": "8", "DC": "9", "FL": "10", "GA": "11", "HI": "12", "ID": "13", "IL": "14", "IN": "15", "IA": "16", "KS": "17", "KY": "18", "LA": "19", "ME": "20", "MD": "21", "MA": "22", "MI": "23", "MN": "24", "MS": "25", "MO": "26", "MT": "27", "NE": "28", "NV": "29", "NH": "30", "NJ": "31", "NM": "32", "NYB": "33", // NY Business "NYNB": "52", // NY Non-Business "NC": "34", "ND": "35", "OH": "36", "OK": "37", "OR": "38", "PA": "39", "RI": "40", "SC": "41", "SD": "42", "TN": "43", "TX": "44", "UT": "45", "VT": "46", "VA": "47", "WA": "48", "WV": "49", "WI": "50", "WY": "51", "GU": "53", "PR": "54", "VI": "55", "AS": "56" }; const selectedState = document.getElementById('state').value; const stateCode = state_map[selectedState]; const termLength = document.getElementById('termLength').value; const faceAmount = document.getElementById('faceAmount').value; const isGUL = document.getElementById('termLength').value === 'GUL'; const isDevQuote = false; return [ { "key": "isDevQuote", "value": isDevQuote }, { "key": "faceAmount", "value": `${faceAmount}` // Face amount }, { "key": "productType", "value": isGUL ? "GUL" : "term" }, { "key": "termLength", "value": `${termLength}` // Term length }, { "key": "coverToAge", "value": "100" }, { "key": "state", "value": `${stateCode}` // State code }, { "key": "sex", "value": gender }, { "key": "dateOfBirth", "value": birthday ? birthday : "01/01/1980" }, { "key": "smoker", "value": smoker }, { "key": "weight", "value": weight ? weight : 150 }, { "key": "heightFeet", "value": heightFeet ? heightFeet : 5 }, { "key": "heightInches", "value": heightInches ? heightInches : 8 }, ]; } function runQuote(){ // Collect form data const data = getFormInputAsObject(); const apiEndpoint = isTestQuote ? '/api/initiatePlaceholderQuote' : '/api/initiateQuote'; fetch(apiEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { // Determine if Compulife_ComparisonResults is an array or a single object let quotes = []; if (Array.isArray(data.Compulife_ComparisonResults)) { // If it's an array, get the first element's Compulife_Results quotes = data.Compulife_ComparisonResults[0].Compulife_Results; } else if (data.Compulife_ComparisonResults && data.Compulife_ComparisonResults.Compulife_Results) { // If it's a single object, get the Compulife_Results directly quotes = data.Compulife_ComparisonResults.Compulife_Results; } quotes = quotes.filter(quote => quote.HealthAnalysisResult === 'go'); displayQuotes(data.Lookup, quotes); // Call the function to display the quotes }) .catch((error) => { console.error('Error:', error); }); }; function getContactInfoFormInputAsObject(){ const firstName = document.getElementById('firstName').value || ""; const lastName = document.getElementById('lastName').value || ""; const email = document.getElementById('email').value || ""; const phone = document.getElementById('phone').value || ""; return { "firstname": firstName, "lastname": lastName, "email": email, "phone": phone }; } function submitContactInfo(){ // Collect form data const data = getContactInfoFormInputAsObject(); const apiEndpoint = '/api/submitContactInfo'; fetch(apiEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch((error) => { console.error('Error:', error); }); }; function submitContactPanelInfo(){ // Collect form data const data = {'name': document.getElementById('contactPanelName').value, 'email': document.getElementById('contactPanelEmail').value}; const apiEndpoint = '/api/submitContactPanelInfo'; fetch(apiEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch((error) => { console.error('Error:', error); }); }; function connectTooltipIcons() { document.querySelectorAll('.tooltip i').forEach(icon => { icon.addEventListener('click', function () { const tooltipText = this.nextElementSibling; tooltipText.classList.toggle('hidden'); }); }); } const compprodcodeToRiders = { // Banner OPTerm "BANNBONN": ["WP", "ABR"], "BANNBANN": ["WP", "ABR"], "BANNBONS": ["WP", "ABR"], "BANNBANS": ["WP", "ABR"], // Protective Classic Choice Term "PROTPROP": ["WP", "LTC/CI"], "PROAPRAT": ["WP", "LTC/CI"], "PROAPRAP": ["WP", "LTC/CI"], "PROAPROT": ["WP", "LTC/CI"], "PROTPROT": ["WP", "LTC/CI"], "PROTPROP": ["WP", "LTC/CI"], "PROTPRET": ["WP", "LTC/CI"], "PROPPREP": ["WP", "LTC"], "PRIPPNGP": ["WP", "ADB"], // Assurity Term "ASSUASRU": ["ROP", "WP"], "ASSUASRP": ["ROP", "WP"], // American General (Corebridge) "AMGEATRG": ["WP"], "AMGEATRH": ["WP"], "AMGEALRH": ["WP"], "AMGEALRG": ["WP"], // John Hancock "JOHUJTAU": ["Vitality"], "JOHUJTAP": ["Vitality"], "JOHUJTBU": ["Vitality"], "JOHUJTBP": ["Vitality"], "JOHUJTCU": ["Vitality"], "JOHUJTCP": ["Vitality"], "JOHUJTDU": ["Vitality"], "JOHUJTDP": ["Vitality"] }; const priorityToRider = { "Payments pause if you become disabled": { tag: "WP", riders: ["WP"] }, //"Guaranteed lifelong coverage": { tag: "GUL", riders: ["GUL", "Conversion"] }, //"Extra protection for accidental death": { tag: "ADB", riders: ["ADB"] }, "Additional coverage for children": { tag: "Child", riders: ["Child Rider"] }, "Income in case of long-term needs or chronic illness": { tag: "LTC/CI", riders: ["LTC/CI"] }, "Rewards for healthy living and lifestyle": { tag: "Vitality", riders: ["Vitality"] }, "Return of premium if you outlive your policy": { tag: "ROP", riders: ["ROP"] }, "Receive benefits if you are faced with terminal or chronic conditions": { tag: "ABR", riders: ["ABR"] }, }; const riderTooltipMap = { "Cost": "Policy monthly rate, annual rates available at a total lower cost, some plans offer other payment terms", "WP": "Waiver of premium, allows you to stop paying life insurance premiums if you become disabled.", //"GUL": "Guaranteed Universal Life policy is somewhere in between term and whole life insurance, though the cash value is limited, but can be cost-effective while offering life-long coverage (up to age 121) as long as premiums are paid on time.", "Child": "Provides a small benefit to cover burial expenses for a child.", "LTC/CI": "Long-term care or chronic illness riders provide a benefit if you need help with activities of daily living, such as bathing, dressing, and eating.", "Vitality": "Rewards you for healthy lifestyle choices, such as not smoking, staying active, and eating well.", "ADB": "Accidental death benefit, pays a lump sum if you die in an accident.", "ROP": "Return of premium, if you outlive your policy, you get back some or all of your premiums paid.", "ABR": "Accelerated death benefit, allows you to receive a lump sum if you are diagnosed with a terminal or chronic condition." }; function setupJourneyButtons(){ }; const priorityList = document.getElementById('priorityList'); priorityList.innerHTML = `
${Object.keys(priorityToRider).map(priority => `
`).join('')}
`; priorityList.querySelectorAll('.priority-button').forEach(button => { button.addEventListener('click', function () { const selectedButtons = priorityList.querySelectorAll('.priority-button.selected'); if (this.classList.contains('selected')) { this.classList.remove('selected'); this.classList.remove('text-[#fbeff1]'); this.classList.add('text-primary'); this.classList.remove('bg-[#5b3d4f]'); this.classList.add('bg-white'); } else if (selectedButtons.length < 3) { this.classList.add('selected'); this.classList.add('text-[#fbeff1]'); this.classList.remove('text-primary'); this.classList.remove('bg-white'); this.classList.add('bg-[#5b3d4f]'); } else { alert('You can only select up to 3 priorities. Click or tap a selected priority to remove it.'); } }); }); const smokerQuestion = document.getElementById('smokerQuestion'); smokerQuestion.querySelectorAll('.smoker-button').forEach(button => { button.addEventListener('click', function () { const selectedButtons = smokerQuestion.querySelectorAll('.smoker-button.selected'); if (this.classList.contains('selected')) { this.classList.remove('selected'); this.classList.remove('text-[#fbeff1]'); this.classList.add('text-primary'); this.classList.remove('bg-[#5b3d4f]'); this.classList.add('bg-[#ffffff]'); } else { this.classList.add('selected'); this.classList.add('text-[#fbeff1]'); this.classList.remove('text-primary'); this.classList.remove('bg-[#ffffff]'); this.classList.add('bg-[#5b3d4f]'); selectedButtons.forEach(button => { button.classList.remove('selected'); button.classList.remove('text-[#fbeff1]'); button.classList.add('text-primary'); button.classList.remove('bg-[#5b3d4f]'); button.classList.add('bg-[#ffffff]'); }); } }); }); function scrollToGetMyQuote() { const targetElement = document.getElementById('getMyQuote'); if (targetElement) { window.scrollTo({ top: targetElement.offsetTop - 175, // Adjust `100` to your header height behavior: 'smooth' }); } } function validateTobaccoQuestion() { if (isTestQuote) { return true; } const selectedButton = document.querySelector('.tobacco-button.selected'); if (!selectedButton) { alert('Please select at least one option for the tobacco question.'); return false; } return true; } function toggleFullMarket() { const quoteCardGallery = document.getElementById('quoteCardGallery'); const viewFullMarketButton = document.getElementById('viewFullMarketButton'); const isFullMarketShown = viewFullMarketButton.textContent === 'Top options only'; if (isFullMarketShown) { // Revert to showing only the top 3 options document.querySelectorAll('.quote-card').forEach((card, index) => { if (index >= 4) { card.classList.add('hidden'); } }); quoteCardGallery.classList.add('sm:justify-center'); viewFullMarketButton.textContent = 'View Full Market'; } else { // Show all options document.querySelectorAll('.quote-card').forEach(card => { card.classList.remove('hidden'); }); quoteCardGallery.classList.remove('sm:justify-center'); viewFullMarketButton.textContent = 'Top options only'; // Start animating scroll let scrollAmount = 0; const scrollStep = 2; // pixels to scroll each step const scrollInterval = 20; // milliseconds between each scroll step let scrollIntervalId; function scrollGallery() { if (scrollAmount < quoteCardGallery.scrollWidth - quoteCardGallery.clientWidth) { scrollAmount += scrollStep; quoteCardGallery.scrollTo({ left: scrollAmount, behavior: 'smooth' }); scrollIntervalId = setTimeout(scrollGallery, scrollInterval); } } // Stop scrolling on user interaction quoteCardGallery.addEventListener('wheel', () => clearTimeout(scrollIntervalId)); quoteCardGallery.addEventListener('touchstart', () => clearTimeout(scrollIntervalId)); quoteCardGallery.addEventListener('mousedown', () => clearTimeout(scrollIntervalId)); scrollGallery(); } } function toggleActiveState(event) { // Add 'active' class to the clicked path; addActiveStateToElement(event.currentTarget); } /*document.getElementById('stateSelect').addEventListener('change', function() { const selectedValue = this.value.toLowerCase(); const pathElement = document.querySelector(`path.${selectedValue}`); if (pathElement) { addActiveStateToElement(pathElement); } else { console.warn(`No path element found with class: ${selectedValue}`); } });*/ function addActiveStateToElement(element) { // Get all path elements const paths = document.querySelectorAll('path'); // Remove 'active' class from all paths paths.forEach(path => path.classList.remove('active')); element.classList.add('active'); }