1/* âââ Lead attribution ââââââââââââââââââââââââââââââââââââââââââââââââââââââ 2 * Records WHERE a lead came from. Nothing on this site did before, which is 3 * why 50+ applications a month couldn't be traced to a channel â Search 4 * Console only sees Google Search clicks, so AI-assistant referrals, direct, 5 * Bing and partner traffic were all invisible. 6 * 7 * Captured on the FIRST page of the session and kept in sessionStorage: by the 8 * time someone reaches the form, document.referrer is the previous page of 9 * this site and the UTM tags are long gone from the URL. Reading either at 10 * submit time would attribute every lead to "internal". 11 */ 12(function(){ 13 var KEY='ax_attr'; 14 function readParams(){ 15 try{ return new URLSearchParams(location.search); }catch(e){ return null; } 16 } 17 /** Group a referrer host into something a human can act on. */ 18 function classify(ref, p){ 19 if(p&&(p.get('gclid')||p.get('gbraid')||p.get('wbraid')||p.get('utm_medium')==='cpc'||p.get('utm_medium')==='ppc')) return 'paid'; 20 /* AI assistants tag their own outbound links and several strip the referrer, 21 * so the referrer alone under-counts them badly: ChatGPT sends 22 * ?utm_source=chatgpt.com and Copilot ?utm_source=copilot.com. Reading only 23 * document.referrer filed 9 of 28 AI-assistant leads as "direct", including 24 * the one web application that has actually funded. Checked before the 25 * referrer because when both are present the tag is the more specific signal. */ 26 var src=''; 27 try{ src=((p&&p.get('utm_source'))||'').toLowerCase(); }catch(e){ src=''; } 28 if(src&&/(chatgpt|openai|copilot|perplexity|claude\.ai|anthropic|gemini|bard|you\.com|poe\.com|phind)/.test(src)) return 'ai_assistant'; 29 var h=''; 30 try{ h=ref?new URL(ref).hostname.replace(/^www\./,'').toLowerCase():''; }catch(e){ h=''; } 31 if(!h) return 'direct'; 32 if(h.indexOf('axiantpartners.com')>-1) return 'internal'; 33 // AI assistants â the channel we most suspect and could least see. 34 if(/(^|\.)(chatgpt\.com|chat\.openai\.com|openai\.com|perplexity\.ai|claude\.ai|anthropic\.com|gemini\.google\.com|bard\.google\.com|copilot\.microsoft\.com|you\.com|poe\.com|phind\.com|arc\.net)$/.test(h)) return 'ai_assistant'; 35 if(/(^|\.)(google\.[a-z.]+|bing\.com|duckduckgo\.com|search\.yahoo\.com|yahoo\.com|ecosia\.org|brave\.com|startpage\.com|baidu\.com|yandex\.[a-z]+)$/.test(h)) return 'organic_search'; 36 if(/(^|\.)(facebook\.com|instagram\.com|linkedin\.com|lnkd\.in|t\.co|twitter\.com|x\.com|reddit\.com|youtube\.com|tiktok\.com|pinterest\.com)$/.test(h)) return 'social'; 37 return 'referral'; 38 } 39 function capture(){ 40 var saved=null; 41 try{ saved=JSON.parse(sessionStorage.getItem(KEY)||'null'); }catch(e){} 42 if(saved&&saved.channel) return saved; 43 var p=readParams(), ref=document.referrer||''; 44 var a={ 45 channel:classify(ref,p), 46 referrer:ref||'(none)', 47 landing_page:location.pathname+(location.search||''), 48 captured_at:new Date().toISOString() 49 }; 50 if(p){ 51 ['utm_source','utm_medium','utm_campaign','utm_term','utm_content','gclid','gbraid','wbraid','fbclid','msclkid'].forEach(function(k){ 52 var v=p.get(k); if(v) a[k]=v; 53 }); 54 } 55 try{ sessionStorage.setItem(KEY,JSON.stringify(a)); }catch(e){} 56 return a; 57 } 58 var attr=capture(); 59 /* Ad click ids, kept for 90 days (Google's click-through conversion window). 60 * capture() is first-touch and per-tab, so a visitor who clicks an ad, leaves and 61 * comes back later to apply would otherwise submit with no click id - and a 62 * conversion Google cannot tie to its click. Newest click wins here, because the 63 * ad platforms attribute to the last ad click. gbraid/wbraid are what Google sends 64 * instead of gclid for many iOS clicks. */ 65 var CLICK_KEY='ax_click_ids', CLICK_IDS=['gclid','gbraid','wbraid','msclkid']; 66 (function(){ 67 var p=readParams(); if(!p) return; 68 var ids={}, any=false; 69 CLICK_IDS.forEach(function(k){ var v=p.get(k); if(v){ ids[k]=v; any=true; } }); 70 if(!any) return; 71 ids.at=Date.now(); 72 try{ localStorage.setItem(CLICK_KEY,JSON.stringify(ids)); }catch(e){} 73 })(); 74 function storedClickIds(){ 75 try{ 76 var c=JSON.parse(localStorage.getItem(CLICK_KEY)||'null'); 77 if(c&&c.at&&Date.now()-c.at<90*864e5) return c; 78 }catch(e){} 79 return null; 80 } 81 /** 82 * The referral partner token from /page?ref=TOKEN, held for the whole session. 83 * 84 * Nothing about a submission says which partner sent it except this token, and 85 * it lives only in the URL â so a visitor who lands on a partner link, reads a 86 * page or two and comes back to apply would otherwise submit with the token 87 * gone and the attribution silently lost. That failure passes every hand test 88 * (you apply straight away) and fails for real partners, so it is stored. 89 * 90 * Two sources, because either alone has a hole: the current URL catches a land 91 * directly on /match.html?ref=..., and `attr.landing_page` â first-touch and 92 * never overwritten, see capture() above â catches a land on /?ref=... followed 93 * by navigation to the form. 94 */ 95 var REF_KEY='axp_ref'; 96 (function(){ 97 var p=readParams(); 98 var token=(p&&p.get('ref')||'').trim(); 99 if(!token&&attr&&attr.landing_page){
100 try{ token=(new URL(attr.landing_page,location.origin).searchParams.get('ref')||'').trim(); }catch(e){} 101 } 102 if(token){ try{ sessionStorage.setItem(REF_KEY,token); }catch(e){} } 103 })(); 104 /** The stored token, or null. The CRM treats an unknown token as no referral. */ 105 window.__axRef=function(){ 106 try{ return sessionStorage.getItem(REF_KEY)||null; }catch(e){ return null; } 107 }; 108 /** Flat params for EmailJS / Netlify. `lead_source` is the one-line summary. */ 109 window.__axAttr=function(){ 110 var a=attr||{}, bits=[]; 111 bits.push('Channel: '+(a.channel||'unknown')); 112 bits.push('Landed on: '+(a.landing_page||'?')); 113 bits.push('Referrer: '+(a.referrer||'(none)')); 114 if(a.utm_source) bits.push('Campaign: '+a.utm_source+' / '+(a.utm_medium||'?')+(a.utm_campaign?' / '+a.utm_campaign:'')); 115 var out={ 116 lead_source:bits.join(' | '), 117 lead_channel:a.channel||'unknown', 118 lead_referrer:a.referrer||'(none)', 119 lead_landing_page:a.landing_page||'', 120 lead_submitted_from:location.pathname 121 }; 122 ['utm_source','utm_medium','utm_campaign','utm_term','utm_content','gclid','gbraid','wbraid','fbclid','msclkid'].forEach(function(k){ 123 if(a[k]) out[k]=a[k]; 124 }); 125 var c=storedClickIds(); 126 if(c){ CLICK_IDS.forEach(function(k){ if(!out[k]&&c[k]) out[k]=c[k]; }); } 127 return out; 128 }; 129})(); 130 131const banks=[{name:"Prime National Bank",minCreditScore:"excellent",minIncome:60000,loanTypes:["personal","home","auto"],maxLoanAmount:500000,employmentRequired:["fulltime","selfemployed"],approvalRate:95,interestRate:"3.5% - 5.5%",features:["Low interest rates","Fast approval (24-48 hours)","No prepayment penalty"]},{name:"Community First Credit Union",minCreditScore:"good",minIncome:40000,loanTypes:["personal","auto","home"],maxLoanAmount:300000,employmentRequired:["fulltime","parttime","selfemployed"],approvalRate:85,interestRate:"4.5% - 7.0%",features:["Member-focused service","Flexible terms","Lower fees"]},{name:"Business Growth Bank",minCreditScore:"good",minIncome:50000,loanTypes:["business","personal"],maxLoanAmount:1000000,employmentRequired:["selfemployed","fulltime"],approvalRate:80,interestRate:"5.0% - 8.0%",features:["Business expertise","SBA loan options","Business consulting included"]},{name:"Metro Trust Bank",minCreditScore:"fair",minIncome:35000,loanTypes:["personal","auto","home"],maxLoanAmount:250000,employmentRequired:["fulltime","parttime","selfemployed","retired"],approvalRate:75,interestRate:"6.0% - 9.5%",features:["Accepts fair credit","Multiple loan options","Online application"]},{name:"SecondChance Financial",minCreditScore:"poor",minIncome:25000,loanTypes:["personal","auto"],maxLoanAmount:50000,employmentRequired:["fulltime","parttime","selfemployed"],approvalRate:70,interestRate:"8.5% - 14.0%",features:["Bad credit accepted","Credit building programs","Financial counseling"]},{name:"Education First Bank",minCreditScore:"fair",minIncome:0,loanTypes:["student"],maxLoanAmount:150000,employmentRequired:["fulltime","parttime","selfemployed","unemployed"],approvalRate:90,interestRate:"4.0% - 7.5%",features:["Student-focused","Deferred payment options","Co-signer accepted"]},{name:"Flexible Finance Corp",minCreditScore:"verypoor",minIncome:20000,loanTypes:["personal"],maxLoanAmount:25000,employmentRequired:["fulltime","parttime"],approvalRate:60,interestRate:"12.0% - 18.0%",features:["No credit check options","Quick approval","Small loan specialist"]},{name:"HomeOwner's Bank",minCreditScore:"good",minIncome:55000,loanTypes:["home"],maxLoanAmount:750000,employmentRequired:["fulltime","selfemployed","retired"],approvalRate:85,interestRate:"3.25% - 5.75%",features:["Mortgage specialists","First-time buyer programs","Low down payment options"]}];const creditScoreRank={"excellent":5,"good":4,"fair":3,"poor":2,"verypoor":1};function matchBanks(customerData){const matches=[];banks.forEach(bank=>{let matchScore=0;let reasons=[];if(!bank.loanTypes.includes(customerData.loanType)){return;} 132if(creditScoreRank[customerData.creditScore]<creditScoreRank[bank.minCreditScore]){return;}else if(creditScoreRank[customerData.creditScore]>=creditScoreRank[bank.minCreditScore]){matchScore+=25;reasons.push("Credit score meets requirements");} 133if(customerData.income<bank.minIncome){return;}else{matchScore+=20;reasons.push("Income qualifies");} 134if(customerData.loanAmount>bank.maxLoanAmount){return;}else{matchScore+=15;reasons.push("Loan amount within limits");}
135if(!bank.employmentRequired.includes(customerData.employment)){return;}else{matchScore+=15;reasons.push("Employment status accepted");} 136if(customerData.creditScore==="excellent"){matchScore+=15;} 137if(customerData.income>bank.minIncome*1.5){matchScore+=10;} 138matches.push({bank:bank,matchScore:matchScore,reasons:reasons});});matches.sort((a,b)=>b.matchScore-a.matchScore);return matches;} 139function displayResults(matches){const resultsContainer=document.getElementById('bankResults');resultsContainer.innerHTML='';if(matches.length===0){resultsContainer.innerHTML=` 140 <div class="no-results"> 141 <h3>No matches found</h3> 142 <p>We couldn't find banks that match your current criteria. Consider:</p> 143 <ul> 144 <li>Improving your credit score</li> 145 <li>Increasing your income</li> 146 <li>Reducing the loan amount</li> 147 <li>Working with a credit counselor</li> 148 </ul> 149 </div> 150 `;return;} 151const topMatches=matches.slice(0,3);topMatches.forEach((match,index)=>{const bank=match.bank;const matchPercentage=Math.min(match.matchScore,100);const approvalLikelihood=Math.min(Math.round(bank.approvalRate*(matchPercentage/100)),bank.approvalRate);let matchClass='high-match';if(matchPercentage<70)matchClass='medium-match';if(matchPercentage<50)matchClass='low-match';const bankCard=document.createElement('div');bankCard.className=`bank-card ${matchClass}`;bankCard.innerHTML=` 152 <div class="bank-header"> 153 <h3>${index + 1}. ${bank.name}</h3> 154 <div class="match-badge"> 155 <span class="match-percentage">${matchPercentage}%</span> 156 <span class="match-label">Match</span> 157 </div> 158 </div> 159 <div class="bank-info"> 160 <div class="info-row"> 161 <span class="label">Approval Likelihood:</span> 162 <span class="value" style="color: #3ca6d8; font-weight: 700;">${approvalLikelihood}%</span> 163 </div> 164 <div class="info-row"> 165 <span class="label">Interest Rate:</span> 166 <span class="value">${bank.interestRate}</span> 167 </div> 168 <div class="info-row"> 169 <span class="label">Max Loan:</span> 170 <span class="value">$${bank.maxLoanAmount.toLocaleString()}</span> 171 </div> 172 </div> 173 <div class="features"> 174 <h4>Key Features:</h4> 175 <ul> 176 ${bank.features.map(feature => `<li>${feature}</li>`).join('')} 177 </ul> 178 </div> 179 <div class="match-reasons"> 180 <h4>Why you match:</h4> 181 <ul> 182 ${match.reasons.map(reason => `<li>${reason}</li>`).join('')} 183 </ul> 184 </div> 185 `;resultsContainer.appendChild(bankCard);});} 186function generateReferenceNumber(){const timestamp=Date.now().toString(36).toUpperCase();const random=Math.random().toString(36).substring(2,7).toUpperCase();return`AXP-${timestamp}-${random}`;} 187window.addEventListener('load',function(){if(typeof emailjs!=='undefined'){emailjs.init("VCRoHGxbB5ZkCxxUg");console.log('EmailJS initialized');}else{console.error('EmailJS failed to load');}});document.addEventListener('DOMContentLoaded',function(){const loanForm=document.getElementById('loanForm');const leadForm=document.getElementById('leadForm');const contactForm=document.getElementById('contactForm'); 188function handleContactSubmit(e){e.preventDefault();if(typeof emailjs==='undefined'){alert('Email service is not available. Please refresh the page and try again.');return;} 189const submitBtn=e.target.querySelector('button[type="submit"]');const originalText=submitBtn.textContent;submitBtn.textContent='Sending...';submitBtn.disabled=true;const subjectSelect=document.getElementById('contactSubject');const subjectText=subjectSelect.options[subjectSelect.selectedIndex].text;/* Attribution: same shape the application and partial-lead paths already use. 190 Appended to `message` as well as spread, because template_xujy2ik renders 191 `message` today - relying on the spread alone would need a template edit. */ 192const contactData={from_name:document.getElementById('contactName').value,from_email:document.getElementById('contactEmail').value,phone:document.getElementById('contactPhone').value||'Not provided',subject:subjectText,message:document.getElementById('contactMessage').value+(typeof window.__axAttr==='function'?'\n\n--- Source ---\n'+window.__axAttr().lead_source:''),...(typeof window.__axAttr==='function'?window.__axAttr():{}),to_email:'[email protected]'};var email1=emailjs.send('service_jweh7na','template_xujy2ik',{...contactData,to_email:'[email protected]'});Promise.allSettled([email1]).then(function(results){if(results[0].status==='fulfilled'){document.getElementById('contactForm').style.display='none';var ty=document.getElementById('contactThankYou');if(ty)ty.style.display='block';window.scrollTo({top:0,behavior:'smooth'});}else{alert('Sorry, there was an error sending your message. Please email us directly at [email protected] or try again later.');} 193submitBtn.textContent=originalText;submitBtn.disabled=false;}).catch(function(err){console.error('Contact form error:',err);alert('Sorry, there was an error sending your message. Please email us directly at [email protected] or try again later.');submitBtn.textContent=originalText;submitBtn.disabled=false;});} 194/* The success UI, shared by the path that runs when EmailJS is unavailable. */ 195function __axShowApplicationThankYou(isLeadForm){if(isLeadForm){var lf=document.getElementById('leadForm');var lfTy=document.getElementById('leadFormThankYou');if(lf)lf.style.display='none';if(lf&&lf.nextElementSibling)lf.nextElementSibling.style.display='none';if(lfTy)lfTy.style.display='block';}else{var af=document.getElementById('applicationForm');
195if(af)af.style.display='none';var sb=document.getElementById('matchStickySubmit');if(sb)sb.style.display='none';var ty=document.getElementById('thankYouContainer');if(ty){ty.style.display=ty.classList.contains('match-thank-you')?'flex':'block';if(ty.classList.contains('match-thank-you')){ty.setAttribute('aria-hidden','false');document.body.style.overflow='hidden';}}}window.scrollTo({top:0,behavior:'smooth'});} 196function handleApplicationSubmit(e,isLeadForm){e.preventDefault();const agreeToTerms=document.getElementById('agreeToTerms');if(!agreeToTerms){alert('Form elements not found. Please refresh the page and try again.');console.error('agreeToTerms checkbox not found');return;} 197if(!agreeToTerms.checked){alert('Please agree to the Privacy Policy and Terms and Conditions to continue.');agreeToTerms.focus();return;} 198/* EmailJS is blocked by some ad blockers and flaky mobile networks. It used to abort the 199 submit right here - before the CRM POST - so the lead was lost entirely. Now the CRM 200 intake below still runs, and the thank-you waits on the CRM accepting it. */ 201var __axNoEmail=(typeof emailjs==='undefined');if(__axNoEmail){console.error('EmailJS is not loaded - relying on CRM intake');} 202const customerData={fullName:document.getElementById('fullName').value,email:document.getElementById('email').value,phone:document.getElementById('phone').value,loanAmount:document.getElementById('loanAmount').value,businessName:document.getElementById('businessName').value,loanType:document.getElementById('loanType').value,creditScore:document.getElementById('creditScore').value,revenue:document.getElementById('revenue').value,yearsInBusiness:document.getElementById('yearsInBusiness').value,equipmentDescription:document.getElementById('equipmentDescription').value};const referenceNumber=generateReferenceNumber();var refEl=document.getElementById('referenceNumber');var leadRefEl=document.getElementById('leadFormReference');if(refEl)refEl.textContent=referenceNumber;if(leadRefEl)leadRefEl.textContent=referenceNumber;const submitButton=e.target.querySelector('button[type="submit"]');const originalButtonText=submitButton.textContent;submitButton.textContent='Submitting...';submitButton.disabled=true;console.log('Sending application email with data:',customerData);const isCobrandedPage=window.location.pathname.includes('rightmfgsystems.html');const urlParams=new URLSearchParams(window.location.search);const vendorEmail=urlParams.get('vendor');if(vendorEmail){console.log('Vendor email detected:',vendorEmail);}else{console.log('No vendor email in URL');} 203/* Direct path into the CRM, via the Netlify function that holds the intake key 204 (netlify/functions/apply.mjs). Fire-and-forget and deliberately BEFORE the 205 EmailJS branches: it must not gate the success UI, and a CRM outage must not 206 cost us the email copy of a lead. 207 208 EmailJS still runs during the cutover, so every application arrives twice. The 209 two collapse into ONE lead only because `referenceNumber` is sent: the CRM keys 210 loan_app dedupe on `referenceNumber ?? AXP-<timestamp>`, and the timestamp 211 fallback would make every submission unique â i.e. double every applicant. 212 Do not drop that field while both paths are live. 213 214 `revenue` is the site's ANNUAL revenue select (match.html: "Annual Business 215 Revenue"), so it maps to annualRevenue, not monthlyRevenue. The CRM discards 216 "Not specified" / "N/A" itself, so values go over raw. */ 217/* Google Ads, from the same choke point as Meta and OpenAI. It used to fire only after 218 EmailJS succeeded, so an email hiccup silently dropped a real application from Google's 219 count. transaction_id is the reference number, so a double submit counts once. 220 user_data feeds enhanced conversions (gtag hashes it before sending); phone goes as 221 E.164, which for a bare 10-digit US number needs the 1. */ 222try{if(typeof gtag==='function'){var __gEm=(customerData.email||'').trim().toLowerCase();var __gPh=(customerData.phone||'').replace(/\D/g,'');if(__gPh.length===10)__gPh='1'+__gPh;var __gUd={};if(__gEm)__gUd.email=__gEm;if(__gPh.length>=11)__gUd.phone_number='+'+__gPh;
222if(__gUd.email||__gUd.phone_number)gtag('set','user_data',__gUd);}if(typeof gtag_report_conversion==='function')gtag_report_conversion(undefined,{transaction_id:referenceNumber});}catch(__ge){} 223if(typeof fbq==='function'){try{fbq('track','Lead',{},{eventID:referenceNumber});}catch(__fbe){}}if(typeof oaiq==='function'){try{oaiq('measure','lead_created',{type:'customer_action'},{event_id:referenceNumber});}catch(__oe){}}var __axCrm=null;try{__axCrm=fetch('/.netlify/functions/apply',{method:'POST',keepalive:true,headers:{'content-type':'application/json'},body:JSON.stringify({form_type:'loan_app',name:customerData.fullName,email:customerData.email,phone:customerData.phone,businessName:customerData.businessName,loanAmount:customerData.loanAmount,loanType:customerData.loanType,creditScore:customerData.creditScore,annualRevenue:customerData.revenue,yearsInBusiness:customerData.yearsInBusiness,equipmentDescription:customerData.equipmentDescription,referenceNumber:referenceNumber,smsConsent:!!(document.getElementById('smsConsent')&&document.getElementById('smsConsent').checked),ref:(typeof window.__axRef==='function'?window.__axRef():null),page_url:window.location.href,message:(typeof window.__axAttr==='function'?window.__axAttr().lead_source:''),...(typeof window.__axAttr==='function'?window.__axAttr():{})})});__axCrm.then(function(r){console.log('CRM intake:',r.status);}).catch(function(err){console.error('CRM intake failed (EmailJS still sent):',err);});}catch(err){console.error('CRM intake threw:',err);} 224if(__axNoEmail){Promise.resolve(__axCrm).then(function(r){if(r&&r.ok){__axShowApplicationThankYou(isLeadForm);}else{throw new Error('CRM intake '+(r?r.status:'not sent'));}}).catch(function(err){console.error('Application not accepted:',err);alert('Sorry, there was an error submitting your application. Please contact us directly at [email protected] or try again later.');submitButton.textContent=originalButtonText;submitButton.disabled=false;});return;} 225const emailData={full_name:customerData.fullName,email:customerData.email,phone:customerData.phone,loan_amount:customerData.loanAmount||'Not specified',business_name:customerData.businessName||'Not specified',loan_type:customerData.loanType,credit_score:customerData.creditScore,revenue:customerData.revenue||'Not specified',years_in_business:customerData.yearsInBusiness||'Not specified',equipment_description:customerData.equipmentDescription||'N/A',reference_number:referenceNumber,referral_token:(typeof window.__axRef==='function'?(window.__axRef()||''):''),to_email:'[email protected]',...(typeof window.__axAttr==='function'?window.__axAttr():{})};if(vendorEmail){const decodedVendorEmail=decodeURIComponent(vendorEmail);const emailRegex=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;if(!emailRegex.test(decodedVendorEmail)){console.error('Invalid vendor email format:',decodedVendorEmail);alert('Invalid vendor email in URL. Please contact support.');submitButton.textContent=originalButtonText;submitButton.disabled=false;return;} 226console.log('Sending emails to Axiant Partners and vendor:',decodedVendorEmail);console.log('Full URL:',window.location.href);console.log('URL params:',window.location.search);const emailDataWithVendor={...emailData,vendor_email:decodedVendorEmail,vendor_note:`\n\n---\nThis application was submitted through a vendor partnership.\nVendor Email: ${decodedVendorEmail}\nPlease forward this application to the vendor.`};const email1=emailjs.send('service_jweh7na','template_dmwg1ey',{...emailDataWithVendor,to_email:'[email protected]'}).then(function(response){console.log('Email 1 (Axiant) sent successfully:',response);console.log('Response status:',response.status);console.log('Response text:',response.text);return response;}).catch(function(error){console.error('Email 1 (Axiant) failed:',error);console.error('Error status:',error.status);console.error('Error text:',error.text);throw{email:'Axiant',error:error};});const email2=emailjs.send('service_jweh7na','template_dmwg1ey',{...emailData,to_email:decodedVendorEmail}).then(function(response){console.log('Email 2 (Vendor) sent successfully:',response);console.log('Response status:',response.status);console.log('Response text:',response.text);return response;}).catch(function(error){console.error('Email 2 (Vendor) failed:',error);console.error('Vendor email used:',decodedVendorEmail);console.error('Error status:',error.status);console.error('Error text:',error.text);console.error('Note: If this fails, the vendor email may need to be whitelisted in EmailJS service settings.');throw{email:'Vendor',error:error};});Promise.allSettled([email1,email2]).then(function(results){console.log('Email sending results:',results);const axiantResult=results[0];const vendorResult=results[1];if(axiantResult.status==='fulfilled'){console.log('Axiant email sent successfully');}else{console.error('Axiant email failed:',axiantResult.reason);} 227if(vendorResult.status==='fulfilled'){console.log('Vendor email sent successfully');}else{console.error('Vendor email failed:',vendorResult.reason);console.error('This might be due to EmailJS template configuration. Make sure the template uses {{to_email}} variable.');} 228if(axiantResult.status==='fulfilled'){if(isLeadForm){var lf=document.getElementById('leadForm');var lfTy=document.getElementById('leadFormThankYou');if(lf)lf.style.display='none';if(lf&&lf.nextElementSibling)lf.nextElementSibling.style.display='none';if(lfTy)lfTy.style.display='block';}else{document.getElementById('applicationForm').style.display='none';var sb=document.getElementById('matchStickySubmit');if(sb)sb.style.display='none';var ty=document.getElementById('thankYouContainer');if(ty){ty.style.display=ty.classList.contains('match-thank-you')?'flex':'block';if(ty.classList.contains('match-thank-you')){ty.setAttribute('aria-hidden','false');document.body.style.overflow='hidden';}}} 229window.scrollTo({top:0,behavior:'smooth'});}else{let errorMessage='Sorry, there was an error submitting your application. ';if(axiantResult.reason&&axiantResult.reason.error&&axiantResult.reason.error.status===4
22912){errorMessage+='The email service connection needs to be updated. Please contact us directly at [email protected] or try again later.';}else{errorMessage+='Please contact us directly at [email protected] or try again later.';} 230alert(errorMessage);submitButton.textContent=originalButtonText;submitButton.disabled=false;}});} 231else if(isCobrandedPage){const email1=emailjs.send('service_jweh7na','template_dmwg1ey',{...emailData,to_email:'[email protected]'});const email2=emailjs.send('service_jweh7na','template_dmwg1ey',{...emailData,to_email:'[email protected]'});Promise.all([email1,email2]).then(function(responses){console.log('Both emails sent successfully!',responses);if(isLeadForm){var lf=document.getElementById('leadForm');var lfTy=document.getElementById('leadFormThankYou');if(lf)lf.style.display='none';if(lf&&lf.nextElementSibling)lf.nextElementSibling.style.display='none';if(lfTy)lfTy.style.display='block';}else{document.getElementById('applicationForm').style.display='none';var sb=document.getElementById('matchStickySubmit');if(sb)sb.style.display='none';var ty=document.getElementById('thankYouContainer');if(ty){ty.style.display=ty.classList.contains('match-thank-you')?'flex':'block';if(ty.classList.contains('match-thank-you')){ty.setAttribute('aria-hidden','false');document.body.style.overflow='hidden';}}} 232window.scrollTo({top:0,behavior:'smooth'});}).catch(function(error){console.error('Email sending failed:',error);console.error('Error details:',JSON.stringify(error,null,2));let errorMessage='Sorry, there was an error submitting your application. ';
232if(error.status===412){errorMessage+='The email service connection needs to be updated. Please contact us directly at [email protected] or try again later.';}else{errorMessage+='Please contact us directly at [email protected] or try again later.';} 233alert(errorMessage);submitButton.textContent=originalButtonText;submitButton.disabled=false;});}else{var email1=emailjs.send('service_jweh7na','template_dmwg1ey',{...emailData,to_email:'[email protected]'});Promise.allSettled([email1]).then(function(results){var axiantOk=results[0].status==='fulfilled';if(axiantOk){console.log('Application email sent successfully!');if(isLeadForm){var lf=document.getElementById('leadForm');var lfTy=document.getElementById('leadFormThankYou');if(lf)lf.style.display='none';if(lf&&lf.nextElementSibling)lf.nextElementSibling.style.display='none';if(lfTy)lfTy.style.display='block';}else{document.getElementById('applicationForm').style.display='none';var sb=document.getElementById('matchStickySubmit');if(sb)sb.style.display='none';var ty=document.getElementById('thankYouContainer');if(ty){ty.style.display=ty.classList.contains('match-thank-you')?'flex':'block';if(ty.classList.contains('match-thank-you')){ty.setAttribute('aria-hidden','false');document.body.style.overflow='hidden';}}} 234window.scrollTo({top:0,behavior:'smooth'});}else{console.error('Email sending failed:',results[0].reason);var err=results[0].reason&&results[0].reason.error?results[0].reason.error:{};var errorMessage='Sorry, there was an error submitting your application. ';errorMessage+=(err.status===412)?'The email service connection needs to be updated. ':'';errorMessage+='Please contact us directly at [email protected] or try again later.';alert(errorMessage);submitButton.textContent=originalButtonText;submitButton.disabled=false;}});}} 235if(contactForm){contactForm.addEventListener('submit',handleContactSubmit);if(window.matchMedia&&window.matchMedia('(max-width:768px)').matches){var contactSticky=document.createElement('div');contactSticky.className='contact-sticky-submit match-sticky-submit';contactSticky.innerHTML='<button type="submit" form="contactForm" class="btn-primary">Send Message</button>';contactSticky.querySelector('button').style.minHeight='48px';document.body.appendChild(contactSticky);var contactFooter=document.querySelector('.contact-hero-wrap~.site-footer,.contact-content~.site-footer');var cf=document.querySelector('.site-footer');if(cf&&typeof IntersectionObserver!=='undefined'){var cio=new IntersectionObserver(function(entries){entries.forEach(function(entry){if(!contactSticky)return;contactSticky.classList.toggle('sticky-bar-hidden',entry.isIntersecting);});},{rootMargin:'0px 0px 100px 0px',threshold:0});cio.observe(cf);}}} 236if(loanForm){loanForm.addEventListener('submit',function(e){handleApplicationSubmit(e,false);}); 237/* Partial-lead capture: the moment a visitor has a valid name+email+phone, send a clearly-labeled 238 "Partial Application Lead" so abandoned applications are never lost and the contact is delivered 239 before the final submit can fail. Fires once per page load. Purely additive â does not touch the 240 full-application submit. */ 241function __axCapturePartial(){if(window.__axPartialSent)return;if(typeof emailjs==='undefined')return;var nm=document.getElementById('fullName'),em=document.getElementById('email'),ph=document.getElementById('phone');if(!nm||!em||!ph)return;var name=(nm.value||'').trim(),email=(em.value||'').trim(),phone=(ph.value||'').trim();if(!name||!email||!phone)return;if(!/.+@.+\..+/.test(email))return;window.__axPartialSent=true;if(typeof __axNetlifyBackup==='function')__axNetlifyBackup('partial');var g=function(id){var e=document.getElementById(id);return e&&e.value?e.value:'';};var extras=[];if(g('loanAmount'))extras.push('Loan amount: '+g('loanAmount'));if(g('loanType'))extras.push('Loan type: '+g('loanType'));if(g('businessName'))extras.push('Business: '+g('businessName'));var msg='PARTIAL APPLICATION LEAD â this person entered their contact details on the Get Matched form but has NOT submitted the full application yet. Follow up promptly.'+(extras.length?'\n\n'+extras.join('\n'):'');var data={from_name:name,from_email:email,phone:phone,subject:'â Partial Application Lead (follow up)',message:msg+(typeof window.__axAttr==='function'?'\n\n--- Source ---\n'+window.__axAttr().lead_source:''),...(typeof window.__axAttr==='function'?window.__axAttr():{})};try{emailjs.send('service_jweh7na','template_xujy2ik',{...data,to_email:'[email protected]'});}catch(__e){try{localStorage.setItem('axiant_partial_lead',JSON.stringify(data));}catch(__e2){}}} 242['fullName','email','phone'].forEach(function(__id){var __el=document.getElementById(__id);if(__el)__el.addEventListener('blur',__axCapturePartial);}); 243/* Server-side backup via Netlify Forms â fire-and-forget POST alongside EmailJS s
243o no lead is lost if EmailJS fails. Only runs on pages that have the hidden detection form (match.html). */ 244function __axNetlifyBackup(leadType){try{if(!document.querySelector('form[name="loan-application"]'))return;var nf=new URLSearchParams();nf.append('form-name','loan-application');['fullName','email','phone','loanAmount','businessName','loanType','creditScore','revenue','yearsInBusiness','equipmentDescription'].forEach(function(__id){var __el=document.getElementById(__id);if(__el&&__el.value)nf.append(__id,__el.value);});nf.append('lead_type',leadType||'full');nf.append('page_url',location.pathname);if(typeof window.__axAttr==='function'){var __a=window.__axAttr();Object.keys(__a).forEach(function(__k){if(__a[__k])nf.append(__k,String(__a[__k]));});}fetch('/',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:nf.toString()}).catch(function(){});}catch(__nfe){}} 245loanForm.addEventListener('submit',function(){__axNetlifyBackup('full');}); 246if(window.matchMedia&&window.matchMedia('(max-width:768px)').matches){var submitBtn=loanForm.querySelector('button[type="submit"]');var stickyBar=document.createElement('div');stickyBar.id='matchStickySubmit';stickyBar.className='match-sticky-submit';stickyBar.setAttribute('aria-hidden','true');var agreeEl=document.getElementById('agreeToTerms');var privacyPath=document.querySelector('a[href*="privacy-policy"]');var termsPath=document.querySelector('a[href*="terms-and-conditions"]');var pHref=privacyPath?privacyPath.getAttribute('href'):'/privacy-policy.html';var tHref=termsPath?termsPath.getAttribute('href'):'/terms-and-conditions.html';stickyBar.innerHTML='<p class="match-sticky-trust">$300M+ funded · Same-day response · Free</p><label for="agreeToTerms" class="match-sticky-checkbox" id="matchStickyCheckboxLabel"><span class="match-sticky-checkbox-box"></span>I agree to <a href="'+pHref+'" target="_blank" onclick="event.stopPropagation()">Privacy Policy</a> & <a href="'+tHref+'" target="_blank" onclick="event.stopPropagation()">Terms</a></label><button type="submit" form="loanForm" class="btn-primary">'+(submitBtn?submitBtn.textContent:'Get Matched')+'</button>'; 247function syncStickyCheckbox(){var cb=document.getElementById('agreeToTerms');var lb=document.getElementById('matchStickyCheckboxLabel');if(cb&&lb){if(cb.checked)lb.classList.add('is-checked');else lb.classList.remove('is-checked');}} 248function initFormSteps(){var steps=loanForm.querySelectorAll('.form-step');if(!steps.length)return;var indicator=document.getElementById('formStepIndicator');var nextBtn=document.getElementById('formStepNext');var backBtn=document.getElementById('formStepBack');var isMobile=function(){return window.matchMedia&&window.matchMedia('(max-width:768px)').matches;}; 249function setStep(n){var idx=Math.max(1,Math.min(n,steps.length));steps.forEach(function(s,i){s.classList.toggle('form-step-active',i+1===idx);});if(indicator){indicator.querySelectorAll('.form-step-dot').forEach(function(d,i){d.classList.toggle('active',i+1===idx);d.setAttribute('aria-current',i+1===idx?'step':null);});} 250if(backBtn)backBtn.style.display=idx>1&&isMobile()?'inline-flex':'none';if(nextBtn){nextBtn.style.display=isMobile()?'inline-flex':'none';nextBtn.textContent=idx===steps.length?'Submit Application':idx===steps.length-1?'Review & Submit':'Continue';nextBtn.type=idx===steps.length?'submit':'button';} 251var sb=document.getElementById('matchStickySubmit');if(sb){var showFull=idx===steps.length;sb.querySelector('.match-sticky-trust').style.display=showFull?'block':'none';var cbWrap=sb.querySelector('.match-sticky-checkbox');if(cbWrap)cbWrap.style.display=showFull?'flex':'none';var sbBtn=sb.querySelector('button[type="submit"]');if(sbBtn){sbBtn.style.display=showFull?'inline-flex':'none';sbBtn.type='submit';}var stepBtn=sb.querySelector('.match-sticky-step-next');if(!stepBtn&&!showFull){stepBtn=document.createElement('button');stepBtn.type='button';stepBtn.className='btn-primary match-sticky-step-next';stepBtn.textContent='Continue';sb.appendChild(stepBtn);}
251if(stepBtn){stepBtn.style.display=showFull?'none':'inline-flex';stepBtn.onclick=function(){goNext();};}}} 252function validateStep(idx){var step=steps[idx];if(!step)return true;var inputs=step.querySelectorAll('input[required],select[required]');var valid=true;inputs.forEach(function(inp){if(!inp.value||!inp.value.trim()){valid=false;inp.reportValidity?inp.reportValidity():inp.focus();}});return valid;} 253function goNext(){var current=Array.from(steps).findIndex(function(s){return s.classList.contains('form-step-active');});if(current>=0&&validateStep(current)){if(current===2&&typeof __axCapturePartial==='function')__axCapturePartial();setStep(current+2);}} 254function goBack(){var current=Array.from(steps).findIndex(function(s){return s.classList.contains('form-step-active');});if(current>0)setStep(current);} 255if(nextBtn){nextBtn.addEventListener('click',function(){if(nextBtn.type==='submit')return;goNext();});}if(backBtn){backBtn.addEventListener('click',goBack);} 256steps.forEach(function(s){s.classList.add('form-step-active');});if(indicator)indicator.setAttribute('aria-hidden','true');if(backBtn)backBtn.style.display='none';if(nextBtn)nextBtn.style.display='none';} 257if(agreeEl){agreeEl.addEventListener('change',syncStickyCheckbox);}document.body.appendChild(stickyBar);syncStickyCheckbox();var footer=document.querySelector('.site-footer');if(footer&&typeof IntersectionObserver!=='undefined'){var io=new IntersectionObserver(function(entries){entries.forEach(function(entry){var sb=document.getElementById('matchStickySubmit');if(!sb)return;if(entry.isIntersecting){sb.classList.add('sticky-bar-hidden');}else{sb.classList.remove('sticky-bar-hidden');}});},{rootMargin:'0px 0px 100px 0px',threshold:0});io.observe(footer);}}if(typeof initFormSteps==='function')initFormSteps();} 258if(leadForm){leadForm.addEventListener('submit',function(e){handleApplicationSubmit(e,true);});} 259var newContactBtn=document.getElementById('newContactMessage');if(newContactBtn){newContactBtn.addEventListener('click',function(){var form=document.getElementById('contactForm');var ty=document.getElementById('contactThankYou');if(form)form.style.display='';if(ty)ty.style.display='none';if(form)form.reset();window.scrollTo({top:0,behavior:'smooth'});});} 260const newApplicationBtn=document.getElementById('newApplication');const thankYouContainer=document.getElementById('thankYouContainer');const matchBackdrop=document.getElementById('matchThankYouBackdrop');function closeMatchThankYouModal(){const appForm=document.getElementById('applicationForm');const ty=document.getElementById('thankYouContainer');const loanForm=document.getElementById('loanForm');var sb=document.getElementById('matchStickySubmit');if(sb)sb.style.display='';if(appForm)appForm.style.display='block';if(ty){ty.style.display='none';ty.setAttribute('aria-hidden','true');} 261document.body.style.overflow='';if(loanForm)loanForm.reset();window.scrollTo({top:0,behavior:'smooth'});} 262if(newApplicationBtn){newApplicationBtn.addEventListener('click',closeMatchThankYouModal);} 263if(matchBackdrop){matchBackdrop.addEventListener('click',closeMatchThankYouModal);} 264document.addEventListener('keydown',function(e){if(e.key==='Escape'&&thankYouContainer&&thankYouContainer.classList.contains('match-thank-you')&&thankYouContainer.style.display==='flex'){closeMatchThankYouModal();}});function enhanceTablesForMobile(){document.querySelectorAll('table').forEach(function(table){var headers=[];var headerRow=table.querySelector('thead tr');if(headerRow){headerRow.querySelectorAll('th').forEach(function(th,i){headers[i]=(th.textContent||'').trim();});}table.querySelectorAll('tbody tr').forEach(function(tr){tr.querySelectorAll('td').forEach(function(td,i){if(headers[i])td.setAttribute('data-label',headers[i]);});});});}enhanceTablesForMobile();});(function initMobileNavOverlayHandlers(){var scrollPos=0;function run(){var mobileNavToggle=document.getElementById('mobileNavToggle')||document.querySelector('.mobile-menu-toggle');var mobileNavOverlay=document.getElementById('mobileNavOverlay');var mobileNavClose=document.getElementById('mobileNavClose');if(mobileNavClose&&(mobileNavClose.textContent||'').trim()==='?'){mobileNavClose.textContent='Ã';}var overlayLinks=document.getElementById('mobileOverlayNavLinks');var mainNavLinks=document.querySelector('.main-nav .nav-links');if(overlayLinks&&mainNavLinks){overlayLinks.innerHTML='';var children=mainNavLinks.children;for(var i=0;i<children.length;i++){var el=children[i];if(el.tagName==='A'){if(el.classList&&el.classList.contains('nav-link-mobile'))continue;var a=el.cloneNode(true);a.classList.remove('active');overlayLinks.appendChild(a);}else if(el.classList&&el.classList.contains('nav-dropdown')){var trigger=el.querySelector('.nav-dropdown-trigger');var triggerText=trigger?(trigger.textContent||'').trim():'';var isIndustries=triggerText==='Industries';var isServices=triggerText==='Services';if(isIndustries){var ia=document.createElement('a');ia.setAttribute('href','/industries.html');ia.textContent='Industries';overlayLinks.appendChild(ia);}else if(isServices){var sa=document.createElement('a');sa.setAttribute('href','/services.html');sa.textContent='Services';overlayLinks.appendChild(sa);}else{var mobileLink=el.nextElementSibling;if(mobileLink&&mobileLink.tagName==='A'&&mobileLink.classList.contains('nav-link-mobile')){var a=mobileLink.cloneNode(true);a.classList.remove('active');overlayLinks.appendChild(a);}else{var firstA=el.querySelector('.nav-dropdown-menu a');if(firstA){var a=firstA.cloneNode(true);overlayLinks.appendChild(a);}}}}}}function openMobileNav(){if(!mobileNavOverlay||window.innerWidth>768)return;scrollPos=window.pageYOffset||document.documentElement.scrollTop;mobileNavOverlay.classList.add('open');if(mobileNavToggle)mobileNavToggle.classList.add('active');document.documentElement.classList.add('mobile-nav-open');document.body.classList.add('mobile-nav-open');document.body.style.overflow='hidden';document.body.style.touchAction='none';document.body.style.position='fixed';document.body.style.top='-'+scrollPos+'px';
264document.body.style.left='0';document.body.style.right='0';document.body.style.width='100%';} 265function closeMobileNav(){if(!mobileNavOverlay)return;mobileNavOverlay.classList.remove('open');if(mobileNavToggle)mobileNavToggle.classList.remove('active');document.documentElement.classList.remove('mobile-nav-open');document.body.classList.remove('mobile-nav-open');document.body.style.overflow='';document.body.style.touchAction='';document.body.style.position='';document.body.style.top='';document.body.style.left='';document.body.style.right='';document.body.style.width='';window.scrollTo(0,scrollPos);} 266if(mobileNavToggle&&mobileNavOverlay){mobileNavToggle.addEventListener('click',function(){if(window.innerWidth<=768){if(mobileNavOverlay.classList.contains('open'))closeMobileNav();else openMobileNav();}});}if(mobileNavClose&&mobileNavOverlay){mobileNavClose.addEventListener('click',closeMobileNav);}if(mobileNavOverlay){mobileNavOverlay.querySelectorAll('#mobileOverlayNavLinks a, .mobile-overlay-links a, .nav-cta').forEach(function(link){link.addEventListener('click',closeMobileNav);});mobileNavOverlay.addEventListener('click',function(e){if(e.target===mobileNavOverlay)closeMobileNav();});}}setTimeout(run,80);})();(function(){function addRevealClasses(){var skip=function(el){return!el||el.closest('.main-nav,footer,.match-thank-you-modal,.calc-results-modal,.nav-dropdown-menu,.mobile-nav-overlay')};document.querySelectorAll('section:not(.contact-hero-wrap):not(.referral-hero-wrap):not(.calculator-hero-wrap):not(.match-hero-wrap)').forEach(function(s){if(skip(s))return;s.classList.add('reveal');});document.querySelectorAll('.card,.service-card,.benefit-card,.step-card,.blog-card,.metric-card,.industry-tile,.about-section,.section-block,.contact-main,.referral-main,.landing-cta-strip').forEach(function(c){if(skip(c))return;c.classList.add('reveal');});document.querySelectorAll('main h1,main h2,main h3,section h1,section h2,section h3,.hero-copy h1,.hero-copy h2,.section-block h2,.section-block h3').forEach(function(h){if(skip(h))return;h.classList.add('reveal');});document.querySelectorAll('.metric-card,.metric-grid .metric-card').forEach(function(m,i){if(skip(m))return;m.classList.add('reveal','reveal-delay-'+(Math.min(i,3)+1));});var cardRows=document.querySelectorAll('.metric-grid,.benefit-grid,.step-grid,.industry-grid');cardRows.forEach(function(row){var cards=row.querySelectorAll('.metric-card,.benefit-card,.step-card,.industry-tile');cards.forEach(function(c,i){if(skip(c))return;c.classList.add('reveal','reveal-delay-'+((i%4)+1));});});var twoCol=document.querySelectorAll('.hero-grid,.about-section,.section-block');twoCol.forEach(function(blk){var left=blk.querySelector('.hero-copy,.section-intro,.about-content');var right=blk.querySelector('.hero-form,.section-content,.form-container');if(left&&right){left.classList.add('reveal-left');right.classList.add('reveal-right');}});document.querySelectorAll('main img,section img').forEach(function(img){if(skip(img))return;if(img.closest('.card,.nav-brand'))return;img.classList.add('reveal');});}addRevealClasses();var revealEls=document.querySelectorAll('.reveal,.reveal-left,.reveal-right');
266if(window.innerWidth<=768){revealEls.forEach(function(el){el.classList.add('visible');});}else{var vh=window.innerHeight;revealEls.forEach(function(el){var r=el.getBoundingClientRect();if(r.top<vh*0.9)el.classList.add('visible');});var revealObserver=new IntersectionObserver(function(entries){entries.forEach(function(entry){if(entry.isIntersecting){entry.target.classList.add('visible');revealObserver.unobserve(entry.target);}});},{threshold:0.12});revealEls.forEach(function(el){if(!el.classList.contains('visible'))revealObserver.observe(el);});}})();
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.