var mainGa4DataLayer,ga4DataLayer=function(){var n,i,r,t;this.init=function(){window.onload=function(){for(var t,i=document.getElementsByClassName("btn-sitetype-details"),n=0;n<i.length;n++)i[n].addEventListener("click",function(n){var t=n.currentTarget.getAttribute("data-siteid");t&&mainGa4DataLayer.viewDetail(t)});for(t=document.getElementsByClassName("removeFromCartCheckout"),n=0;n<t.length;n++)t[n].addEventListener("click",function(){var n=$(this).val();n&&mainGa4DataLayer.removeFromCartCheckout(n)})}};this.populateSites=function(t){n=t};this.populateCartItems=function(n){i=n};this.populateSelectSites=function(n){r=n};this.populateSelectSitesCheckout=function(n){t=n};this.ccTypeForRewards=function(n){var t="";n==="VI"&&(t="VISA");n==="MC"&&(t="MC");n==="DI"&&(t="DISC");dataLayer.push({event:"checkout",ecommerce:{checkout:{actionField:{step:2,option:t}}}})};this.rewardsNewPurchase=function(){dataLayer.push({event:"detail",ecommerce:{detail:{actionField:{},products:[{name:"KOA Rewards Purchase",id:"VKR-stand-alone-purchase",price:39,brand:"",category:"VKR",variant:"",position:1}]}}})};this.rewardsRenewal=function(){dataLayer.push({event:"detail",ecommerce:{detail:{actionField:{},products:[{name:"KOA Rewards Renewal",id:"VKR-stand-alone-renewal",price:39,brand:"",category:"VKR",variant:"",position:2}]}}})};this.sensibleWeatherDetail=function(n,t,i,r){dataLayer.push({event:"productClick",ecommerce:{click:{actionField:{},products:[{name:"Sensible Weather Guarantee",id:t,price:i,brand:n,category:"SW",quoteId:r,quantity:1}]}}})};this.viewDetail=function(t){var i=n.find(n=>n.id==t);i&&(dataLayer.push({event:"productClick",ecommerce:{click:{actionField:{list:"SiteType - "+i.category},products:[{name:i.name,id:i.id,price:i.price,brand:i.brand,category:i.category,variant:i.variant,position:i.position}]}}}),dataLayer.push({ecommerce:{impressions:[{name:i.name,id:i.id,price:i.price,brand:i.brand,category:i.category,variant:i.variant,list:"SiteType - "+i.category,position:i.position}]},event:"impression"}))};this.addToCart=function(t,i){var r=n.find(n=>n.id==t);r&&dataLayer.push({event:"addToCart",ecommerce:{add:{actionField:{list:"SiteType - "+r.category},products:[{name:r.name,id:r.id,price:r.price,brand:r.brand,category:r.category,variant:r.variant,quantity:i,dimension8:i}]}}})};this.addToCartSelectSite=function(t,i,u){var f=r.find(n=>n.variant==t),e=n.find(n=>n.id==i);e&&f&&dataLayer.push({event:"addToCart",ecommerce:{add:{actionField:{list:"SiteType - "+f.category},products:[{name:e.name,id:e.id,price:e.price,brand:e.brand,category:e.category,variant:e.variant,quantity:u,dimension8:u},{name:f.name,id:f.id,price:f.price,brand:f.brand,category:f.catetory,variant:f.variant,quantity:f.quantity}]}}})};this.removeFromCartCheckout=function(n){var r=i.find(t=>t.shoppingCartReservationID==n),f=[],u,e;t!=null&&(u=t.find(n=>n.shoppingCartReservationID=r.shoppingCartReservationID),e={name:u.name,id:u.id,price:u.price,brand:u.brand,category:u.catetory,variant:u.variant,quantity:u.quantity},f.push(e));f.push({name:r.name,id:r.id,price:r.price,brand:r.brand,category:r.category,variant:r.variant,quantity:r.dimension8,dimension8:r.dimension8});dataLayer.push({event:"removeFromCart",ecommerce:{remove:{products:f}}})};this.removeSelectMySite=function(n,t,i,r,u){var f=[];f.push({name:u+" - Select My Site",id:"sms_"+n+"_"+i,price:r,brand:t,category:"SMS",variant:i,quantity:1});dataLayer.push({event:"removeFromCart",ecommerce:{remove:{products:f}}})};this.removeFromCartDataLayer=function(n){var t=[],i;n.length>1?n.forEach(function(n){if(t.push({name:n.CampgroundAlias+" - "+n.SiteTitle,id:n.PricingGroupID,price:Math.round(n.QuotedAmount/n.LengthOfStay),brand:n.CampgroundName,category:n.SiteCategoryCode,variant:n.CampgroundName,quantity:n.LengthOfStay,dimension8:n.LengthOfStay}),n.SiteNumber!=null){var i={name:n.CampgroundAlias+" - Select My Site",id:"sms_"+n.CampgroundID+"_"+n.SiteNumber,price:n.QuotedSiteRequestFeeAmount,brand:n.CampgroundName,category:"SMS",variant:n.SiteNumber,quantity:1};t.push(i)}}):(t.push({name:n.CampgroundAlias+" - "+n.SiteTitle,id:n.PricingGroupID,price:Math.round(n.QuotedAmount/n.LengthOfStay),brand:n.CampgroundName,category:n.SiteCategoryCode,variant:n.CampgroundName,quantity:n.LengthOfStay,dimension8:n.LengthOfStay}),n.SiteNumber!=null&&(i={name:n.CampgroundAlias+" - Select My Site",id:"sms_"+n.CampgroundID+"_"+n.SiteNumber,price:n.QuotedSiteRequestFeeAmount,brand:n.CampgroundName,category:"SMS",variant:n.SiteNumber,quantity:1},t.push(i)));dataLayer.push({event:"removeFromCart",ecommerce:{remove:{products:t}}})};this.addRewardsToCart=function(n,t){dataLayer.push({event:"addToCart",ecommerce:{add:{products:[{name:"KOA Rewards Purchase",id:"VKR-"+n,price:t,brand:"",category:"VKR",variant:"",quantity:1}]}}})};this.removeRewardsFromCart=function(n,t){dataLayer.push({event:"removeFromCart",ecommerce:{remove:{products:[{name:"KOA Rewards Purchase",id:"VKR-"+n,price:t,brand:"",category:"VKR",variant:"",quantity:1}]}}})};this.addRewardsToCartNew=function(){dataLayer.push({event:"addToCart",ecommerce:{add:{products:[{name:"KOA Rewards Purchase",id:"VKR-stand-alone-purchase",price:39,brand:"",category:"VKR",variant:"",quantity:1}]}}})};this.addRewardsToCartRenew=function(){dataLayer.push({event:"addToCart",ecommerce:{add:{products:[{name:"KOA Rewards Renewal",id:"VKR-stand-alone-renewal",price:39,brand:"",category:"VKR",variant:"",quantity:1}]}}})};this.addToCartStep3=function(n){dataLayer.push({event:"addToCart",ecommerce:{add:{actionField:{list:"SiteType - "+n.actionField},products:[{name:n.name,id:n.id,price:n.price,brand:n.brand,category:n.category,variant:n.variant,quantity:n.dimension8,dimension8:n.dimension8}]}}})};this.init()};mainGa4DataLayer=new ga4DataLayer