(function () {

                  var psm_wb_font = new FontFace('Bebas Neue', 'url(/css/BebasNeue-Regular.ttf)'); 
                  psm_wb_font.load().then(function(psm_Bebas_Neue_face) { 
                      document.fonts.add(psm_Bebas_Neue_face); 
                  }).catch(function(error) { 
                    // error occurred
                  }); 
                  // ---------- single-run & defer reinsert ----------
                  if (window.__PSM_WRAPPER_DONE__) return;
                  window.__PSM_WRAPPER_DONE__ = true;

                  try {
                    var currScript = document.currentScript;
                    if (currScript && !currScript.defer) {
                      var defScript = document.createElement('script');
                      defScript.src = currScript.src;
                      defScript.defer = true;
                      function replaceScript(){
                        if (currScript.parentNode) { currScript.parentNode.removeChild(currScript); }
                        (document.head || document.documentElement).appendChild(defScript);
                      }
                      if (document.readyState === 'loading') {
                        document.addEventListener('DOMContentLoaded', replaceScript);
                      } else {
                        replaceScript();
                      }
                      return; // let the deferred copy run once
                    }
                  } catch(e) {}

                  if (window.PSMScriptLoaded === true) {
                    console.log('Firestorm Script already loaded under Dealer ' + window.PSMScriptDealerId + ' and this script is attempting to load e0dd12b85803459184a7741e7e21b4a1');
                    return;
                  }
                  window.PSMScriptLoaded = true;
                  window.PSMScriptDealerId = 'e0dd12b85803459184a7741e7e21b4a1';

                  // ---------- PSM TIMER (inspectable) ----------
                  window.psm_timer_data = window.psm_timer_data || {
                    version: '1.1',
                    createdAt: new Date().toISOString(),
                    marks: [],       // {label,type:'start'|'end'|'note', t, at, value?}
                    durations: {},   // label -> total ms
                    startTimes: {},  // label -> start timestamp
                    meta: {          // include fingerprint-specific info here
                      dealerId: 26565,
                      dealerGuid: 'e0dd12b85803459184a7741e7e21b4a1',
                      fp: {
                        token: '8SMYTmlRdqyGTGMYPwF5',
                        endpointUsed: 'https://metrics.psmmarketing.com', // dynamic import endpoint
                        importMs: null,
                        loadMs: null,
                        getMs: null,
                        requestTag: null,
                        visitorId: null,
                        errors: []
                      }
                    }
                  };
                  window.psm_timer = window.psm_timer || (function(){
                    const d = window.psm_timer_data;
                    function now(){ return (window.performance && performance.now) ? performance.now() : Date.now(); }
                    function start(label){
                      d.startTimes[label] = now();
                      d.marks.push({label, type:'start', t:d.startTimes[label], at:new Date().toISOString()});
                    }
                    function end(label){
                      var s = d.startTimes[label];
                      if (typeof s === 'number'){
                        var dur = now() - s;
                        d.durations[label] = (d.durations[label]||0) + dur;
                        delete d.startTimes[label];
                        d.marks.push({label, type:'end', t:dur, at:new Date().toISOString()});
                        return dur;
                      }
                      return 0;
                    }
                    function note(label, value){
                      d.marks.push({label, type:'note', t:0, value:value, at:new Date().toISOString()});
                    }
                    function print(){
                      const rows = Object.keys(d.durations).sort().map(k => ({ label:k, ms: Math.round(d.durations[k]) }));
                      console.groupCollapsed('%cPSM Timer','font-weight:bold');
                      if (rows.length) console.table(rows); else console.log('No durations yet.');
                      console.log('meta:', d.meta);
                      console.log('marks:', d.marks);
                      console.groupEnd();
                    }
                    return { start, end, note, print };
                  })();
                  window.psmTimer = function(){ return window.psm_timer_data; };

                  // ---------- YOUR GENERATED SCRIPT (unchanged) ----------
                   if (document.createStyleSheet) { document.createStyleSheet('/css/PDLFooter.css?vs=4'); } else { var child2 = document.createElement("div"); child2.innerHTML = "<link rel='stylesheet' href='/css/PDLFooter.css?vs=4' type='text/css' media='screen' />"; if(document.getElementsByTagName('body')[0] == null){document.getElementsByTagName('head')[0].appendChild(child2); } else {document.getElementsByTagName('body')[0].appendChild(child2); }} var convert = {toNumber: function(str) {return str.replace(/[^0-9]/gi, '');},toTenDigits: function(str) {return str.substring(0, 10);}};function getPSMCookie(c_name) { var c_value = document.cookie; var c_start = c_value.indexOf(' ' + c_name + '='); if (c_start == -1) { c_start = c_value.indexOf(c_name + '='); } if (c_start == -1) { c_value = null; } else { c_start = c_value.indexOf('=', c_start) + 1; var c_end = c_value.indexOf(';', c_start); if (c_end == -1) { c_end = c_value.length; } c_value = unescape(c_value.substring(c_start,c_end)); } return c_value; } function getInventoryUpdatesMakeValue() { var makeIntValue = document.getElementById('PSM-IU-Make'); if (!makeIntValue || makeIntValue.selectedIndex < 0) return ''; var makeTextValue = makeIntValue.options[makeIntValue.selectedIndex].text; var removeMakeSpecialChars = makeTextValue.replace(/[©®™℠]/g,'').replace(/\s{2,}/g,' ').trim(); return removeMakeSpecialChars.length ? removeMakeSpecialChars : makeTextValue; } var divPSMPriceDropMain = document.createElement("div"); var html = "<!-- The Price Drop Modal --><div id='modal-psm-pricedrop' class='psm-pricedrop' style='display: none'><!-- Price Drop Modal content --><div class='psm-pricedrop-content'><span id='btnPSMPriceDropClose' class='psm-pricedrop-close'>&times;</span><div class='psm-pricedrop-header'>GET PRICE DROP ALERTS</div><div class='psm-pricedrop-text' id='div-psm-pricedrop-text'>Provide your details to receive an email and/or text alert when the price drops on this unit.</div><div id='div-pricedrop-form' class='div-pricedrop-form'><div class='PD-row'><div class='PD-input-group'><input type='text' id='PSM-PD-FirstName' class='PD-form-input' placeholder='First Name*' required /><span id='pd-error-firstname' class='PD-error-msg'></span></div><div class='PD-input-group'><input type='text' id='PSM-PD-LastName' class='PD-form-input' placeholder='Last Name*' required /><span id='pd-error-lastname' class='PD-error-msg'></span></div></div><div class='PD-row'><div class='PD-input-group'><input type='text' id='PSM-PD-Email' class='PD-form-input' placeholder='Email*' required /><span id='pd-error-email' class='PD-error-msg'></span></div><div class='PD-input-group'><input type='text' id='PSM-PD-Phone' class='PD-form-input' placeholder='Phone*' maxlength='10' /><span id='pd-error-phone' class='PD-error-msg'></span></div></div><div class='psm-pricedrop-alert'><label for='PSM-PD-Type'>Alert Preference<span class='required'>*</span></label><div><div><label for='PSM-PD-EmailType' style='font-weight: normal !Important;'>Email</label><input type='checkbox' checked id='PSM-PD-EmailType' value='Email' /></div><div><label for='PSM-PD-PhoneType' style='font-weight: normal !Important;'>Text</label><input type='checkbox' checked id='PSM-PD-TextType' value='Text' /></div></div><p class='legalize'><i>I agree to receive text messages at the number provided. Message and data rates apply.</i><br /><i>Use of your information is governed by our <a href='https://www.rivasuperstore.com/read-our-privacy-statement--xprivacy'>Privacy Policy</a>.</i></p><button id='psm-PD-FormSubmit' class='PD-FormSubmit'>Sign Up</button><div id='PD-validation' class='PD-validation'></div></div></div><div id='div-pd-success-message' class='div-pd-success-message' style='display: none'>Sending....<div class='lds-ellipsis'><div></div></div></div>"; const pdunits = ['13030942','14438499','13793162','15179768','15055800','13361116','15089066','15028811','13398987','15179725','13295488','14568935','14692029','13092940','13756533','15179748','14898224','15179727','14665947','15106270','13379550','15106284','14144739','14692027','14619497','15044452','14987749','14262250','13494235','14911529','15028798','15127269','14558904','14720362','14995955','14911536','14413976','13793159','14274893','14677117','14677120','14458720','13003775','13464752','13239624','13793150','14458712','14274897','14813884','14755557','15179743','14971499','15179718','14987748','14024466','15007541','14619498','14995933','14911546','15089052','15206790','15055791','14975334','13221457','14144720','14144737','14613148','12225436','14649443','14783655','14862172','13422779','13825766','14204911','15007542','14987747','15179737','14649435','13361092','15089061','15089068','14018413','14881920','14726718','15044442','14982435','14661503','14677118','15213598','14126276','14144731','15179728','12773853','14657815','14995956','14694195','15120437','15179731','14619507','15120439','15028819','14448351','14661506','14947706','15044435','15044422','14881918','14060314','15179765','14739448','14968524','13075203','14953169','14720353','14995945','15113377','14881913','14558905','14975333','15055795','15028816','14006612','15055798','14968525','14317865','14726720','15113378','14024514','15213594','15044423','15055799','15106281','13691291','13896029','13411955','14911540','14677113','14144721','15179758','15007540','15089063','13793152','15024103','15028815','13205605','14216298','14703726','15213606','15055797','14841251','14991141','13716011','13379551','13586113','14274885','14677275','14862167','14024515','14995947','14755551','15179733','13282554','14987752','14755552','14144722','12938350','15024113','15243401','15179724','13793148','14813897','14924147','15179744','15243412','14014318','13504094','14720351','15179739','13258401','14862170','15089064','14813893','14903446','14726717','14797841','15044440','15061223','15071367','14280200','14018419','14898211','14589701','15044434','14755559','14875779','14875789','15028801','14144719','13158341','15243413','14995953','13756534','14875782','14875783','14619499','15243411','12552271','14971500','14266692','15196895','15179745','13571391','14953166','15127264','15213591','14924128','15106277','15028808','15106282','15028802','15106285','15179717','13422772','14898228','14881915','13745986','15127275','13571398','13851437','15028812','14448364','14045921','15179732','14541383','14494259','13314631','14482997','15250463','14987766','14748898','14597197','15127279','15213602','15213596','13571396','15089054','15089071','14448357','14677115','13903113','15098812','14924144','13908657','15106274','14494257','13361101','14649437','15136200','14898230','13586112','14126286','15044427','14661509','14694196','13818324','15196891','13494232','14881919','14500639','14458725','14924152','12617070','14133416','14458726','15213601','14862173','15089070','14694204','15213588','15028800','15044433','15179734','15044426','12938354','12980854','14619505','15196893','14898236','13532367','14448363','15136202','15179750','13258405','14797839','15024098','14748895','14409171','12938339','14409178','15089047','14726716','14558902','14748903','14448362','14769844','15044437','14924136','14448356','14813895','14924131','14402156','15044429','14018402','14898219','14413975','15179735','14720357','15048840','13793163','12980856','15044424','14841253','14117811','14482996','14018417','14164173','14018405','15044443','14448360','13557462','15179769','14971498','14953164','15127272','15071371','14335077','15179763','14458724','15113376','14995959','14144742','13725962','15028805','15044439','15028814','14310218','14266687','14936257','14151762','14458722','14677114','14300010','13825764','14018407','15044444','14875778','14574039','14661513','14924134','14739447','15089057','14558920','14392253','13810009','14086345','15007543','13557484','14661511','14052227','14677280','14898232','14597199','13846240','14762621','14748894','14024516','14133427','13355672','14458727','15179749','13282545','14619501','14783654','13092946','13846241','14987751','14875788','13109764','13810008','15089059','14126287','14777880','15213590','15024108','15243403','14971497','15028807','15243406','14898237','15028799','11796194','14642540','14599687','14039381','14448367','14171046','14726722','13282546','14433339','12938349','13932599','14164179','13422770','14968522','15024107','14987754','13542185','14813879','14216299','13205604','14409174','14898235','14558916','14995958','15179770','14144718','14911535','14024464','13205629','14987746','15089065','13282547','14677274','13629248','14739450','15028817','14898215','15024109','14836070','14140650','15127266','13825765','13092949','14619503','14816549','13314630','13793167','15243410','14657788','15028797','14924148','15089062','14216300','13494231','15196892','14657771','14373506','14164184','15044432','14881910','15213599','14657818','12404783','14851944','14748896','14086341','15055802','15028813','13335677','13825767','14151768','14574053','14677277','14755569','14494263','15120440','14657772','15213597','14649441','14720360','15071373','15098816','14423622','14458732','14947704','14692028','13061603','14875796','15055796','15243408','14911541','14185119','14813891','15127282','14314175','14813885','15028804','13793156','14924151','14982446','14748908','14862175','14126304','15071372','13485142','14458713','13335676','14151768','14052230','13190240','14982444','13988384','13335678','14924133','15007538','14413977','15028818','15055793','14982443','14185109','14274892','14898221','14813892','14777881','15179754','15089074','14971504','13003773','14797840','13765171','14185123','13454955','15127267','14677116','15024096','14392254','14126309','14018408','14661505','12905669','14971502','15179756','14755562','15089060','12864825','15055804','15001624','14086340','14987750','13422789','14300011','14280199','13825763','15127280','13494241','14982439','15213595','15127270','14024461','14649429','15106273','13473624','15055794','14541374','14574054','14589700','14924154','15213604','15213605','14813896','13532361','14862166','15179742','15089051','15089072','14995951','14574051','14024510','14953168','14574038','14630516','14755567','14357098','14126302','13030920','14661514','15243407','14104230','14458728','15179716','14793248','14726714','15089048','13846242','15127263','14875784','14911530','14574046','12404782','14500638','14619500','14982436','15127274','14151761','14836072','14657813','13464754','14898214','14991140','13335675','14813889','15179747','15127261','13818330','15127265','15106278','14433342','14987757','14898216','14995940','14126279','14982441','13586114','14953167','15089067','14448348','14398821','14649442','14018416','14558901','14018412','14924150','14995952','15024104','15106279','15179736','15019555','13061599','15089049','14458718','15179759','13586115','14478510','14924156','15106275','14661510','14677278','15007536','14755550','14971496','13825753','15243404','13571393','15179751','14558914','12938336','14448361','14018418','14816550','15243405','13485129','14898220','14335079','14619502','15127281','15213603','15098810','15071369','15196894','14126278','15098811','15189318','15044425','14052234','12972900','14024463','14409177','14661512','14144732','14458729','14793247','14862168','14898223','15127262','14968523','15177691','15177747','14875780','15237911','14748901','14039383','15089058','13771054','14982445','15127273','14677110','13239622','14862169','14875787','15179740','13282555','13716009','15089050','14164183','14898234','12972898','14104228','14677276','14312587','15179746','15098815','14409173','14262247','14694197','15028810','14448369','14144734','14875785','15044436','13030934','13230025','14982438','14777879','13295491','14574041','14797843','11900750','14024465','14816548','14898231','14558907','14720361','13793149','14841255','14971501','12574333','14448354','15106280','14126277','14862171','12773854','14558913','14024513','14458719','15179761','15177497','14649436','15127276','15177467','14875791','14995939','14126305','14898239','15237908','13793160','14171045','15044428','14433340','15179723','15106272','15044438','14314172','14692025','15084301','13205598','14144733','14995954','13422775','15127290','14881914','15213607','14911539','14924153','15044441','14541380','15028803','14881917','15089053','14898238','13793161','14911531','13030950','14122913','15028809','15179738','15007544','15176499','13494237','14898218','15127283','14726723','15106276','13994411','13494238','15089069','15213593','15106286','15044430','14541379','14164178','14898217','14813883','14813894','14881916','13494240','14208320','14862174','14875790','12938351','14726719','14755561','14677119','14971503','15061222','12938356','13756526','13494242','14924155','14574048','14755560','14875786','14309111','15028806','14458715','14448368','14151767','14385779','14898209','14692024','14494258','13771055','13725961','14875781','13557479','15055801','15213600','14903447','14875794','14987743','13994414','15098813','14458723','15179741','13003785','14060313','14982434','15001628','13504095','13793164','13960690','13271741','14024467','15089073'];divPSMPriceDropMain.innerHTML = html; document.body.appendChild(divPSMPriceDropMain); var psmPriceDropCSS = document.createElement("div"); psmPriceDropCSS.innerHTML = "<link rel='stylesheet' href='/css/psmPriceDrop.css?v=13' type='text/css' media='screen' />"; if(document.getElementsByTagName('body')[0] == null) {document.getElementsByTagName('head')[0].appendChild(psmPriceDropCSS);  } else {document.getElementsByTagName('body')[0].appendChild(psmPriceDropCSS); } var psmSubmitted = 0; document.addEventListener('click', function(e) { if(e.target && e.target.id === 'modal-psm-pricedrop') { var divPDModal = document.getElementById('modal-psm-pricedrop'); if(divPDModal) { if(divPDModal.style.display === 'block') { divPDModal.style.display = 'none'; }  if(psmSubmitted === 1) { resetPriceDropForm(); var successElement = document.getElementById("div-pd-success-message"); successElement.style.display = "none"; var elementContentForm = document.getElementById("div-pricedrop-form"); elementContentForm.style.display = "block"; var elementPriceDropText = document.getElementById("div-psm-pricedrop-text"); elementPriceDropText.style.display = "block"; }  } } }); document.addEventListener('click', function(e){ if(e.target && e.target.id== 'btnPSMPriceDropClose') { var divPDModal = document.getElementById('modal-psm-pricedrop'); if(divPDModal) { if(divPDModal.style.display === 'block') { divPDModal.style.display = 'none'; }  if(psmSubmitted === 1) { resetPriceDropForm(); var successElement = document.getElementById("div-pd-success-message"); successElement.style.display = "none"; var elementContentForm = document.getElementById("div-pricedrop-form"); elementContentForm.style.display = "flex"; var elementPriceDropText = document.getElementById("div-psm-pricedrop-text"); elementPriceDropText.style.display = "block"; }  } } }); var alertTypeTextCheckbox = document.getElementById('PSM-PD-TextType');var phoneInput = document.getElementById('PSM-PD-Phone'); alertTypeTextCheckbox.addEventListener('change', function() { if (alertTypeTextCheckbox.checked) { phoneInput.setAttribute('placeholder', 'Phone*'); } else { phoneInput.setAttribute('placeholder', 'Phone');}});var psmPDUnitId; var psmPDUnitUrl; var psmPDUnitImageUrl; var psmPDUnitName; var psmPDUnitPrice; function showPSMPDModal() { var divPDModal = document.getElementById('modal-psm-pricedrop'); if(divPDModal) { if(divPDModal.style.display === 'none' || divPDModal.style.display === '') { divPDModal.style.display = 'block'; } psmPDUnitId = this.getAttribute('data-psm-unitid'); psmPDUnitUrl = this.getAttribute('data-psm-uniturl'); psmPDUnitName = this.getAttribute('data-psm-unitname'); psmPDUnitPrice = this.getAttribute('data-psm-unitprice'); psmPDUnitImageUrl = this.getAttribute('data-psm-unitimageurl'); psmSendPriceDropTealiumEvent('ua_price_drop_alert_load', psmPDUnitId, psmPDUnitUrl, psmPDUnitName, psmPDUnitPrice, psmPDUnitImageUrl); } event.stopPropagation(); } window.addEventListener('load', loadPDWidgets, false); window.addEventListener('DOMContentLoaded', loadPDWidgets); function loadPDWidgets() { var elementSRPOpenerWidgets = document.getElementsByClassName('psm-pricedrop-srp-widget'); for (var i=elementSRPOpenerWidgets.length; i--;) { elementSRPOpenerWidgets[i].innerHTML = 'Price Drop Alert'; elementSRPOpenerWidgets[i].style.backgroundColor = '#0135A2'; elementSRPOpenerWidgets[i].classList.add('psm-PD-ButtonType'); elementSRPOpenerWidgets[i].style.color = '#FFFFFF'; elementSRPOpenerWidgets[i].onclick = showPSMPDModal; if (elementSRPOpenerWidgets[i].dataset.psmUnitid == '12346'){elementSRPOpenerWidgets[i].style.display =  'block'; }else { elementSRPOpenerWidgets[i].style.display = pdunits.includes(elementSRPOpenerWidgets[i].dataset.psmUnitid) ?'block':'none';}} var elementVDPOpenerWidgets = document.getElementsByClassName('psm-pricedrop-vdp-widget'); for (var i=elementVDPOpenerWidgets.length; i--;) { elementVDPOpenerWidgets[i].innerHTML = 'Price Drop Alert'; elementVDPOpenerWidgets[i].style.backgroundColor = '#0135A2'; elementVDPOpenerWidgets[i].classList.add('psm-PD-ButtonType'); elementVDPOpenerWidgets[i].style.color = '#FFFFFF'; elementVDPOpenerWidgets[i].onclick = showPSMPDModal; if (elementVDPOpenerWidgets[i].dataset.psmUnitid == '12345'){elementVDPOpenerWidgets[i].style.display =  'block'; }else{elementVDPOpenerWidgets[i].style.display = pdunits.includes(elementVDPOpenerWidgets[i].dataset.psmUnitid) ?'block':'none';}} } function loadPDWidget(element) { try {element.innerHTML = 'Price Drop Alert'; element.style.backgroundColor = '#0135A2'; element.classList.add('psm-PD-ButtonType'); element.style.color = '#FFFFFF'; element.onclick = showPSMPDModal; if (pdunits.length > 0 && pdunits!==undefined && pdunits!==null && pdunits[0] != '') {element.style.display =  pdunits.includes(element.dataset.psmUnitid) ?'block':'none'; } } catch (error) { console.warn('An error occurred while processing elements:', error);}} var loadPDScript = document.createElement("script"); loadPDScript.innerHTML = " function showPSMPDModal() { var divPDModal = document.getElementById('modal-psm-pricedrop'); if(divPDModal) { if(divPDModal.style.display === 'none' || divPDModal.style.display === '') { divPDModal.style.display = 'block'; } psmPDUnitId = this.getAttribute('data-psm-unitid'); psmPDUnitUrl = this.getAttribute('data-psm-uniturl'); psmPDUnitName = this.getAttribute('data-psm-unitname'); psmPDUnitPrice = this.getAttribute('data-psm-unitprice'); psmPDUnitImageUrl = this.getAttribute('data-psm-unitimageurl'); psmSendPriceDropTealiumEvent('ua_price_drop_alert_load', psmPDUnitId, psmPDUnitUrl, psmPDUnitName, psmPDUnitPrice, psmPDUnitImageUrl); } event.stopPropagation(); } var elementSRPOpenerWidgets = document.getElementsByClassName('psm-pricedrop-srp-widget'); for (var i=elementSRPOpenerWidgets.length; i--;) { elementSRPOpenerWidgets[i].innerHTML = 'Price Drop Alert'; elementSRPOpenerWidgets[i].style.backgroundColor = '#0135A2'; elementSRPOpenerWidgets[i].classList.add('psm-PD-ButtonType'); elementSRPOpenerWidgets[i].style.color = '#FFFFFF'; elementSRPOpenerWidgets[i].onclick = showPSMPDModal; if (elementSRPOpenerWidgets[i].length > 0 && elementSRPOpenerWidgets[i]!==undefined && elementSRPOpenerWidgets[i]!==null) {elementSRPOpenerWidgets[i].style.display =elementSRPOpenerWidgets[i].dataset.psmUnitid ?'block':'none';} } var elementVDPOpenerWidgets = document.getElementsByClassName('psm-pricedrop-vdp-widget'); for (var i=elementVDPOpenerWidgets.length; i--;) { elementVDPOpenerWidgets[i].innerHTML = 'Price Drop Alert'; elementVDPOpenerWidgets[i].style.backgroundColor = '#0135A2'; elementVDPOpenerWidgets[i].classList.add('psm-PD-ButtonType'); elementVDPOpenerWidgets[i].style.color = '#FFFFFF'; elementVDPOpenerWidgets[i].onclick = showPSMPDModal; if (elementVDPOpenerWidgets[i].length > 0 && elementVDPOpenerWidgets[i]!==undefined && elementVDPOpenerWidgets[i]!==null) {elementVDPOpenerWidgets[i].style.display = elementVDPOpenerWidgets[i].dataset.psmUnitid ?'block':'none';} } "; if(document.getElementsByTagName('body')[0] == null) {document.getElementsByTagName('head')[0].appendChild(loadPDScript); } else {document.getElementsByTagName('body')[0].appendChild(loadPDScript); } var submitButtonPriceDrop = document.getElementById('psm-PD-FormSubmit');submitButtonPriceDrop.style.background = '#0135A2'; submitButtonPriceDrop.style.color = '#FFFFFF'; submitButtonPriceDrop.style.padding = '10px'; submitButtonPriceDrop.style.borderRadius = '10px'; submitButtonPriceDrop.onclick = function () { submitPriceDropForm(); };document.getElementById('PSM-PD-Phone').addEventListener('keyup', (event) => {document.getElementById('PSM-PD-Phone').value = convert.toNumber(document.getElementById('PSM-PD-Phone').value);});validatePriceDropForm = function(firstName, lastName, number, email,alertType) {var validationArea = document.getElementById("PD-validation"); validationArea.style.color = "red";var validationMessage = ""; var isValid = true; document.getElementById('PSM-PD-FirstName').classList.remove('error'); document.getElementById('PSM-PD-LastName').classList.remove('error'); document.getElementById('PSM-PD-Phone').classList.remove('error'); document.getElementById('PSM-PD-Email').classList.remove('error'); document.getElementById('PSM-PD-EmailType').classList.remove('error');if (firstName == undefined || firstName == null || firstName.trim().length == 0) { document.getElementById('pd-error-firstname').innerText = 'First Name is required.';document.getElementById('PSM-PD-FirstName').classList.add('error');isValid = false;} else {document.getElementById('pd-error-firstname').innerText = '';document.getElementById('PSM-PD-FirstName').classList.remove('error');}if (lastName == undefined || lastName == null || lastName.trim().length == 0) { document.getElementById('pd-error-lastname').innerText = 'Last Name is required.';document.getElementById('PSM-PD-LastName').classList.add('error');isValid = false;} else {document.getElementById('pd-error-lastname').innerText = '';document.getElementById('PSM-PD-LastName').classList.remove('error');}var emailInValid = (email == undefined || email == null || email.trim().length == 0);if (emailInValid){document.getElementById('pd-error-email').innerText = 'Email is required.';document.getElementById('PSM-PD-Email').classList.add('error');isValid = false;} else if (!/^\S+@\S+\.\S+$/.test(email)) {document.getElementById('pd-error-email').innerText = 'Please enter a valid email address.';document.getElementById('PSM-PD-Email').classList.add('error');isValid = false;} else {document.getElementById('pd-error-email').innerText = '';document.getElementById('PSM-PD-Email').classList.remove('error');}if(alertType === '') { validationMessage += "To receive alerts, please select at least one preference: Email, Text, or both.. <br>";document.getElementById('PSM-PD-EmailType').classList.add('error');isValid = false;}if (alertType.includes('Text')) {if (number == undefined || number == null || number.trim().length == 0) {document.getElementById('pd-error-phone').innerText = 'Phone Number is required.';document.getElementById('PSM-PD-Phone').classList.add('error');isValid = false;} else if (number.trim().charAt(0) == '1') {document.getElementById('pd-error-phone').innerText = 'Phone Number cannot start with 1.';document.getElementById('PSM-PD-Phone').classList.add('error');isValid = false;} else {document.getElementById('pd-error-phone').innerText = '';document.getElementById('PSM-PD-Phone').classList.remove('error');}} else {document.getElementById('pd-error-phone').innerText = '';document.getElementById('PSM-PD-Phone').classList.remove('error');}validationArea.innerHTML = validationMessage;return isValid;}; function resetPriceDropForm() {	document.getElementById('PSM-PD-FirstName').value = '';	document.getElementById('PSM-PD-LastName').value = '';	document.getElementById('PSM-PD-Phone').value = '';	document.getElementById('PSM-PD-Email').value = ''; document.getElementById('PSM-PD-FirstName').classList.remove('error'); document.getElementById('PSM-PD-LastName').classList.remove('error'); document.getElementById('PSM-PD-Phone').classList.remove('error'); document.getElementById('PSM-PD-Email').classList.remove('error'); psmSubmitted = 0; } function submitPriceDropForm() {		var dealerGuid = 'e0dd12b85803459184a7741e7e21b4a1'; var firstName = document.getElementById('PSM-PD-FirstName').value; var lastName = document.getElementById('PSM-PD-LastName').value; var phoneNumber = document.getElementById('PSM-PD-Phone').value; var email = document.getElementById('PSM-PD-Email').value; var emailType = document.getElementById('PSM-PD-EmailType').checked ? document.getElementById('PSM-PD-EmailType').value : '';var textType = document.getElementById('PSM-PD-TextType').checked ? document.getElementById('PSM-PD-TextType').value : '';var alertType = ''; if((emailType === 'Email' && textType === 'Text')) {alertType += 'EmailText';}else {if((emailType === 'Email')) { alertType += 'Email'; } if(textType === 'Text') { alertType += 'Text'; } }if (validatePriceDropForm(firstName, lastName, phoneNumber, email,alertType)) { var successElement = document.getElementById("div-pd-success-message"); successElement.style.display = "block"; var elementContentForm = document.getElementById("div-pricedrop-form"); elementContentForm.style.display = "none"; var elementPriceDropText = document.getElementById("div-psm-pricedrop-text"); elementPriceDropText.style.display = "none"; var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://api.customerconnections.io/api/PSM/PriceDropSubcriber/', true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('X-Referer', location.href); xhr.onreadystatechange = function (oEvent) { if (xhr.readyState === 4) { if (xhr.status === 200) { var sendResponse = JSON.parse(xhr.responseText); if (typeof(ProcessPSMCallbackInfo) != 'undefined' && ProcessPSMCallbackInfo != null) { ProcessPSMCallbackInfo(sendResponse); } psmSubmitted = 1; psmSendPriceDropTealiumEvent('ua_price_drop_alert_submit', psmPDUnitId, psmPDUnitUrl, psmPDUnitName, psmPDUnitPrice, psmPDUnitImageUrl); console.log(sendResponse.Message);successElement.innerHTML = sendResponse.Message; const fpPromise = new Promise((resolve, reject) => { const script = document.createElement('script'); script.onload = resolve; script.onerror = reject; script.async = true; script.src = 'https://cdn.jsdelivr.net/npm/@fingerprintjs/fingerprintjs-pro@3/dist/fp.min.js'; document.head.appendChild(script); }).then(() => FingerprintJS.load({ token: '8SMYTmlRdqyGTGMYPwF5', endpoint: 'https://metrics.psmmarketing.com' })); const requestMetadata = { custid: sendResponse.CustomerId, requestType: 'Price Drp' }; fpPromise.then(fp => fp.get({ tag: requestMetadata })) } else { var validationArea = document.getElementById('PD-validation');validationArea.innerHTML = 'Error with Submission, please try again...'; successElement.style.display = "none"; elementContentForm.style.display = "block"; elementPriceDropText.style.display = "block"; } } }; xhr.send(JSON.stringify({ DealerGuid: dealerGuid, FirstName: firstName,LastName: lastName,PhoneNumber: convert.toNumber(phoneNumber), Email: email, AlertType: alertType, UnitName: psmPDUnitName, UnitId: psmPDUnitId, UnitURL: psmPDUnitUrl, UnitImageURL: psmPDUnitImageUrl, CurrentPrice: psmPDUnitPrice }));};} var divPSInventoryUpdateMain = document.createElement("div"); var html = "<div id='div-psm-inventoryupdate-content' class='psm-inventoryupdate-content' style='background: linear-gradient(to bottom, #FF0000, #FF0000 70%); color:#FFFFFF;'><div id='div-psm-inventoryupdate-content-close' style='display: none;'>X</div><h9 id='psm-inventoryupdate-header'>[HeadlineText]</h9><div id='div-inventoryupdate-form' class='div-inventoryupdate-form' style='background-color: #B20000;'><table><tr><td><div class='div-inventoryupdate-header'><p>[ModalFormHeaderText]</p></div></td><td><table><tr><td><label for='PSM-IU-FirstName'>First Name<span class='required'>*</span></label><br /> <input type='text' id='PSM-IU-FirstName' placeholder='First Name*' required='required' aria-label='First Name' /></td><td><label for='PSM-IU-LastName'>Last Name<span class='required'>*</span></label><br /><input type='text' id='PSM-IU-LastName' placeholder='Last Name*' required='required' aria-label='Last Name' /></td></tr><tr><td><label for='PSM-IU-Email'>Email Address<span class='required'>*</span></label><br /><input type='text' id='PSM-IU-Email' placeholder='Email*' required='required' aria-label='Email Address' /></td><td><label for='PSM-IU-Phone'>Cell Phone Number<span class='required'>*</span></label><br /><input type='text' id='PSM-IU-Phone' placeholder='Phone' maxlength='10' required='required' aria-label='Phone Number' /></td></tr><tr><td><label for='PSM-IU-Category'>Category<span class='required'>*</span></label><br /><select id='PSM-IU-Category' name='PSM-IU-Category' placeholder='Category*' required='required' aria-label='Category'><option value='-1'>All Categories</option><option value='3'>ATV</option><option value='2'>Motorcycle</option><option value='23'>Scooter</option><option value='1'>UTV</option><option value='4'>Watercraft</option></select></td><td><label for='PSM-IU-Make'>Make<span class='required'>*</span></label><br /><select id='PSM-IU-Make' name='PSM-IU-Make' placeholder='Make*' required='required' aria-label='Make'><option value='-1'>All Makes</option><option value='8087'>AA Test</option><option value='349'>AlphaSports</option><option value='8063'>Alta</option><option value='350'>American IronHorse</option><option value='8138'>American Landmaster</option><option value='8209'>American Lifan</option><option value='8132'>Apollo</option><option value='20'>Aprilia</option><option value='25'>Arctic Cat</option><option value='8248'>Argo</option><option value='1627'>Benelli</option><option value='811'>Bennche</option><option value='857'>BETA</option><option value='405'>Big Bear Choppers</option><option value='365'>Big Dog</option><option value='8210'>Bighorn Powersports</option><option value='12'>BMW</option><option value='48'>Bobcat®</option><option value='26'>Bombardier™</option><option value='831'>Brammo</option><option value='15'>Buell</option><option value='829'>California Scooter Co.</option><option value='389'>Can-Am™</option><option value='852'>Case IH</option><option value='1370'>CFMOTO</option><option value='2062'>Chicago Scooter Co.</option><option value='8127'>Club Car</option><option value='8215'>CobraMoto</option><option value='1526'>CSC Motorcycles</option><option value='45'>Cub Cadet</option><option value='8020'>Cushman</option><option value='24'>Ducati</option><option value='1457'>Erik Buell Racing</option><option value='373'>E-TON</option><option value='8019'>EZ Go</option><option value='8283'>Fantic</option><option value='408'>Fischer</option><option value='830'>Flyscooters</option><option value='858'>GASGAS</option><option value='8026'>GEM</option><option value='479'>Genuine Scooter Co.</option><option value='8118'>Gravely</option><option value='8256'>Greenger Powersports</option><option value='10'>Harley-Davidson</option><option value='1528'>Hisun</option><option value='2'>Honda</option><option value='399'>Husaberg</option><option value='330'>Husqvarna</option><option value='390'>Hyosung</option><option value='423'>Indian Motorcycle®</option><option value='8206'>Intimidator</option><option value='36'>John Deere</option><option value='3'>Kawasaki</option><option value='8196'>Kayo</option><option value='850'>KIOTI</option><option value='21'>KTM</option><option value='47'>Kubota</option><option value='27'>KYMCO</option><option value='770'>Lambretta</option><option value='828'>Lance</option><option value='8162'>Lance Powersport</option><option value='372'>Land Pride</option><option value='1978'>LiveWire™</option><option value='848'>Mahindra</option><option value='8165'>Massimo Motor</option><option value='8226'>Minimotors Electric Scooter</option><option value='22'>Moto Guzzi</option><option value='1525'>Motus</option><option value='391'>MV Agusta</option><option value='331'>MZ</option><option value='849'>New Holland</option><option value='2061'>NIU</option><option value='348'>Norton</option><option value='792'>Peirspeed</option><option value='17'>Piaggio</option><option value='8143'>Piranha</option><option value='23'>Polaris</option><option value='406'>QLINK</option><option value='8088'>Roxor</option><option value='2063'>Royal Alloy</option><option value='1340'>Royal Enfield</option><option value='826'>Saxon Motorcycle</option><option value='398'>Schwinn</option><option value='8289'>Scorpa</option><option value='28'>Sea-Doo</option><option value='8217'>Segway</option><option value='2049'>Segway Powersports</option><option value='8146'>Sherco</option><option value='1623'>SSR Motorsports</option><option value='8281'>Stark</option><option value='8267'>Stealth</option><option value='8231'>Surron</option><option value='4'>Suzuki</option><option value='8233'>SWM</option><option value='480'>SYM</option><option value='1618'>Textron Off Road</option><option value='8276'>TM Racing</option><option value='388'>Tomberlin™</option><option value='771'>Tomos</option><option value='8096'>Tracker Off Road </option><option value='2052'>TRACKER® OFF ROAD</option><option value='8189'>TrailMaster</option><option value='16'>Triumph</option><option value='392'>United Motors</option><option value='327'>Ural</option><option value='8083'>Vanderhall</option><option value='754'>Vectrix</option><option value='328'>Vento</option><option value='18'>Vespa</option><option value='11'>Victory</option><option value='8133'>Vitacci </option><option value='8234'>Volcon ePowersports</option><option value='8115'>Wolf Brand</option><option value='1'>Yamaha</option><option value='8038'>Yamaha Power</option><option value='8141'>YCF</option><option value='827'>Zero</option></select></td></tr><tr><td><label for='PSM-IU-Status'>Condition<span class='required'>*</span></label><br /><select id='PSM-IU-Status' name='PSM-IU-Status' placeholder='Status*' required='required' aria-label='Status'><option value='All' selected>All</option><option value='New'>New</option><option value='Used'>Used</option></select></td><td><label for='PSM-IU-Type'>Type<span class='required'>*</span></label><br /><select id='PSM-IU-Type' name='PSM-IU-Type' placeholder='Status*' required='required' aria-label='Type'><option value='EmailText' selected>Email & Text</option><option value='Email'>Email Only</option><option value='Text'>Text Only</option></select></td></tr><tr><td colspan='2'><p class='legalize'><i>I agree to receive text messages at the number provided. Message and data rates apply.</i><br /><i>Use of your information is governed by our <a href='https://www.rivasuperstore.com/read-our-privacy-statement--xprivacy'>Privacy Policy</a>.</i></p><button id='psm-IU-FormSubmit' class='IU-FormSubmit'>Sign Up</button><div id='IU-validation' class='IU-validation'></div></td></tr></table></td></tr></table></div><div id='div-iu-success-message' class='div-iu-success-message'>Sending....<div class='lds-ellipsis'><div></div></div>"; html = html.replace('[HeadlineText]', 'Get Inventory Updates'); html = html.replace('[ModalFormHeaderText]', 'Provide your information to receive an email alert when products that meet your needs are in stock.'); divPSInventoryUpdateMain.innerHTML = html; var psInventoryUpdateCSS = document.createElement("div"); psInventoryUpdateCSS.innerHTML = "<link rel='stylesheet' href='/css/psmInventoryUpdate.css?vs=15' type='text/css' media='screen' />"; if(document.getElementsByTagName('body')[0] == null) {document.getElementsByTagName('head')[0].appendChild(psInventoryUpdateCSS); } else {document.getElementsByTagName('body')[0].appendChild(psInventoryUpdateCSS); } document.body.appendChild(divPSInventoryUpdateMain); var elementContent = document.getElementById("div-psm-inventoryupdate-content"); elementContent.style.display = "block"; elementContent.style.height = "50px"; var elementOpener = document.getElementById("psm-inventoryupdate-header"); elementOpener.onclick = function () { var elementContent = document.getElementById("div-psm-inventoryupdate-content"); if (elementContent.style.height === "50px") { elementContent.style.height = "auto"; var elementCloser = document.getElementById("div-psm-inventoryupdate-content-close"); elementCloser.style.display = "block"; psmSendInventoryTealiumEvent('ua_inventory_updates_load'); } else { elementContent.style.height = "50px"; var elementClose = document.getElementById("div-psm-inventoryupdate-content-close"); elementClose.style.display = "none"; } event.stopPropagation(); document.addEventListener('click', function(event) { if (event.target.closest('.psm-inventoryupdate-content')) return; elementContent.style.height = "50px"; var elementClose = document.getElementById("div-psm-inventoryupdate-content-close"); elementClose.style.display = "none"; }); }; window.addEventListener('load', loadInventoryWidgets, false); window.addEventListener('DOMContentLoaded', (event) => { loadInventoryWidgets }); function loadInventoryWidgets() { var elementOpenerWidgets = document.getElementsByClassName("psm-inventoryupdate-widget"); for ( var i=elementOpenerWidgets.length; i--; ) { elementOpenerWidgets[i].innerHTML = '<div class="invUpdRow" > <div> <img width="50" src="https://psmfirestorm.blob.core.windows.net/3ee22f0d-ae8a-410f-b12b-cbcdc7359a3a/microphone-.png"> </div> <div> <h8>Get Inventory Updates</h8> <p><span class="emph">Sign up</span> <span class="txt">to receive an email alert when products that meet your needs are in stock.</span></p></div></div>'; elementOpenerWidgets[i].style.display = "block"; elementOpenerWidgets[i].onclick = function () { var elementContent = document.getElementById("div-psm-inventoryupdate-content"); if (elementContent.style.height === "50px") { elementContent.style.height = "auto"; var elementCloser = document.getElementById("div-psm-inventoryupdate-content-close"); elementCloser.style.display = "block"; } else { elementContent.style.height = "50px"; var elementClose = document.getElementById("div-psm-inventoryupdate-content-close"); elementClose.style.display = "none"; } event.stopPropagation(); }; } var elementOpenerWidgetsContainers = document.getElementsByClassName("invUpdRow"); for ( var i=elementOpenerWidgetsContainers.length; i--; ) { elementOpenerWidgetsContainers[i].style.backgroundColor = '#FF0000'; elementOpenerWidgetsContainers[i].style.color = '#FFFFFF'; } } var elementClose = document.getElementById("div-psm-inventoryupdate-content-close"); elementClose.onclick = function () { var elementContent = document.getElementById("div-psm-inventoryupdate-content"); elementClose.style.display = "none"; if (elementContent.style.height === "auto") { elementContent.style.height = "50px"; } event.stopPropagation(); }; var submitButtonInventory = document.getElementById('psm-IU-FormSubmit'); submitButtonInventory.style.background = '#FF0000'; submitButtonInventory.style.color = '#FFFFFF'; submitButtonInventory.style.padding = '10px'; submitButtonInventory.style.borderRadius = '10px'; submitButtonInventory.onclick = function () { submitInventoryForm(); }; document.getElementById('PSM-IU-Phone').addEventListener('keyup', (event) => { document.getElementById('PSM-IU-Phone').value = convert.toNumber(document.getElementById('PSM-IU-Phone').value); });document.getElementById('PSM-IU-Type').addEventListener('change', function () { var type = this.value; var phone = document.getElementById('PSM-IU-Phone'); var phoneLabel = document.querySelector("label[for='PSM-IU-Phone'] .required"); if (type === 'Email') { phone.removeAttribute('required'); if (phoneLabel) { phoneLabel.classList.add('hidden'); } phone.setAttribute('placeholder', 'Phone'); } else { phone.setAttribute('required', 'required'); if (phoneLabel) { phoneLabel.classList.remove('hidden'); } phone.setAttribute('placeholder', 'Phone*'); } }); validateInventoryForm = function(firstName, lastName, number, email, category, make) { var validationArea = document.getElementById("IU-validation"); var validationMessage = ""; var isValid = true; document.getElementById('PSM-IU-FirstName').classList.remove('error'); document.getElementById('PSM-IU-LastName').classList.remove('error'); document.getElementById('PSM-IU-Phone').classList.remove('error'); document.getElementById('PSM-IU-Email').classList.remove('error'); document.getElementById('PSM-IU-Make').classList.remove('error'); if (firstName == undefined || firstName == null || firstName.trim().length == 0) { validationMessage += "First Name is required. <br/>"; document.getElementById('PSM-IU-FirstName').classList.add('error'); isValid = false; } if (lastName == undefined || lastName == null || lastName.trim().length == 0) { validationMessage += "Last Name is required. <br/> ";document.getElementById('PSM-IU-LastName').classList.add('error');isValid = false;} var typeValue = document.getElementById('PSM-IU-Type').value; if (typeValue !== 'Email' && (number == undefined || number == null || number.trim().length < 10)) { validationMessage += 'Phone Number is required. <br/>'; document.getElementById('PSM-IU-Phone').classList.add('error'); isValid = false; } if (number.substring(0,1) == '1'){ validationMessage += "Invalid Phone Number. Cannot start with 1 <br/>"; document.getElementById('PSM-IU-Phone').classList.add('error'); isValid = false; } if (email == undefined || email == null || email.trim().length == 0) { validationMessage += "Email is required. <br/>"; document.getElementById('PSM-IU-Email').classList.add('error'); isValid = false; } if (make == '-1' && category == '-1') { validationMessage += "Make or Category is required.";document.getElementById('PSM-IU-Make').classList.add('error'); isValid = false; } validationArea.innerHTML = validationMessage; if (isValid) return true; else return false; }; function resetInventoryForm() {	document.getElementById('PSM-IU-Category').value = '-1';	document.getElementById('PSM-IU-FirstName').value = '';	document.getElementById('PSM-IU-LastName').value = '';	document.getElementById('PSM-IU-Phone').value = '';	document.getElementById('PSM-IU-Email').value = ''; document.getElementById('PSM-IU-Make').value = '-1'; document.getElementById('PSM-IU-Status').value = 'All'; document.getElementById('PSM-IU-Type').value = 'EmailText'; document.getElementById('PSM-IU-FirstName').classList.remove('error'); document.getElementById('PSM-IU-LastName').classList.remove('error'); document.getElementById('PSM-IU-Phone').classList.remove('error'); document.getElementById('PSM-IU-Email').classList.remove('error'); document.getElementById('PSM-IU-Make').classList.remove('error'); document.getElementById('PSM-IU-Category').classList.remove('error'); document.getElementById('PSM-IU-Status').classList.remove('error'); document.getElementById('PSM-IU-Type').classList.remove('error'); } function submitInventoryForm() {		var dealerGuid = 'e0dd12b85803459184a7741e7e21b4a1'; var firstName = document.getElementById('PSM-IU-FirstName').value; var lastName = document.getElementById('PSM-IU-LastName').value; var phoneNumber = document.getElementById('PSM-IU-Phone').value; var email = document.getElementById('PSM-IU-Email').value; var make = getInventoryUpdatesMakeValue(); var category = document.getElementById('PSM-IU-Category').value; var type = document.getElementById('PSM-IU-Type').value; var status = document.getElementById('PSM-IU-Status').value; if (validateInventoryForm(firstName, lastName, phoneNumber, email, category, make)) 	{ var successElement = document.getElementById("div-iu-success-message"); successElement.style.display = "block"; var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://api.customerconnections.io/api/PSM/InventoryUpdatesSubcriber/', true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('X-Referer', location.href); xhr.onreadystatechange = function (oEvent) { if (xhr.readyState === 4) { if (xhr.status === 200) { var sendResponse = JSON.parse(xhr.responseText); if (typeof(ProcessPSMCallbackInfo) != 'undefined' && ProcessPSMCallbackInfo != null) { ProcessPSMCallbackInfo(sendResponse); } psmSendInventoryTealiumEvent('ua_inventory_updates_submit'); resetInventoryForm(); setTimeout(function() { var successElement = document.getElementById("div-iu-success-message"); successElement.style.display = "none"; }, 10000); console.log(sendResponse.Message); successElement.innerHTML = sendResponse.Message; const fpPromise = new Promise((resolve, reject) => { const script = document.createElement('script'); script.onload = resolve; script.onerror = reject; script.async = true; script.src = 'https://cdn.jsdelivr.net/npm/@fingerprintjs/fingerprintjs-pro@3/dist/fp.min.js'; document.head.appendChild(script); }) .then(() => FingerprintJS.load({ token: '8SMYTmlRdqyGTGMYPwF5', endpoint: 'https://metrics.psmmarketing.com' })); const requestMetadata = { custid: sendResponse.CustomerId, requestType: 'Inventory Update' }; fpPromise.then(fp => fp.get({ tag: requestMetadata })) } else { var validationArea = document.getElementById('IU-validation'); validationArea.innerHTML = 'Error with Submission, please try again...'; successElement.style.display = "none"; } } }; xhr.send(JSON.stringify({ DealerGuid: dealerGuid, FirstName: firstName, LastName: lastName, PhoneNumber: convert.toNumber(phoneNumber), Email: email, Make: make, Category: category, AlertType: type, Status: status })); }; } function psmSendTealiumEvent(event) { console.log('tealium_event: ' + event); if (typeof utag_data === 'object') { var psm_event_utag = utag_data; Object.keys(psm_event_utag).forEach(function (k) { if (k.startsWith('cp.')) { delete psm_event_utag[k]; } if (k.startsWith('ut.')) { delete psm_event_utag[k]; } }); if (event === 'wr_google_click') {  psm_event_utag.website_name = 'google';  psm_event_utag.site_section = 'testimonials';  psm_event_utag.site_sub_section = 'other';}psm_event_utag.tealium_event = event; utag.link(psm_event_utag); } } function registerBoatyardCallbacks() { const dr_events = [ 'dr_load', 'signup_success', 'dr_get_quote_next_steps_click', 'dr_trade_in_added', 'dr_trade_in_photos_added', 'dr_form_submit', ]; dr_events.forEach(event => window.boatyard.registerAnalyticsCallback(event, (data) => LoadDigitalRetailing(data)) ); } function waitForBoatyardAndRegisterCallbacks(maxWaitMs = 10000, intervalMs = 100) { const start = Date.now(); const interval = setInterval(() => { if ( window.boatyard && typeof window.boatyard.registerAnalyticsCallback === 'function' ) { clearInterval(interval); console.log('Boatyard ready. Registering callbacks.'); registerBoatyardCallbacks(); } else if (Date.now() - start > maxWaitMs) { clearInterval(interval); console.warn('Timed out waiting for window.boatyard.registerAnalyticsCallback'); } }, intervalMs); } window.addEventListener('load', () => waitForBoatyardAndRegisterCallbacks()); function LoadDigitalRetailing(eventData) { const theUrl = 'https://onboard.localwebdominator.com/api/PSM/RegisterPaymentGenieEvent?DealerId=26565&DeviceId=' + PSMOnboardCookie; const eventPost = new XMLHttpRequest(); eventPost.open('POST', theUrl); eventPost.setRequestHeader('x-apiKey', 'eb094e9e-3fa7-4402-b49e-08a04c1847eb'); eventPost.setRequestHeader('Content-Type', 'application/json;charset=UTF-8'); eventPost.send(JSON.stringify(eventData)); eventPost.onload = () => { let status = eventPost.status; if (status === 200) { var data = JSON.parse(JSON.parse(eventPost.responseText)); if (data.success) { console.log('Digital Retail Event Saved for ' + PSMOnboardCookie); } else { console.log(data.message); } } else { console.log(eventPost.responseText); } } } function psmSendPriceDropTealiumEvent(event, psmPDUnitId, psmPDUnitUrl, psmPDUnitName, psmPDUnitPrice, psmPDUnitImageUrl) { console.log('tealium_event: ' + event); var psm_event_utag = {}; if (typeof utag_data === 'object') { psm_event_utag.ga4_id = utag_data.ga4_id; psm_event_utag.ga_ua_id = utag_data.ga_ua_id; psm_event_utag.page_h1 = utag_data.page_h1; psm_event_utag.page_title = utag_data.page_title; psm_event_utag.page_title_count = utag_data.page_title_count; psm_event_utag.piwik_id = utag_data.piwik_id; psm_event_utag.site_company_city = utag_data.site_company_city; psm_event_utag.site_company_name = utag_data.site_company_name; psm_event_utag.site_company_state = utag_data.site_company_state; psm_event_utag.site_company_zip_code = utag_data.site_company_zip_code; psm_event_utag.site_id = utag_data.site_id; psm_event_utag.site_internal_id = utag_data.site_internal_id; psm_event_utag.site_platform = utag_data.site_platform; psm_event_utag.site_section = utag_data.site_section; psm_event_utag.site_sub_section = utag_data.site_sub_section; psm_event_utag.site_phone_main = utag_data.site_phone_main; if (utag_data.hasOwnProperty('product_category')) {psm_event_utag.product_category = utag_data.product_category; }if (utag_data.hasOwnProperty('product_condition')) {psm_event_utag.product_condition = utag_data.product_condition; }if (utag_data.hasOwnProperty('product_custom_image_count')) {psm_event_utag.product_custom_image_count = utag_data.product_custom_image_count; }if (utag_data.hasOwnProperty('product_description_char_count')) {psm_event_utag.product_description_char_count = utag_data.product_description_char_count; }if (utag_data.hasOwnProperty('product_industry')) {psm_event_utag.product_industry = utag_data.product_industry; }if (utag_data.hasOwnProperty('product_make')) {psm_event_utag.product_make = utag_data.product_make; }if (utag_data.hasOwnProperty('product_model')) {psm_event_utag.product_model = utag_data.product_model; }if (utag_data.hasOwnProperty('product_msrp')) {psm_event_utag.product_msrp = utag_data.product_msrp; }if (utag_data.hasOwnProperty('product_on_sale')) {psm_event_utag.product_on_sale = utag_data.product_on_sale; }if (utag_data.hasOwnProperty('product_original_price')) {psm_event_utag.product_original_price = utag_data.product_original_price; }if (utag_data.hasOwnProperty('product_subcategory')) {psm_event_utag.product_subcategory = utag_data.product_subcategory; }if (utag_data.hasOwnProperty('product_type')) {psm_event_utag.product_type = utag_data.product_type; }if (utag_data.hasOwnProperty('product_videos_count')) {psm_event_utag.product_videos_count = utag_data.product_videos_count; }if (utag_data.hasOwnProperty('product_year')) {psm_event_utag.product_year = utag_data.product_year; }if (utag_data.hasOwnProperty('oem_brp_id')) {psm_event_utag.oem_brp_id = utag_data.oem_brp_id; }if (utag_data.hasOwnProperty('oem_polaris_id')) {psm_event_utag.oem_polaris_id = utag_data.oem_polaris_id; }if (utag_data.hasOwnProperty('oem_harley_id')) {psm_event_utag.oem_harley_id = utag_data.oem_harley_id; }if (utag_data.hasOwnProperty('oem_bmw_id')) {psm_event_utag.oem_bmw_id = utag_data.oem_bmw_id; }psm_event_utag.form_id = 'price_drop_alert'; psm_event_utag.form_name = 'price drop alert'; psm_event_utag.form_type = 'unit_alert'; if (event === 'ua_price_drop_alert_submit') {  psm_event_utag.form_submission_email = document.getElementById('PSM-PD-Email').value;   psm_event_utag.form_submission_first_name = document.getElementById('PSM-PD-FirstName').value;   psm_event_utag.form_submission_id = 'e0dd12b85803459184a7741e7e21b4a1';   psm_event_utag.form_submission_last_name = document.getElementById('PSM-PD-LastName').value;   psm_event_utag.form_submission_phone_number = document.getElementById('PSM-PD-Phone').value;   psm_event_utag.form_submission_alert_type = document.getElementById('PSM-PD-EmailType').value + document.getElementById('PSM-PD-TextType').value; }  psm_event_utag.product_id = psmPDUnitId;   psm_event_utag.product_image_url = psmPDUnitImageUrl;   psm_event_utag.product_name = psmPDUnitName;   psm_event_utag.product_price = psmPDUnitPrice;   psm_event_utag.product_uri = psmPDUnitUrl;   psm_event_utag.tealium_event = event; utag.link(psm_event_utag); } } function psmSendInventoryTealiumEvent(event) { console.log('tealium_event: ' + event); var psm_event_utag = {}; if (typeof utag_data === 'object') {   psm_event_utag.ga4_id = utag_data.ga4_id;   psm_event_utag.ga_ua_id = utag_data.ga_ua_id;   psm_event_utag.page_h1 = utag_data.page_h1;   psm_event_utag.page_title = utag_data.page_title;   psm_event_utag.page_title_count = utag_data.page_title_count;   psm_event_utag.piwik_id = utag_data.piwik_id;   psm_event_utag.site_company_city = utag_data.site_company_city;   psm_event_utag.site_company_name = utag_data.site_company_name;   psm_event_utag.site_company_state = utag_data.site_company_state;   psm_event_utag.site_company_zip_code = utag_data.site_company_zip_code;   psm_event_utag.site_id = utag_data.site_id;   psm_event_utag.site_internal_id = utag_data.site_internal_id;   psm_event_utag.site_platform = utag_data.site_platform;   psm_event_utag.site_section = utag_data.site_section;   psm_event_utag.site_sub_section = utag_data.site_sub_section;   psm_event_utag.site_phone_main = utag_data.site_phone_main; if (utag_data.hasOwnProperty('oem_brp_id')) {psm_event_utag.oem_brp_id = utag_data.oem_brp_id; }if (utag_data.hasOwnProperty('oem_polaris_id')) {psm_event_utag.oem_polaris_id = utag_data.oem_polaris_id; }if (utag_data.hasOwnProperty('oem_harley_id')) {psm_event_utag.oem_harley_id = utag_data.oem_harley_id; }if (utag_data.hasOwnProperty('oem_bmw_id')) {psm_event_utag.oem_bmw_id = utag_data.oem_bmw_id; }psm_event_utag.form_id = 'inventory_updates'; psm_event_utag.form_name = 'inventory updates'; psm_event_utag.form_type = 'unit_alert'; if (event === 'ua_inventory_updates_submit') {  psm_event_utag.form_submission_email = document.getElementById('PSM-IU-Email').value;   psm_event_utag.form_submission_first_name = document.getElementById('PSM-IU-FirstName').value;   psm_event_utag.form_submission_id = 'e0dd12b85803459184a7741e7e21b4a1';   psm_event_utag.form_submission_last_name = document.getElementById('PSM-IU-LastName').value;   psm_event_utag.form_submission_phone_number = document.getElementById('PSM-IU-Phone').value;   psm_event_utag.form_submission_alert_type = document.getElementById('PSM-IU-Type').value;   psm_event_utag.form_submission_category = document.getElementById('PSM-IU-Category').value;   psm_event_utag.form_submission_make = getInventoryUpdatesMakeValue();   psm_event_utag.form_submission_condition = document.getElementById('PSM-IU-Status').value; }psm_event_utag.tealium_event = event; utag.link(psm_event_utag); } } function PSMOnboardResponseSuccess(visitorId) { console.log('onboarding-id: ' + visitorId); var dateOfExp = new Date(); dateOfExp.setDate(dateOfExp.getDate() + 1); document.cookie = 'firestorm_dev_id=' + visitorId + '; path=/; Expires=' + dateOfExp.toString(); DisplayAndCheckHistory(visitorId); } function DisplayAndCheckHistory(visitorId) { var DealerWelcomeBackEnabled = false; if(DealerWelcomeBackEnabled) { var LoadVDPRecentChecker = '/LoadVDPHistoryModal.aspx?id=' + visitorId + '&dealerid=26565'; const OnboardURL = new XMLHttpRequest(); OnboardURL.open('GET', LoadVDPRecentChecker); OnboardURL.send(); OnboardURL.onload = () => { let status = OnboardURL.status; if (status == 200) { var data = JSON.parse(OnboardURL.responseText); if (data.success) { LoadRecentlyViewedModal(data);  } else { console.log(data.message); } } else { console.log(OnboardURL.responseText); } }; } else { console.log('PSM Dealer Welcome Back VDP Disabled'); } } var divPSMReviews =  document.getElementById('divLVRM-Reviews'); function LoadPSMReviews(BadgeGUID, initial) { var buttonhtml = '<div class="psm-review-container"><h1>Read What Our Customers Are Saying</h1><hr >'; divPSMReviews.style.display = 'block'; divPSMReviews.innerHTML = buttonhtml + '<div style="width: 600px;height: 300px;margin: 0 auto;display: flex;align-items: center;justify-content: flex-start;text-align: center;flex-direction: column;"><img src="https://psm.blob.core.windows.net/psmdata/Images/loading_transparent.gif" alt="Loading"></div>'; var LoadReviewsURL = '/LoadReviews.aspx?origId=e0dd12b85803459184a7741e7e21b4a1&id=' + BadgeGUID+'&isInitial='+initial; const ReviewDataURL = new XMLHttpRequest(); ReviewDataURL.open('GET', LoadReviewsURL); ReviewDataURL.send(); ReviewDataURL.onload = () => { let status = ReviewDataURL.status; if (status == 200) { if(initial) { var psmReviewCSS = document.createElement("div"); psmReviewCSS.innerHTML = "<link rel='stylesheet' href='/css/psmreview.css?vs=7' type='text/css' media='screen' />"; if(document.getElementsByTagName('body')[0] == null) {document.getElementsByTagName('head')[0].appendChild(psmReviewCSS); } else {document.getElementsByTagName('body')[0].appendChild(psmReviewCSS); } } divPSMReviews.style.display = 'block'; var data = JSON.parse(ReviewDataURL.responseText); if (data.success) { buttonhtml += '<div>'; buttonhtml += "<div id='divPSMLocations' style='display:none;'>Current Location: <select id='psmDealerSelect' class='psm-dealer-select'>" ; for(var i = 0; i < data.dealerOptions.length; i++) { if(i === 0) { buttonhtml += "<option value='all' locationId='0'>Show All Locations</option>"}buttonhtml += "<option value=" + data.dealerOptions[i].EditValue + " locationId=" + data.dealerOptions[i].ColumnOne + " " + (data.dealerOptions[i].ColumnTwo != null && initial ? data.dealerOptions[i].ColumnTwo : (BadgeGUID == data.dealerOptions[i].EditValue ? 'selected' : ''))  + ">" + data.dealerOptions[i].DisplayName + "</option>"} buttonhtml += "</select><br /></div>"; if(data.IsGoogleURLEnabled && data.googleURL) { buttonhtml += '<a onclick="psmSendTealiumEvent(&quot;wr_google_click&quot;)" class="psm-reviews-button" href="' + data.googleURL + '" target="_blank"><img src="https://psm.blob.core.windows.net/psmdata/Images/icon-google.png" alt="Google" height="15" />&nbsp;&nbsp;Write Review on Google</a>';  } if(data.IsFacebookURLEnabled && data.facebookURL) { buttonhtml += '<a class="psm-reviews-button" href="'+ data.facebookURL +'" target="_blank"><img src="https://psm.blob.core.windows.net/psmdata/Images/icon-facebook.png" alt="Facebook" height="15" />&nbsp;&nbsp;Write Review on Facebook</a>';  } buttonhtml += '</div>'; buttonhtml += " <div class='psm-reviews-heading-text'><p>Highlights from our reviews are shared below. All reviews can be viewed on the respective review sites.</p></div>"; var reviewHtml = "<div class='psm-review-row-padding'>"; for(var i = 0; i < data.reviews.length; i++) { var review = data.reviews[i]; var Comments = decodeHtml(review.CommentPreview); if(review.ShowMoreButton) { Comments += ' <br /><span style="cursor: pointer; padding-top:5px; display: block;" onclick="ShowPSMReviewDetails(\'' + review.RatingImageURL + '\', \'' + review.FullName + '\', \'' + review.Rating + '\', \'' + review.ReviewDescSafe.replaceAll('|&|', '&#39;') + '\', \'' + review.ReviewDateDisplay + '\',\'' + review.SourceURL + '\',\'' + review.TypeText + '\');"><u><b>Read Full Review</b></u></span>'; } reviewHtml += "<div class='psm-review-third'><b>" + review.DealerName + "</b><br /><img src='" + review.RatingImageURL + "' alt='" + review.Rating + "' /><br /><div class='psm-review-comments'>" + decodeHtml(Comments.replaceAll('|&|', '&#39;')) + "</div><table width='100%' style='padding: 2px;'><tr><td><b>" + review.FullName + "</b><br />" + review.ReviewDateDisplay + "</td><td align='right'><img height='30' src='" + review.SourceURL + "' alt='" + review.TypeText + "' /></td></tr></table></div>"; } reviewHtml += "</div>"; buttonhtml += reviewHtml; buttonhtml += "<div id='psmReviewsModal' class='psm-reviews-modal'>"; buttonhtml += "<div class='psm-reviews-modal-content'>"; buttonhtml += "<span class='psm-reviews-modal-close'>&times;</span>"; buttonhtml += "<div id='psm-reviews-modal-content-template' style='display:none;'><div class='psm-review-third'><img src='[RatingImageURL]' alt='[ReviewLevel]' /><br /><div class='psm-review-comments'>[reviewComments]</div><table width='100%'><tr><td><b>[FullName]</b><br />[FacebookDateString]</td><td align='right'><img height='30' src='[SourceURL]' alt='[TypeText]' /></td></tr></table></div> </div>"; buttonhtml += "<div id='psm-reviews-modal-content'></div>"; buttonhtml += "</div>"; buttonhtml += "</div>"; buttonhtml += "</div>"; divPSMReviews.innerHTML = buttonhtml; var sendButton = document.getElementById('btnSendFeedback'); if (sendButton) { sendButton.onclick = function () { document.querySelectorAll('.psm-feedback-text-danger.psm-feedback-small').forEach(el => el.style.display = 'none'); let valid = true; var firstName = document.getElementById('txtFirstName').value.trim(); var lastName = document.getElementById('txtLastName').value.trim(); var email = document.getElementById('txtEmail').value.trim(); var phone = document.getElementById('txtPhone').value.trim(); var number = phone.replace(/\D/g, ''); if (number.length > 0 && number.substring(0,1) == '1') { document.getElementById('errPhone').innerText = 'Invalid phone number. Cannot start with 1.'; document.getElementById('errPhone').style.display = 'block'; valid = false; } var feedback = document.getElementById('txtFeedback').value.trim(); var captchaInput = document.getElementById('txtCaptchaInput').value.trim(); var captchaExpected = document.getElementById('hdnCaptchaExpected').value.trim(); if (!firstName) { document.getElementById('errFirstName').innerText = 'Please enter first name.'; document.getElementById('errFirstName').style.display = 'block'; valid = false; } if (!lastName) { document.getElementById('errLastName').innerText = 'Please enter last name.'; document.getElementById('errLastName').style.display = 'block'; valid = false; } if (!email || !/^\S+@\S+\.\S+$/.test(email)) { document.getElementById('errEmail').innerText = 'Please enter a valid email.'; document.getElementById('errEmail').style.display = 'block'; valid = false; } if (!feedback) { document.getElementById('errFeedback').innerText = 'Please enter feedback.'; document.getElementById('errFeedback').style.display = 'block'; valid = false; } if (!captchaInput) { document.getElementById('errCaptcha').innerText = 'Please enter CAPTCHA.'; document.getElementById('errCaptcha').style.display = 'block'; valid = false; } else if (captchaExpected !== captchaInput) { document.getElementById('errCaptcha').innerText = 'Please enter valid CAPTCHA.'; document.getElementById('errCaptcha').style.display = 'block'; valid = false; } if (!valid) return; var rawPhone = phone.replace(/\D/g, ''); document.body.style.cursor = 'wait'; var xhr = new XMLHttpRequest(); xhr.open('POST', '/SaveDealerFeedback.aspx', true); xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8'); document.getElementById('div-dealer-feedback-success-message').style.display = 'block'; document.body.style.cursor = 'wait'; xhr.onreadystatechange = function () { if (xhr.readyState === 4) { document.getElementById('div-dealer-feedback-success-message').style.display = 'none'; document.body.style.cursor = 'default'; var result = {}; try { result = JSON.parse(xhr.responseText); } catch (e) { document.getElementById('errCaptcha').innerText = 'Unexpected response from server.'; document.getElementById('errCaptcha').style.display = 'block'; return; } if (xhr.status === 200 && result.success) { alert('Thank you for your feedback!'); closeDealerFeedbackPopup(); } else { document.getElementById('errCaptcha').innerText = result.message || 'Submission failed. Please try again.'; document.getElementById('errCaptcha').style.display = 'block'; } } }; xhr.send(JSON.stringify({ DealerGUID: BadgeGUID, OriginalDealerGUID: 'e0dd12b85803459184a7741e7e21b4a1', FirstName: firstName, LastName: lastName, Email: email, Phone: rawPhone, Feedback: feedback })); }; document.getElementById('txtPhone').addEventListener('input', function (e) { let x = e.target.value.replace(/\D/g, '').substring(0, 10); let formatted = ''; if (x.length > 0) formatted = '(' + x.substring(0, 3); if (x.length >= 4) formatted += ') ' + x.substring(3, 6); if (x.length >= 7) formatted += '-' + x.substring(6); e.target.value = formatted; });} let h1 = divPSMReviews.querySelector('.psm-review-container h1'); if (h1) {  let h1Color = window.getComputedStyle(h1).color;  let tempDiv = document.createElement("div");  tempDiv.style.color = h1Color;  document.body.appendChild(tempDiv);  let computedColor = window.getComputedStyle(tempDiv).color;  document.body.removeChild(tempDiv);  let [r, g, b] = computedColor.match(/\d+/g).map(Number);  if (r >= 240 && g >= 240 && b >= 240) {    h1.style.color = "black";  }} if(data.dealerOptions.length > 1) { divPSMLocations.style.display = "block"; } } else { console.log(data.message); divPSMReviews.innerHTML = '<div style="width: 600px; height: 300px; margin: 0 auto; text-align: center; margin-top: 60px;">' + data.message + '</div>'; } psmDealerSelect.addEventListener('change', psmDealerChangeHandler, false); } else { console.log(ReviewDataURL.responseText); divPSMReviews.innerHTML = '<div style="width: 600px; height: 300px; margin: 0 auto; text-align: center; margin-top: 60px;">' + ReviewDataURL.responseText + '</div>'; } }; } function ShowPSMReviewDetails(RatingImageURL, FullName, ReviewLevel, reviewComments, FacebookDateString, SourceURL, TypeText) { var psmReviewsModal = document.getElementById('psmReviewsModal'); psmReviewsModal.style.display = 'block'; var psmReviewsModalContent = document.getElementById('psm-reviews-modal-content');var psmReviewsModalContentTemplate = document.getElementById('psm-reviews-modal-content-template');psmReviewsModalContent.innerHTML = psmReviewsModalContentTemplate.innerHTML.replace('[RatingImageURL]', RatingImageURL).replace('[FullName]', FullName).replace('[ReviewLevel]', ReviewLevel).replace('[reviewComments]', decodeHtml(reviewComments.replaceAll('|&|', '&#39;'))).replace('[FacebookDateString]', FacebookDateString).replace('[TypeText]', TypeText).replace('[SourceURL]', SourceURL); var psmReviewsModalClose = document.getElementsByClassName('psm-reviews-modal-close')[0]; psmReviewsModalClose.onclick = function() {  psmReviewsModal.style.display = 'none'; } } function decodeHtml(html) { var txt = document.createElement("textarea"); txt.innerHTML = html; return txt.value; } function closeDealerFeedbackPopup() { document.getElementById('modal-dealer-feedback').style.display = 'none'; document.getElementById('txtFirstName').value = ''; document.getElementById('txtLastName').value = ''; document.getElementById('txtEmail').value = ''; document.getElementById('txtPhone').value = ''; document.getElementById('txtFeedback').value = ''; document.getElementById('txtCaptchaInput').value = ''; document.querySelectorAll('#modal-dealer-feedback .psm-feedback-text-danger.psm-feedback-small').forEach(function(el) { el.innerText = ''; el.style.display = 'none'; }); reloadCaptcha(); } function reloadCaptcha() { fetch('/SurveyCheck.aspx?getCaptchaBase64=true') .then(response => response.json()) .then(data => { document.getElementById('imgCaptcha').src = data.captchaBase64; document.getElementById('hdnCaptchaExpected').value = data.captchaText; }) .catch(err => console.error('CAPTCHA reload error', err)); } function openDealerFeedbackPopup() { document.getElementById('modal-dealer-feedback').style.display = 'block'; } function selectPSMDealerByExternalLocationId(locationId) { $('#psmDealerSelect option[locationId=' + locationId + ']').prop('selected', true); var e = document.getElementById('psmDealerSelect'); var dealerGuid = e.value; LoadPSMReviews(dealerGuid, false); } if (typeof(divPSMReviews) != 'undefined' && divPSMReviews != null) { var psmDealerChangeHandler = function () { LoadPSMReviews(this.value, false); }; LoadPSMReviews('e0dd12b85803459184a7741e7e21b4a1', true); } var divLVRMReviewCarousel =  document.getElementById('divLVRM-Review-Carousel'); if (typeof(divLVRMReviewCarousel) != 'undefined' && divLVRMReviewCarousel != null) { divLVRMReviewCarousel.style.display = 'block'; divLVRMReviewCarousel.innerText = 'Review Tool or Review Carousel is disabled'; } function include(filename, onload) { var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.src = filename; script.type = 'text/javascript'; script.onload = script.onreadystatechange = function () { if (script.readyState) { if (script.readyState === 'complete' || script.readyState === 'loaded') { script.onreadystatechange = null; onload(); } } else { onload(); } }; head.appendChild(script); }; function css(selector, property, value) { for (var i = 0; i < document.styleSheets.length; i++) { try { document.styleSheets[i].insertRule(selector + ' {' + property + ':' + value + '}', document.styleSheets[i].cssRules.length); } catch (err) { try { document.styleSheets[i].addRule(selector, property + ':' + value); } catch (err) { } } } }  
                (function () {
                  // ---------- Config / Debug ----------
                  var TARGET_MATCH = /\/shopper-guide\b/i; // case-insensitive anywhere in path
                  window.__SG_DEBUG = window.__SG_DEBUG || false;
                  function dbg(){ if (!window.__SG_DEBUG) return; try{ console.log.apply(console, arguments);}catch(_){} }

                  // ---------- Page gate ----------
                  function isTarget() {
                    try { return TARGET_MATCH.test(location.pathname); } catch(e) { return false; }
                  }

                  // ---------- Data selection (prefer utag_data) ----------
                  function rawUtagData()  { return (window.utag && window.utag.data) ? window.utag.data : null; }
                  function rawUtag_data() { return window.utag_data || null; }

                  // Merge in priority: utag.data < utag_data < local payload
                  function bestData(local) {
                    var a = rawUtagData() || {};
                    var b = rawUtag_data() || {};
                    var out = {};
                    try { out = Object.assign({}, a, b, local || {}); }
                    catch(_) { var k; for (k in a) out[k]=a[k]; for (k in b) out[k]=b[k]; for (k in (local||{})) out[k]=local[k]; }
                    return out;
                  }

                  function toInt(x){ var n = parseInt(x,10); return isNaN(n)?0:n; }
                  function normEvt(v){ return (v==null? '' : (''+v)).trim().toLowerCase(); }

                  function buildDto(d){
                    return {
                      DateCreated: new Date().toISOString(),
                      DealerId: 26565,
                      DeviceId: (typeof getPSMCookie==='function'?getPSMCookie('firestorm_dev_id'):null),
                      CustomerId: 0,
                      tealium_event: d.tealium_event || '',
                      ga4_id: d.ga4_id || d.ga_client_id || '',
                      page_h1: d.page_h1 || '',
                      page_title: d.page_title || document.title || '',
                      page_title_count: toInt(d.page_title_count || 0),
                      shopper_guide_step: toInt(d.shopper_guide_step || 0),
                      shopper_guide_question: d.shopper_guide_question || '',
                      site_company_name: d.site_company_name || '',
                      site_company_city: d.site_company_city || '',
                      site_company_state: d.site_company_state || '',
                      site_company_zip_code: d.site_company_zip_code || '',
                      site_phone_main: d.site_phone_main || '',
                      site_id: d.site_id || '',
                      site_internal_id: d.site_internal_id || '',
                      site_platform: d.site_platform || '',
                      site_platform_brand: d.site_platform_brand || '',
                      site_section: d.site_section || ''
                    };
                  }

                  var lastStepSent = -1;    // dedupe what we've POSTed
                  var lastStepObserved = 0; // track transitions (for reset -> step 1)

                  function shouldSend(step){ return isTarget() && step>0 && step!==lastStepSent; }

                  function sendNow(d){
                    var dto = buildDto(d);
                    dbg('[SG] send step', dto.shopper_guide_step, 'event=', dto.tealium_event, dto);
                    try {
                      fetch('https://onboard.localwebdominator.com/api/PSM/RegisterShopperGuideEvent', {
                        method:'POST',
                        headers:{
                          'Content-Type':'application/json',
                          'x-apiKey':'eb094e9e-3fa7-4402-b49e-08a04c1847eb',
                          'X-Referer': location.href
                        },
                        body: JSON.stringify(dto),
                        keepalive:true
                      }).catch(function(e){ console && console.warn('ShopperGuide post failed', e); });
                    } catch(e){}
                  }

                  function maybeSend(local){
                    if(!isTarget()){ dbg('[SG] skip: not target'); return; }
                    var d = bestData(local);
                    if(!d){ dbg('[SG] skip: no data'); return; }

                    var step = toInt(d.shopper_guide_step);
                    var was  = toInt(lastStepObserved);
                    var isResetToOne = (was > 1 && step === 1);

                    // Only override when resetting to 1 AND current event is shopper_guide_view
                    var evt = normEvt(d.tealium_event);
                    if (isResetToOne && evt === 'shopper_guide_view') {
                      d.tealium_event = 'shopper_guide_start_over';
                      dbg('[SG] reset detected (' + was + ' -> ' + step + ') with shopper_guide_view; overriding event to shopper_guide_start_over');
                    }

                    if(shouldSend(step)){
                      lastStepSent = step;
                      sendNow(d);
                    } else {
                      dbg('[SG] skip: step', step, 'lastStepSent', lastStepSent, 'was', was, 'evt', evt);
                    }

                    // Always update observed step so future transitions are detected
                    lastStepObserved = step;
                  }

                  // ---------- Instrument Tealium (with re-check) ----------
                  function wrapOnce(obj, method, wrapper){
                    var orig = obj && obj[method];
                    if(typeof orig !== 'function' || orig.__sg_instrumented) return;
                    var wrapped = wrapper(orig);
                    wrapped.__sg_instrumented = true;
                    obj[method] = wrapped;
                  }
                  function instrumentTealium(){
                    if(!window.utag) return;
                    wrapOnce(window.utag, 'track', function(orig){
                      return function(type, data){ try{ dbg('[SG] utag.track', type, data); maybeSend(data);}catch(_){} return orig.apply(this, arguments); };
                    });
                    wrapOnce(window.utag, 'view', function(orig){
                      return function(data){ try{ dbg('[SG] utag.view', data); maybeSend(data);}catch(_){} return orig.apply(this, arguments); };
                    });
                    wrapOnce(window.utag, 'link', function(orig){
                      return function(data){ try{ dbg('[SG] utag.link', data); maybeSend(data);}catch(_){} return orig.apply(this, arguments); };
                    });
                  }

                  // ---------- Watch BOTH utag.data and utag_data ----------
                  var lastRef_data = null;
                  var lastRef_utag_data = null;

                  function installStepWatcherOn(obj, label){
                    if(!obj || typeof obj!=='object') return;
                    if(obj.__sg_step_watched) return;
                    try {
                      var backing = obj.hasOwnProperty('shopper_guide_step') ? obj.shopper_guide_step : undefined;
                      Object.defineProperty(obj, 'shopper_guide_step', {
                        configurable:true, enumerable:true,
                        get:function(){ return backing; },
                        set:function(v){ backing = v; dbg('[SG] step set ('+label+') ->', v); try{ maybeSend(obj);}catch(_){} }
                      });
                      Object.defineProperty(obj, '__sg_step_watched', { value:true, enumerable:false });
                      dbg('[SG] watcher via defineProperty on', label);
                    } catch(e){
                      try {
                        var prox = new Proxy(obj, {
                          set:function(t,p,v){ t[p]=v; if(p==='shopper_guide_step'){ dbg('[SG] step set Proxy('+label+') ->', v); try{ maybeSend(t);}catch(_){} } return true; }
                        });
                        if(label==='utag.data' && window.utag && window.utag.data===obj) window.utag.data = prox;
                        if(label==='utag_data' && window.utag_data===obj) window.utag_data = prox;
                        dbg('[SG] watcher via Proxy on', label);
                      } catch(e2){ dbg('[SG] failed to watch', label, e2); }
                    }
                  }

                  function watchForReplacement(){
                    var checks=0;
                    var id=setInterval(function(){
                      checks++;
                      var a = rawUtagData();
                      var b = rawUtag_data();

                      if(a && a!==lastRef_data){ lastRef_data=a; installStepWatcherOn(a, 'utag.data'); maybeSend(); }
                      if(b && b!==lastRef_utag_data){ lastRef_utag_data=b; installStepWatcherOn(b, 'utag_data'); maybeSend(); }

                      // also re-instrument Tealium if its methods were replaced
                      instrumentTealium();

                      if(checks>1200) clearInterval(id); // ~20m
                    }, 1000);
                  }

                  // ---------- SPA route hooks ----------
                  function hookHistory(){
                    ['pushState','replaceState'].forEach(function(m){
                      var orig = history[m];
                      if(typeof orig!=='function' || orig.__sg_instrumented) return;
                      var wrapped = function(){
                        var ret = orig.apply(this, arguments);
                        setTimeout(function(){ dbg('[SG] history.'+m+' -> check'); try{ maybeSend(); }catch(_){} },0);
                        return ret;
                      };
                      wrapped.__sg_instrumented=true;
                      history[m]=wrapped;
                    });
                    window.addEventListener('popstate', function(){ dbg('[SG] popstate'); try{ maybeSend(); }catch(_){} });
                    window.addEventListener('hashchange', function(){ dbg('[SG] hashchange'); try{ maybeSend(); }catch(_){} });
                  }

                  // ---------- Bootstrap ----------
                  function start(){
                    dbg('[SG] start. isTarget=', isTarget(), 'href=', location.href);

                    // Initialize last observed step from current data
                    var initial = bestData();
                    lastStepObserved = toInt(initial && initial.shopper_guide_step);

                    instrumentTealium();
                    hookHistory();

                    var a = rawUtagData();  if(a) { lastRef_data=a; installStepWatcherOn(a, 'utag.data'); }
                    var b = rawUtag_data(); if(b){ lastRef_utag_data=b; installStepWatcherOn(b, 'utag_data'); }

                    maybeSend(); // attempt immediately with best merged snapshot
                    watchForReplacement();

                    // light polling safety net
                    var tries=0, poll=setInterval(function(){ tries++; try{ maybeSend(); }catch(_){} if(tries>600) clearInterval(poll); }, 1000);

                    // helpers
                    window.__SG_status=function(){ var d=bestData(); return { href:location.href, isTarget:isTarget(), step:toInt(d.shopper_guide_step), lastStepSent:lastStepSent, lastStepObserved:lastStepObserved, event:(d && d.tealium_event)||'', hasUtag:!!window.utag, has_utag_data:!!window.utag_data }; };
                    window.__SG_forceSend=function(){ maybeSend(); };
                  }

                  if(isTarget()) start(); else { hookHistory(); /* wait for SPA nav onto the guide */ }
                })();
                 
                  // ---------- ONBOARDING with fingerprint timings recorded on meta.fp ----------
                  
                            var LoadOnboardScript = 0;
                            var PSMOnboardCookie = getPSMCookie('firestorm_dev_id');

                            if (PSMOnboardCookie != null && PSMOnboardCookie != '') {
                                LoadOnboardScript = 1;
                            }

                            if (LoadOnboardScript === 0) {
                                PSMOnboardCookie = getPSMCookie('OnboardCook26565');
                                if (PSMOnboardCookie != null && PSMOnboardCookie != '') {
                                    LoadOnboardScript = 1;
                                }
                            }

                            function waitForUtag(callback, timeout = 5000) {
                                const start = Date.now();
                                function check() {
                                    const now = Date.now();
                                    if (window.utag && window.utag.data) {
                                        callback(window.utag.data);
                                    } else if (now - start < timeout) {
                                        requestAnimationFrame(check);
                                    } else {
                                        console.warn('Timeout waiting for utag.data — proceeding with empty payload.');
                                        callback(null);
                                    }
                                }
                                check();
                            }

                            waitForUtag((utagData) => {
                                var tealiumPayload = {
                                    tealiumevent: '',
                                    interestedin: '',
                                    product_id: '',
                                    product_brand: '',
                                    product_category: '',
                                    product_subcategory: '',
                                    product_condition: '',
                                    product_image_url: '',
                                    product_industry: '',
                                    product_year: 0,
                                    product_make: '',
                                    product_model: '',
                                    product_name: '',
                                    product_original_price: 0,
                                    product_price: 0,
                                    product_type: '',
                                    product_uri: ''
                                };

                                if (utagData) {
                                    if (utagData.tealium_event) { tealiumPayload.tealiumevent = utagData.tealium_event; }
                                    if (utagData.product_name) { tealiumPayload.interestedin = utagData.product_name; }
                                    if (utagData.product_id) { tealiumPayload.product_id = utagData.product_id; }
                                    if (utagData.product_brand) { tealiumPayload.product_brand = utagData.product_brand; }
                                    if (utagData.product_category) { tealiumPayload.product_category = utagData.product_category; }
                                    if (utagData.product_subcategory) { tealiumPayload.product_subcategory = utagData.product_subcategory; }
                                    if (utagData.product_condition) { tealiumPayload.product_condition = utagData.product_condition; }
                                    if (utagData.product_image_url) { tealiumPayload.product_image_url = utagData.product_image_url; }
                                    if (utagData.product_industry) { tealiumPayload.product_industry = utagData.product_industry; }
                                    if (utagData.product_year) { tealiumPayload.product_year = utagData.product_year; }
                                    if (utagData.product_make) { tealiumPayload.product_make = utagData.product_make; }
                                    if (utagData.product_model) { tealiumPayload.product_model = utagData.product_model; }
                                    if (utagData.product_name) { tealiumPayload.product_name = utagData.product_name; }
                                    if (utagData.product_original_price) { tealiumPayload.product_original_price = utagData.product_original_price; }
                                    if (utagData.product_price) { tealiumPayload.product_price = utagData.product_price; }
                                    if (utagData.product_type) { tealiumPayload.product_type = utagData.product_type; }
                                    if (utagData.product_uri) { tealiumPayload.product_uri = utagData.product_uri; }
                                }

                                if (LoadOnboardScript == 0) {
                                  // ---- grab the fp meta bucket from psm_timer_data ----
                                  var fpMeta =
                                    window.psm_timer_data &&
                                    window.psm_timer_data.meta &&
                                    window.psm_timer_data.meta.fp
                                      ? window.psm_timer_data.meta.fp
                                      : null;

                                  function nowMs() {
                                    return (window.performance && performance.now)
                                      ? performance.now()
                                      : Date.now();
                                  }

                                  // ---- import() timing ----
                                  if (window.psm_timer && window.psm_timer.start) {
                                    window.psm_timer.start('fp_import');
                                  }
                                  var importStart = nowMs();

                                  const fpImport = import('https://metrics.psmmarketing.com/web/v3/8SMYTmlRdqyGTGMYPwF5');

                                  const fpPromise = fpImport
                                    .then(FingerprintJS => {
                                      var importEnd = nowMs();
                                      if (window.psm_timer && window.psm_timer.end) {
                                        window.psm_timer.end('fp_import');
                                      }
                                      if (fpMeta) {
                                        fpMeta.importMs = importEnd - importStart;
                                      }

                                      // ---- FingerprintJS.load() timing ----
                                      if (window.psm_timer && window.psm_timer.start) {
                                        window.psm_timer.start('fp_load');
                                      }
                                      var loadStart = nowMs();

                                      return FingerprintJS.load({
                                        endpoint: [
                                          'https://metrics.psmmarketing.com',
                                          FingerprintJS.defaultEndpoint
                                        ]
                                      }).then(fpInstance => {
                                        var loadEnd = nowMs();
                                        if (window.psm_timer && window.psm_timer.end) {
                                          window.psm_timer.end('fp_load');
                                        }
                                        if (fpMeta) {
                                          fpMeta.loadMs = loadEnd - loadStart;
                                        }
                                        return fpInstance;
                                      });
                                    });

                                  const requestMetadata = {
                                    dealerid: 51894,
                                    requestType: 'onboard',
                                    // keep sending tealium payload into FP tag
                                    tealium_data: JSON.stringify(tealiumPayload),
                                  };

                                  fpPromise
                                    .then(fp => {
                                      // ---- fp.get() timing ----
                                      if (window.psm_timer && window.psm_timer.start) {
                                        window.psm_timer.start('fp_get');
                                      }
                                      var getStart = nowMs();

                                      return fp.get({ tag: requestMetadata }).then(result => {
                                        var getEnd = nowMs();
                                        if (window.psm_timer && window.psm_timer.end) {
                                          window.psm_timer.end('fp_get');
                                        }
                                        if (fpMeta) {
                                          fpMeta.getMs = getEnd - getStart;
                                          fpMeta.requestTag = requestMetadata;
                                          fpMeta.visitorId = result.visitorId;
                                        }

                                        // existing behavior
                                        PSMOnboardResponseSuccess(result.visitorId);
                                        return result;
                                      });
                                    })
                                    .catch(error => {
                                      var msg = (error && error.message) ? error.message : String(error);
                                      if (fpMeta) {
                                        fpMeta.errors = fpMeta.errors || [];
                                        fpMeta.errors.push(msg);
                                      }
                                      console.log(msg);
                                    });
                                }
                                else {
                                    console.log('prior onboarding-id: ' + PSMOnboardCookie);

                                    // ---------------- TIMING HELPERS ----------------
                                    var fpMeta =
                                        window.psm_timer_data &&
                                        window.psm_timer_data.meta &&
                                        window.psm_timer_data.meta.fp
                                            ? window.psm_timer_data.meta.fp
                                            : null;

                                    function nowMs() {
                                        return (window.performance && performance.now)
                                            ? performance.now()
                                            : Date.now();
                                    }

                                    // ------------ mark build start ------------
                                    var buildStart = nowMs();

                                    DisplayAndCheckHistory(PSMOnboardCookie);

                                    var onboardData = {
                                        DealerId: 26565,
                                        DealerGuid: 'e0dd12b85803459184a7741e7e21b4a1',
                                        PageVisited: encodeURIComponent(window.location.href),
                                        DeviceId: PSMOnboardCookie,
                                        TealiumDatas: tealiumPayload
                                    };

                                    // ------------ mark build end ------------
                                    if (fpMeta) {
                                        fpMeta.onboard_buildMs = nowMs() - buildStart;
                                        fpMeta.visitorId = PSMOnboardCookie;
                                    }

                                    const url = 'https://onboard.localwebdominator.com/api/PSM/OnboardEvent';
                                    const OnboardURL = new XMLHttpRequest();

                                    // ------------------ SEND TIMING ------------------
                                    var sendStart = nowMs();

                                    OnboardURL.open('POST', url);
                                    OnboardURL.setRequestHeader('x-apiKey', 'eb094e9e-3fa7-4402-b49e-08a04c1847eb');
                                    OnboardURL.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');

                                    OnboardURL.onload = () => {
                                        var sendEnd = nowMs();
                                        if (fpMeta) {
                                            fpMeta.onboard_sendMs = sendEnd - sendStart;
                                            fpMeta.onboard_status = OnboardURL.status;
                                        }

                                        let status = OnboardURL.status;

                                        if (status == 200) {
                                            // ---------------- PARSE TIMING ----------------
                                            var parseStart = nowMs();
                                            try {
                                                var data = JSON.parse(JSON.parse(OnboardURL.responseText));
                                                var parseEnd = nowMs();

                                                if (fpMeta) fpMeta.onboard_parseMs = parseEnd - parseStart;

                                                if (data.success) {
                                                    console.log('Onboarded page for ' + PSMOnboardCookie);
                                                } else {
                                                    console.log(data.html);
                                                    if (fpMeta) fpMeta.onboard_error = data.html || 'unknown inline error';
                                                }
                                            }
                                            catch (e) {
                                                console.log('Onboard parse error', e);
                                                if (fpMeta) fpMeta.onboard_error = e.toString();
                                            }
                                        } else {
                                            console.log(OnboardURL.responseText);
                                            if (fpMeta) fpMeta.onboard_error = OnboardURL.responseText;
                                        }
                                    };

                                    OnboardURL.onerror = () => {
                                        if (fpMeta) {
                                            fpMeta.onboard_error = 'XHR network failure';
                                        }
                                    };

                                    OnboardURL.send(JSON.stringify(onboardData));

                                }
                            });
                          })() 