function getCookie(n){var t="; "+document.cookie,i=t.split("; "+n+"=");if(i.length==2)return!0}function reloadOTBanner(){if(!getCookie("OptanonAlertBoxClosed")){var n=document.getElementById("onetrust-consent-sdk");n&&n.remove();window.OneTrust!=null&&(OneTrust.Init(),setTimeout(function(){var t,n;for(OneTrust.LoadBanner(),t=document.getElementsByClassName("ot-sdk-show-settings"),n=0;n<t.length;n++)t[n].onclick=function(n){n.stopImmediatePropagation();window.OneTrust.ToggleInfoDisplay()}},1e3))}}function OptanonWrapper(){}document.addEventListener("DOMContentLoaded",reloadOTBanner());var gtmConstants={events:{footerInteraction:"FooterInteraction",menuInteraction:"MenuInteraction",socialInteraction:"SocialInteraction",branchLookup:"BranchLookup",emailInteraction:"EmailInteraction",pageNavigatedTo:"PageNavigatedTo",preferenceInteraction:"Preferences",carInfoInteraction:"CarInfoVehicleLookup",carInfoVehicleNotFound:"CarInfoVehicleNotFound",carInfoVehicleFound:"CarInfoVehicleFound",carInfoProvided:"CarInfoProvided"},categories:{footerLinkInteraction:"Footer Link Interaction",menuLinkInteraction:"Menu Link Interaction",socialInteraction:"Social Interaction",branchLocator:"Branch Locator",contactUs:"Contact Us",preferenceInteraction:"Preferences",carInfoInteraction:"Car Information"},actions:{branchLocator:"Branch Locator",email:"Email",search:"Search",updatePreferences:"Update Preferences",preferenceCentreLogin:"Preference Centre Login",optIn:"Opt In",optOut:"Opt Out",carInfoVL:"Registration Plate Entered",carInfoVehicleFound:"Car Info Vehicle Found",carInfoVehicleNotFound:"Car Info Vehicle Not Found",carInfoProvided:"Car Information Provided"},values:{empty:""}},gtmHelper={push:function(n){console.log("%cGTM event >> "+JSON.stringify(n,null,2),"background: #000; color: #b0f442");window.dataLayer.push(n)},footerInteraction:function(n){var t={event:gtmConstants.events.footerInteraction,eventCategory:gtmConstants.categories.footerLinkInteraction,eventAction:$(n).attr("data-action"),eventLabel:n.innerText,eventValue:gtmConstants.values.empty};gtmHelper.push(t)},menuInteraction:function(n){var t={event:gtmConstants.events.menuInteraction,eventCategory:gtmConstants.categories.menuLinkInteraction,eventAction:n.innerText,eventLabel:$(n).attr("href").replace(window.location.origin,""),eventValue:gtmConstants.values.empty};gtmHelper.push(t)},preferenceLoginInteraction:function(){var n={event:gtmConstants.events.preferenceInteraction,eventCategory:gtmConstants.categories.preferenceInteraction,eventAction:gtmConstants.actions.preferenceCentreLogin,eventLabel:window.location.pathname,eventValue:gtmConstants.values.empty};gtmHelper.push(n)},preferenceUpdateInteraction:function(){var n={event:gtmConstants.events.preferenceInteraction,eventCategory:gtmConstants.categories.preferenceInteraction,eventAction:gtmConstants.actions.updatePreferences,eventLabel:window.location.pathname,eventValue:gtmConstants.values.empty};gtmHelper.push(n)},freeCarCheckVLInteraction:function(n){var t={event:gtmConstants.events.carInfoInteraction,eventCategory:gtmConstants.categories.carInfoInteraction,eventAction:gtmConstants.actions.carInfoVL,eventLabel:window.location.pathname,eventValue:gtmConstants.values.empty,registrationPlate:n};gtmHelper.push(t)},preferenceAllInteraction:function(n){var t={event:gtmConstants.events.preferenceInteraction,eventCategory:gtmConstants.categories.preferenceInteraction,eventAction:n.checked?gtmConstants.actions.optIn:gtmConstants.actions.optOut,eventLabel:n.attributes.communicationpreferencename.value,eventValue:gtmConstants.values.empty};gtmHelper.push(t)},preferenceInteraction:function(n){var t={event:gtmConstants.events.preferenceInteraction,eventCategory:gtmConstants.categories.preferenceInteraction,eventAction:n.checked?gtmConstants.actions.optIn:gtmConstants.actions.optOut,eventLabel:n.attributes.communicationpreferencename.value.replace(/^webuyanycar[ ]*/i,".com ").toLowerCase().trim(),eventValue:gtmConstants.values.empty};gtmHelper.push(t)},socialInteraction:function(n){var t={event:gtmConstants.events.socialInteraction,eventCategory:gtmConstants.categories.socialInteraction,eventAction:$(n).attr("data-action"),eventLabel:window.location.pathname,eventValue:gtmConstants.values.empty};gtmHelper.push(t)},emailInteraction:function(n){var t={event:gtmConstants.events.emailInteraction,eventCategory:gtmConstants.categories.contactUs,eventAction:gtmConstants.actions.email,eventLabel:$(n).attr("href").split("@")[0].replace("mailto:",""),eventValue:gtmConstants.values.empty};gtmHelper.push(t)},branchLookup:function(n){var r=$(n).find("input")[0],t=r.value.padEnd(6," "),i;t=t.substr(0,t.length-3).trim().toUpperCase();i={event:gtmConstants.events.branchLookup,eventCategory:gtmConstants.categories.branchLocator,eventAction:gtmConstants.actions.search,eventLabel:t,eventValue:gtmConstants.values.empty};gtmHelper.push(i)},pageNavigatedTo:function(){var n=window.location.pathname,t={event:gtmConstants.events.pageNavigatedTo,page:n,eventCategory:null,eventAction:null,eventLabel:null,eventValue:null};gtmHelper.push(t)},freeCarCheckVehicleNotFound:function(n){var t={event:gtmConstants.events.carInfoVehicleNotFound,eventCategory:gtmConstants.categories.carInfoInteraction,eventAction:gtmConstants.actions.carInfoVehicleNotFound,eventLabel:window.location.pathname,eventValue:gtmConstants.values.empty,registrationPlate:n};gtmHelper.push(t)},freeCarCheckVehicleFound:function(n){var t=n.Make,i=n.Model,r=n.ColourName,u=n.ManufacturedYear,f=n.DateOfFirstRegistration,e=n.Transmission,o=n.EngineCapacity,s=n.Vrm,h={event:gtmConstants.events.carInfoVehicleFound,eventCategory:gtmConstants.categories.carInfoInteraction,eventAction:gtmConstants.actions.carInfoVehicleFound,eventLabel:window.location.pathname,eventValue:gtmConstants.values.empty,manufacturer:t,model:i,colour:r,engineSize:o,firstRegistered:f,year:u,transmission:e,registrationPlate:s};gtmHelper.push(h)},carInfoProvided:function(n){var t={event:gtmConstants.events.carInfoProvided,page:window.location.pathname,eventCategory:gtmConstants.categories.carInfoInteraction,eventAction:gtmConstants.actions.carInfoProvided,eventLabel:window.location.pathname,eventValue:gtmConstants.values.empty,registerationPlate:n};gtmHelper.push(t)}},gtmSelectors={footerInteraction:".footer-links-section > ul > li > a",menuInteraction:".menu-links a",preferenceLoginInteraction:"#btn-login-preferences",preferenceUpdateInteraction:"#btn-update-your-preferences",preferenceAllInteraction:".preference-checkbox.root",preferenceInteraction:".preference-checkbox:not(.root)",socialInteraction:".social-links a",emailInteraction:'a[href^="mailto:"]',branchLookup:'form[action*="branch-locator"]'};$().ready(function(){$(gtmSelectors.footerInteraction).on("click",function(n){gtmHelper.footerInteraction(n.currentTarget)});$(gtmSelectors.menuInteraction).on("click",function(n){gtmHelper.menuInteraction(n.currentTarget)});$(gtmSelectors.preferenceLoginInteraction).on("click",function(n){gtmHelper.preferenceLoginInteraction(n.currentTarget)});$(gtmSelectors.preferenceUpdateInteraction).on("click",function(n){gtmHelper.preferenceUpdateInteraction(n.currentTarget)});$(gtmSelectors.preferenceAllInteraction).on("click",function(n){gtmHelper.preferenceAllInteraction(n.currentTarget)});$(gtmSelectors.preferenceInteraction).on("click",function(n){gtmHelper.preferenceInteraction(n.currentTarget)});$(gtmSelectors.socialInteraction).on("click",function(n){gtmHelper.socialInteraction(n.currentTarget)});$(gtmSelectors.emailInteraction).on("click",function(n){gtmHelper.emailInteraction(n.currentTarget)});gtmHelper&&gtmHelper.pageNavigatedTo()})