function AddHiddenField(n,t){var i=document.createElement("input"),r;i.type="hidden";i.name=n;i.id=n;i.value=t;r=document.getElementsByTagName("body");r&&r[0].appendChild(i)}function PersonalizationTracking(n){var t={EventId:n};t.EventId&&($.post("/Log/TrackEvent",t),Sleep(100))}function WebLogMultiple(n){$.ajax({type:"GET",data:n,url:"/Log/AppendToLogMultiple"})}function GA_Event(n){typeof n!="string"||n.length<1||_gaObj.GATrackEvent("","",n)}function TabNext(n,t,i){n.value.length==t&&i.focus()}function SetCookie(n,t,i){var i=i||{};document.cookie=[encodeURIComponent(n),"=",encodeURIComponent(t),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"; path=/",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}function GetCookieDomain(){var n=document.domain.split(".");return n.length>2?"."+n[n.length-2]+"."+n[n.length-1]:document.domain}function GetCookie(n){var i=new RegExp("("+n+")(?:=?)([^;]*)","i"),t=document.cookie.toString().match(i);return t==null||t[2]==""?null:t[2]}function GetHtmlForExternalUse(n,t,i){jQuery.ajax({type:"GET",url:n,dataType:"jsonp",success:t,error:i})}function SafeAttributeValue(n,t){var i="";return $(n).attr(t)!=null&&(i=$(n).attr(t)),i}function Sleep(n){for(var t=(new Date).getTime();(new Date).getTime()-t<n;);}function SafeUnDecodedQueryString(n){n=n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var i="[\\?&]"+n+"=([^&#]*)",r=new RegExp(i),t=r.exec(window.location.search);return t==null?"":t[1].replace(/\+/g," ")}var domainCategory="progCom",domainName=$(location).attr("hostname"),HandleException,_gaObj,progTimer,pFn;domainName.toLowerCase().indexOf("asiselect.com")>=0?domainCategory="ASI Select":domainName.toLowerCase().indexOf("driveinsurance.com")>=0&&(domainCategory="driveIns");HandleException=function(){var n={url:window.location.pathname,queryString:window.location.search,errorCategory:"JS",errorType:"Generic",sevLvl:"Error"};return function(t){t=$.extend({},n,t);$.ajax({type:"POST",url:"/Log/LogJSError",data:t})}}();window.onerror=function(n,t,i){try{var r={};n&&(r.message=n);t&&(r.url=t);i&&(r.lineNbr=i);AddHiddenField("jserror",n)}catch(u){}};$(document).ready(function(){$("*[data-trackevent], *[data-trackevent-name]").click(function(){var n={PageUrl:window.location.pathname,TargetUrl:$(this).attr("href"),Name:SafeAttributeValue(this,"data-trackevent-name"),TranTyp:SafeAttributeValue(this,"data-trackevent-trantyp"),DData1:SafeAttributeValue(this,"data-trackevent-ddata1"),IData2:SafeAttributeValue(this,"data-trackevent-idata2"),SData1:SafeAttributeValue(this,"data-trackevent-sdata1"),SData2:SafeAttributeValue(this,"data-trackevent-sdata2"),StateCode:SafeAttributeValue(this,"data-trackevent-statecode"),ProductCode:SafeAttributeValue(this,"data-trackevent-productcode")};n.Name&&n.TargetUrl&&n.TargetUrl!="#"&&($.ajax({type:"POST",url:"/Log/LogActivityToTrack",data:n}),Sleep(100))});$("*[data-weblogevent], *[data-weblogevent-name]").click(function(){var n={Name:SafeAttributeValue(this,"data-weblogevent-name"),Value:SafeAttributeValue(this,"data-weblogevent-value")};n.Name&&($.ajax({type:"POST",url:"/Log/AppendToLog",data:n}),Sleep(100))});$("*[data-gaevent], *[data-gaevent-label]").click(function(){var n={category:domainCategory,action:location.href,label:null,value:null,noninteraction:null},t={};$.each(this.attributes,function(){if(this.name.search("data-gaevent-")!=-1){var n=this.name.replace("data-gaevent-","");t[n]=this.value}});$.extend(n,t);typeof _gaObj!="undefined"&&_gaObj instanceof Object&&_gaObj.GATrackEvent(n.category,n.action,n.label,n.value,n.noninteraction);Sleep(100)});$("a[data-redirect-delay]").on("click",function(){if(!$(this).parent().hasClass("ols")){var n=$(this).attr("href");return setTimeout(function(){window.location.href=n},200),!1}});$("*[data-personalization], *[data-personalization-EventId]").click(function(){PersonalizationTracking(SafeAttributeValue(this,"data-personalization-eventid"))})});_gaObj=_gaObj||{};_gaObj.GATrackEvent=function(n,t,i,r,u,f,e){var o,s,h;if(typeof dataLayer!="undefined"){if(u=!!u,n||(n="progCom"),t||(t=document.domain+window.location.pathname),typeof r!="number"&&(r=undefined),o={event:"GAEvent",eventCategory:n,eventAction:t,eventLabel:i,eventValue:r,nonInteraction:u},typeof e=="function"&&(o.callback=e,typeof fallbackTimeoutLookup=="undefined"&&(window.fallbackTimeoutLookup=2e3),window.GACallback=setTimeout(function(){e()},fallbackTimeoutLookup),$(window).bind("pageshow",function(){window.GACallback&&clearTimeout(window.GACallback)})),typeof f!="undefined"&&$.extend(o,f),dataLayer.push(o),typeof f!="undefined"){s=$.extend({},f);for(h in s)s[h]="";dataLayer.push(s)}dataLayer.push({eventValue:0,nonInteraction:!1})}};_gaObj.GARedirectWithFallback=function(n){try{typeof fallbackTimeoutLookup=="undefined"&&(window.fallbackTimeoutLookup=2e3);dataLayer.push({event:"GARedirect",redirectUrl:n});window.redirectFallback=setTimeout(function(){window.location=n},fallbackTimeoutLookup);$(window).bind("pageshow",function(){window.redirectFallback&&clearTimeout(window.redirectFallback)})}catch(t){window.location=n}};_gaObj.GARedirect=function(n){try{window.google_tag_manager&&window._gat&&window._gat._getTracker?dataLayer.push({event:"GARedirect",redirectUrl:n}):window.location=n}catch(t){window.location=n}};_gaObj.Link=function(n){typeof dataLayer!="undefined"?(setTimeout(function(){dataLayer.push({event:"GARedirect",redirectUrl:n})},100),setTimeout(function(){window.location=n},200)):window.location=n};progTimer={};progTimer.TrackTiming=function(n,t,i){this.mData={};this.mData.PageName=window.location.pathname;this.mData.intTranData2=t||0;this.mData.strTranData4=i||"";this.urlsToTrackInGA=[".*"];this.mData.ViewportWidth=$(window).width();this.mData.ViewportHeight=$(window).height()};pFn=progTimer.TrackTiming.prototype;pFn._startTime=function(n){return this.startTime=n||(new Date).getTime(),this};pFn._endTime=function(n){return this.endTime=n||(new Date).getTime(),this};pFn._timeDiff=function(){return(this.endTime-this.startTime)/1e3};pFn.GAParms={bucket:[1,2,3,4,5,10],category:domainCategory,action:window.location.pathname,getBucket:function(n){var t;for(i=0;i<this.bucket.length;i++)if(n<this.bucket[i])if(i==0){t="0-"+this.bucket[0];break}else{t=this.bucket[i-1]+"-"+this.bucket[i];break}return t||(t=this.bucket[i-1]+"+"),t}};pFn._trackGA=function(){this._shouldTrackInGA(this.mData.PageName)&&this._sendDataToGA()};pFn._trackServer=function(){trackServer&&this._sendDataToServer()};pFn._track=function(){try{this._trackGA()}catch(n){}this._trackServer()};pFn._shouldTrackInGA=function(n){for(var t=0,i=this.urlsToTrackInGA.length;t<i;)if(n.match(this.urlsToTrackInGA[t++]))return!0};pFn._sendDataToGA=function(){var n="LoadTime_"+this.GAParms.getBucket(this._timeDiff())+"secs";_gaObj.GATrackEvent(this.GAParms.category,"pageload",n,Math.round(this._timeDiff()*1e3),!0)};pFn._sendDataToServer=function(){this.mData.ClientLoadTime=this.endTime-this.startTime;$.post("/Log/LogVisitorData",this.mData)};pFn._urlsToTrackInGA=function(n){$.type(n)==="array"&&(this.urlsToTrackInGA=n)}