function setcookie(n,t,i){var u=new Date,r=new Date;r.setTime(u.getTime()+864e5*i);document.cookie=n+"="+escape(t)+";expires="+r.toGMTString()}function CouponEvent(){window.dataLayer.push({event:"Click",action:"Coupon Banner"})}(function(n,t){function a(){n.removeEventListener("load",a,!1);e=!0}function i(n){return o=o||new i.Class(n)}function c(n,t){for(var i in t)n[i]=t[i];return n}function v(){t.location.hash=="#ath"&&history.replaceState("",n.document.title,t.location.href.split("#")[0]);u.test(t.location.href)&&history.replaceState("",n.document.title,t.location.href.replace(u,"$1"));f.test(t.location.search)&&history.replaceState("",n.document.title,t.location.href.replace(f,"$2"))}var l="addEventListener"in n,e=!1,u,f,o,r,s,h;t.readyState==="complete"?e=!0:l&&n.addEventListener("load",a,!1);u=/\/ath(\/)?$/;f=/([\?&]ath=[^&]*$|&ath=[^&]*(&))/;i.defaults={appID:"org.cubiq.addtohome",fontSize:15,debug:!1,logging:!1,modal:!1,mandatory:!1,autostart:!0,skipFirstVisit:!1,startDelay:1,lifespan:15,displayPace:1440,maxDisplayCount:0,icon:!1,message:"",validLocation:[],onInit:null,onShow:null,onRemove:null,onAdd:null,onPrivate:null,privateModeOverride:!1,detectHomescreen:!1};r=n.navigator.userAgent;s=n.navigator;c(i,{hasToken:t.location.hash=="#ath"||u.test(t.location.href)||f.test(t.location.search),isRetina:n.devicePixelRatio&&n.devicePixelRatio>1,isIDevice:/iphone|ipod|ipad/i.test(r),isMobileChrome:r.indexOf("Android")>-1&&/Chrome\/[.0-9]*/.test(r)&&r.indexOf("Version")==-1,isMobileIE:r.indexOf("Windows Phone")>-1,language:s.language&&s.language.toLowerCase().replace("-","_")||""});i.isMobileSafari=i.isIDevice&&r.indexOf("Safari")>-1&&r.indexOf("CriOS")<0;i.OS=i.isIDevice?"ios":i.isMobileChrome?"android":i.isMobileIE?"windows":"unsupported";i.OSVersion=r.match(/(OS|Android) (\d+[_\.]\d+)/);i.OSVersion=i.OSVersion&&i.OSVersion[2]?+i.OSVersion[2].replace("_","."):0;i.isStandalone="standalone"in n.navigator&&n.navigator.standalone;i.isTablet=i.isMobileSafari&&r.indexOf("iPad")>-1||i.isMobileChrome&&r.indexOf("Mobile")<0;i.isCompatible=i.isMobileSafari&&i.OSVersion>=6||i.isMobileChrome;h={lastDisplayTime:0,returningVisitor:!1,displayCount:0,optedout:!1,added:!1};i.removeSession=function(n){try{if(!localStorage)throw new Error("localStorage is not defined");localStorage.removeItem(n||i.defaults.appID)}catch(t){}};i.doLog=function(n){this.options.logging&&console.log(n)};i.Class=function(r){var u,f;if(this.doLog=i.doLog,this.options=c({},i.defaults),c(this.options,r),this.options&&this.options.debug&&typeof this.options.logging=="undefined"&&(this.options.logging=!0),l){if(this.options.mandatory=this.options.mandatory&&("standalone"in n.navigator||this.options.debug),this.options.modal=this.options.modal||this.options.mandatory,this.options.mandatory&&(this.options.startDelay=-.5),this.options.detectHomescreen=this.options.detectHomescreen===!0?"hash":this.options.detectHomescreen,this.options.debug&&(i.isCompatible=!0,i.OS=typeof this.options.debug=="string"?this.options.debug:i.OS=="unsupported"?"android":i.OS,i.OSVersion=i.OS=="ios"?"8":"4"),this.container=t.body,this.session=this.getItem(this.options.appID),this.session=this.session?JSON.parse(this.session):undefined,!i.hasToken||i.isCompatible&&this.session||(i.hasToken=!1,v()),!i.isCompatible){this.doLog("Add to homescreen: not displaying callout because device not supported");return}this.session=this.session||h;try{if(!localStorage)throw new Error("localStorage is not defined");localStorage.setItem(this.options.appID,JSON.stringify(this.session));i.hasLocalStorage=!0}catch(e){i.hasLocalStorage=!1;this.options.onPrivate&&this.options.onPrivate.call(this)}for(u=!this.options.validLocation.length,f=this.options.validLocation.length;f--;)if(this.options.validLocation[f].test(t.location.href)){u=!0;break}if(this.getItem("addToHome")&&this.optOut(),this.session.optedout){this.doLog("Add to homescreen: not displaying callout because user opted out");return}if(this.session.added){this.doLog("Add to homescreen: not displaying callout because already added to the homescreen");return}if(!u){this.doLog("Add to homescreen: not displaying callout because not a valid location");return}if(i.isStandalone){this.session.added||(this.session.added=!0,this.updateSession(),this.options.onAdd&&i.hasLocalStorage&&this.options.onAdd.call(this));this.doLog("Add to homescreen: not displaying callout because in standalone mode");return}if(this.options.detectHomescreen){if(i.hasToken){v();this.session.added||(this.session.added=!0,this.updateSession(),this.options.onAdd&&i.hasLocalStorage&&this.options.onAdd.call(this));this.doLog("Add to homescreen: not displaying callout because URL has token, so we are likely coming from homescreen");return}this.options.detectHomescreen=="hash"?history.replaceState("",n.document.title,t.location.href+"#ath"):this.options.detectHomescreen=="smartURL"?history.replaceState("",n.document.title,t.location.href.replace(/(\/)?$/,"/ath$1")):history.replaceState("",n.document.title,t.location.href+(t.location.search?"&":"?")+"ath=")}if(!this.session.returningVisitor&&(this.session.returningVisitor=!0,this.updateSession(),this.options.skipFirstVisit)){this.doLog("Add to homescreen: not displaying callout because skipping first visit");return}if(!this.options.privateModeOverride&&!i.hasLocalStorage){this.doLog("Add to homescreen: not displaying callout because browser is in private mode");return}this.ready=!0;this.options.onInit&&this.options.onInit.call(this);this.options.autostart&&(this.doLog("Add to homescreen: autostart displaying callout"),this.show())}};i.Class.prototype={events:{load:"_delayedShow",error:"_delayedShow",orientationchange:"resize",resize:"resize",scroll:"resize",click:"remove",touchmove:"_preventDefault",transitionend:"_removeElements",webkitTransitionEnd:"_removeElements",MSTransitionEnd:"_removeElements"},handleEvent:function(n){var t=this.events[n.type];t&&this[t](n)},show:function(r){var u,f,o;if(this.options.autostart&&!e){setTimeout(this.show.bind(this),50);return}if(this.shown){this.doLog("Add to homescreen: not displaying callout because already shown on screen");return}if(u=Date.now(),f=this.session.lastDisplayTime,r!==!0){if(!this.ready){this.doLog("Add to homescreen: not displaying callout because not ready");return}if(u-f<this.options.displayPace*6e4){this.doLog("Add to homescreen: not displaying callout because displayed recently");return}if(this.options.maxDisplayCount&&this.session.displayCount>=this.options.maxDisplayCount){this.doLog("Add to homescreen: not displaying callout because displayed too many times already");return}}this.shown=!0;this.session.lastDisplayTime=u;this.session.displayCount++;this.updateSession();this.applicationIcon||(this.applicationIcon=i.OS=="ios"?t.querySelector('head link[rel^=apple-touch-icon][sizes="152x152"],head link[rel^=apple-touch-icon][sizes="144x144"],head link[rel^=apple-touch-icon][sizes="120x120"],head link[rel^=apple-touch-icon][sizes="114x114"],head link[rel^=apple-touch-icon]'):t.querySelector('head link[rel^="shortcut icon"][sizes="196x196"],head link[rel^=apple-touch-icon]'));o="<a target='_blank' href='https://www.youtube.com/c/Carsaddiction?sub_confirmation=1'><p>Check out our video content<\/p><img src='/images/youtube-ca.jpg' /> <br/><span class='btn btn-dark'>Unique and tailored content only on cars!<\/span><\/a><p><\/p>";this.viewport=t.createElement("div");this.viewport.className="ath-viewport";this.options.modal&&(this.viewport.className+=" ath-modal");this.options.mandatory&&(this.viewport.className+=" ath-mandatory");this.viewport.style.position="absolute";this.element=t.createElement("div");this.element.className="ath-container ath-"+i.OS+" ath-"+i.OS+(parseInt(i.OSVersion)||"")+" ath-"+(i.isTablet?"tablet":"phone");this.element.style.cssText="-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0s;-webkit-transition-timing-function:ease-out;transition-property:transform,opacity;transition-duration:0s;transition-timing-function:ease-out;";this.element.style.webkitTransform="translate3d(0,-"+n.innerHeight+"px,0)";this.element.style.transform="translate3d(0,-"+n.innerHeight+"px,0)";this.options.icon&&this.applicationIcon&&(this.element.className+=" ath-icon",this.img=t.createElement("img"),this.img.className="ath-application-icon",this.img.addEventListener("load",this,!1),this.img.addEventListener("error",this,!1),this.img.src=this.applicationIcon.href,this.element.appendChild(this.img));this.element.innerHTML+=o;this.viewport.style.left="-99999em";this.viewport.appendChild(this.element);this.container.appendChild(this.viewport);this.img?this.doLog("Add to homescreen: not displaying callout because waiting for img to load"):this._delayedShow()},_delayedShow:function(){setTimeout(this._show.bind(this),this.options.startDelay*1e3+500)},_show:function(){var i=this;this.updateViewport();n.addEventListener("resize",this,!1);n.addEventListener("scroll",this,!1);n.addEventListener("orientationchange",this,!1);this.options.modal&&t.addEventListener("touchmove",this,!0);this.options.mandatory||setTimeout(function(){i.element.addEventListener("click",i,!0)},1e3);setTimeout(function(){i.element.style.webkitTransitionDuration="1.2s";i.element.style.transitionDuration="1.2s";i.element.style.webkitTransform="translate3d(0,0,0)";i.element.style.transform="translate3d(0,0,0)"},0);this.options.lifespan&&(this.removeTimer=setTimeout(this.remove.bind(this),this.options.lifespan*1e3));this.options.onShow&&this.options.onShow.call(this)},remove:function(){clearTimeout(this.removeTimer);this.img&&(this.img.removeEventListener("load",this,!1),this.img.removeEventListener("error",this,!1));n.removeEventListener("resize",this,!1);n.removeEventListener("scroll",this,!1);n.removeEventListener("orientationchange",this,!1);t.removeEventListener("touchmove",this,!0);this.element.removeEventListener("click",this,!0);this.element.addEventListener("transitionend",this,!1);this.element.addEventListener("webkitTransitionEnd",this,!1);this.element.addEventListener("MSTransitionEnd",this,!1);this.element.style.webkitTransitionDuration="0.3s";this.element.style.opacity="0"},_removeElements:function(){this.element.removeEventListener("transitionend",this,!1);this.element.removeEventListener("webkitTransitionEnd",this,!1);this.element.removeEventListener("MSTransitionEnd",this,!1);this.container.removeChild(this.viewport);this.shown=!1;this.options.onRemove&&this.options.onRemove.call(this)},updateViewport:function(){var r,u;this.shown&&(this.viewport.style.width=n.innerWidth+"px",this.viewport.style.height=n.innerHeight+"px",this.viewport.style.left=n.scrollX+"px",this.viewport.style.top=n.scrollY+"px",r=t.documentElement.clientWidth,this.orientation=r>t.documentElement.clientHeight?"landscape":"portrait",u=i.OS=="ios"?this.orientation=="portrait"?screen.width:screen.height:screen.width,this.scale=screen.width>r?1:u/n.innerWidth,this.element.style.fontSize=this.options.fontSize/this.scale+"px")},resize:function(){clearTimeout(this.resizeTimer);this.resizeTimer=setTimeout(this.updateViewport.bind(this),100)},updateSession:function(){i.hasLocalStorage!==!1&&localStorage&&localStorage.setItem(this.options.appID,JSON.stringify(this.session))},clearSession:function(){this.session=h;this.updateSession()},getItem:function(n){try{if(!localStorage)throw new Error("localStorage is not defined");return localStorage.getItem(n)}catch(t){i.hasLocalStorage=!1}},optOut:function(){this.session.optedout=!0;this.updateSession()},optIn:function(){this.session.optedout=!1;this.updateSession()},clearDisplayCount:function(){this.session.displayCount=0;this.updateSession()},_preventDefault:function(n){n.preventDefault();n.stopPropagation()}};n.addToHomescreen=i})(window,document);$(function(){function n(){var n=$(".navbar-collapse #SearchForm.active");n.find("input").val("");n.removeClass("active")}$('body, .navbar-collapse div[role="search"] button[type="reset"]').on("click keyup",function(t){(t.which===27&&$(".navbar-collapse #SearchForm").hasClass("active")||$(t.currentTarget).attr("type")==="reset")&&n()});$(document).on("click","#btnSearch",function(n){n.preventDefault();var t=$("#SearchForm"),i=t.find("input");$("#SearchForm").hasClass("active")?window.location.href="/search?q="+$("#txtSearch").val():(t.addClass("active"),i.focus())});$("#txtSearch").keyup(function(n){n.which===13&&$("#btnSearch").click()})});document.cookie.indexOf("HideHome=true")<0&&(addToHomescreen(),window.dataLayer.push({event:"Notification",Action:"AddToHomescreen"}),setcookie("HideHome","true","90"));$("#btnNotif").click(function(){setcookie("HideAlert","true","7")});window.CouponCode=function(n,t,i,r){var u,f;document.cookie.indexOf("HideAlert=true")>=0?$("#NotifBar").remove():(u=new Date(i+"T23:59:59"),typeof r=="undefined"&&(r="everything"),u>=new Date&&(window.dataLayer.push({event:"Notification",Action:"CouponCode"}),setTimeout(function(){$("#NotifBar").css("display","block")},800),u.toUTCString(),f=setInterval(function(){var e=(new Date).getTime(),i=u-e,o=Math.floor(i/864e5),s=Math.floor(i%864e5/36e5),h=Math.floor(i%36e5/6e4),c=Math.floor(i%6e4/1e3);document.getElementById("NotifText").innerHTML='<a href="http://www.carsaddiction.com/shop" onclick="return CouponEvent();">Get down with <b>'+n+"<\/b> off "+r+". Use <b>"+t+"<\/b>.<\/a> Expires in "+o+"d "+s+"h "+h+"m "+c+"s ";i<0&&(clearInterval(f),$("#NotifBar").remove())},1e3)))};window.PushEvent=function(n,t){dataLayer.push({event:n,action:t})};var scrolltotop={setting:{startline:100,scrollto:0,scrollduration:1e3,fadeduration:[500,100]},controlHTML:"",controlattrs:{offsetx:5,offsety:5},anchorkeyword:"#top",state:{isvisible:!1,shouldvisible:!1},scrollup:function(){this.cssfixedsupport||this.$control.css({opacity:0});var n=isNaN(this.setting.scrollto)?this.setting.scrollto:parseInt(this.setting.scrollto);n="string"==typeof n&&1==jQuery("#"+n).length?jQuery("#"+n).offset().top:0;this.$body.animate({scrollTop:n},this.setting.scrollduration)},keepfixed:function(){var n=jQuery(window),t=n.scrollLeft()+n.width()-this.$control.width()-this.controlattrs.offsetx,i=n.scrollTop()+n.height()-this.$control.height()-this.controlattrs.offsety;this.$control.css({left:t+"px",top:i+"px"})},togglecontrol:function(){var n=jQuery(window).scrollTop();this.cssfixedsupport||this.keepfixed();this.state.shouldvisible=n>=this.setting.startline;this.state.shouldvisible&&!this.state.isvisible?(this.$control.stop().animate({opacity:1},this.setting.fadeduration[0]),this.state.isvisible=!0):0==this.state.shouldvisible&&this.state.isvisible&&(this.$control.stop().animate({opacity:0},this.setting.fadeduration[1]),this.state.isvisible=!1)},init:function(){jQuery(document).ready(function(n){var t=scrolltotop,i=document.all;t.cssfixedsupport=!i||i&&"CSS1Compat"==document.compatMode&&window.XMLHttpRequest;t.$body=window.opera?"CSS1Compat"==document.compatMode?n("html"):n("body"):n("html,body");t.$control=n('<div id="topcontrol">'+t.controlHTML+"<\/div>").css({position:t.cssfixedsupport?"fixed":"absolute",bottom:t.controlattrs.offsety,right:t.controlattrs.offsetx,opacity:0,cursor:"pointer"}).attr({title:"Scroll Back to Top"}).click(function(){return t.scrollup(),!1}).appendTo("body");document.all&&!window.XMLHttpRequest&&""!=t.$control.text()&&t.$control.css({width:t.$control.width()});t.togglecontrol();n('a[href="'+t.anchorkeyword+'"]').click(function(){return t.scrollup(),!1});n(window).bind("scroll resize",function(){t.togglecontrol()})})}};scrolltotop.init()