;cartstackAPI.bReady=!1;window.console=typeof window.console==='undefined'?{log:function(t){return!1}}:window.console;function cs_crossDomain(t){if(xe_isset(cartstackAPI.crossDomain)){return!1};cartstackAPI.crossDomain=!0;cs_console.log('Setting up cross domain for domain: '+t);document.cookie.split(';').reduce((cookies,cookie)=>{var[name,value]=cookie.split('=').map(c=>c.trim());if(name.indexOf('xe_xdm-')>-1)document.cookie=name+'=;expires=Thu, 01 Jan 1970 00:00:01 GMT;'},{})};var cs_debug=(xe_readCookie('cs_debug')!='')?!0:!1;window.cs_console={log:function(t){return!1}};var _siteid='h49djpV3aA==',_domain='.casteloautopecas.com.br',_dguid='FB8E58C9-D756-7370-D310-EC83395D5359',cs_ref_policy=!1,_wpathname=decodeURIComponent(window.location.pathname);_wpathname=_wpathname.replace(/\/+$/,'').split('/').reverse()[0].toLowerCase().trim();var __ref='';try{__ref=decodeURIComponent('https://www.casteloautopecas.com.br/?srsltid=afmboooc_uiqfai-zqgyd7q5mdtvr02zvgqcxo8fnp9nspkb3hlitzwx')}catch(t$){__ref='https://www.casteloautopecas.com.br/?srsltid=afmboooc_uiqfai-zqgyd7q5mdtvr02zvgqcxo8fnp9nspkb3hlitzwx'};cs_ref_policy=(__ref.indexOf(_wpathname)==-1)?!0:!1;cs_debug&&console.log((cs_ref_policy)?'No referrer was sent, we need to reload!':'Referrer OK!');cs_console.log((cs_ref_policy)?'No referrer was sent, we need to reload!':'Referrer OK!');if(!cs_ref_policy){var cs_avoidCall=!1;function avoidCall(){cs_avoidCall=!0;return!0};function cs_include(){return!1};cs_console.log('CartStack PRO');var cs_pro=!0,cs_event='capture',_cartstack_pro=_cartstack_pro||[],cs_proLoaded=!1;function csPROGenProductID(t){t=(t&&typeof t==='string')?t.toLowerCase().trim():t;t=(t&&typeof t==='number')?parseInt(t):t;var r=decodeURIComponent(window.location.pathname.replace(/\/+$/,''));r=(r[0]!='/')?'/'+r:r;r=(r.substr(r.length-2)=='/p')?r.substr(0,r.length-2):r;t=(typeof t!='undefined')?r.split('/').reverse()[((typeof t==='number')?t:0)].toLowerCase().trim():t;var n='ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž',l='AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz';t=t.split('');var i=t.length,a,c;for(a=0;a=10)?parseInt(e['1'])-10:e['1']):e['1']};return e['2']};e.getHashCode=function(t){var e=0,a=(typeof t=='string')?t.length:0,r=0;while(r1)?!1:!0;var l=cs_apiRequestDiff('cart_update','days');r=(!r&&l===!1||l>1)?!1:!0;(cs_debug&&r)&&console.log('[CartStack] PRO - @csPROHit, Cart already sent... checking for a valid cart...');var n=cs_apiRequestDiff('strictcart','days');r=(r&&(n!==!1&&n===0))?!0:!1;(cs_debug&&r)&&console.log('[CartStack] PRO - @csPROHit, Cart already sent!');if(!cs_proLoaded&&!r&&(window.location.pathname!='/'||xe_isset(cs_home_bypass,'boolean'))&&i!=''){cs_proLoaded=!0;cs_debug&&console.log('[CartStack] PRO - @csPROHit, Init');cs_debug&&console.log('[CartStack] PRO - @csPROHit, Extra data: '+((t!==!1)?JSON.stringify(t):'false'));var o=xe_readCookie('cartstack.com-bwrid');if(isNaN(o)){o='';xe_deleteCookie('cartstack.com-bwrid')};var c={'domain':((typeof cs_pro_domain!=='undefined')?cs_pro_domain:_domain)};if(t!==!1&&typeof t==='object'){c.extra=JSON.stringify(t)} else{c.query=(t&&typeof t=='string'&&t!='')?t:'id='+csPROGenProductID(t)};e=(e!==!1)?'&imgt='+encodeURIComponent(window.btoa(JSON.stringify(e))):'';gmpd_alias=(gmpd_alias!==!1)?'&gmpd_alias='+gmpd_alias:'';cs_debug&&console.log('[CartStack] PRO - @csPROHit, Data.query: '+((typeof c.extra!='undefined')?c.extra:c.query));var d=encodeURIComponent(window.btoa(JSON.stringify(c)))+String(e)+String(gmpd_alias)+((cs_debug)?'&cartstacktest=true':'');_cartstack_pro.push(['setSiteID',_siteid]);_cartstack_pro.push(['setEmail',i]);if(o!='')_cartstack_pro.push(['setBrowseID',o]);_cartstack_pro.push(['setLocation','br']);_cartstack_pro.push(['setShowAlert',cs_debug]);var s=document.createElement('script');s.type='text/javascript';s.async=!0;s.src=document.location.protocol+'//app.cartstack.com.br/activeAPI/cnct/pro_rc.js?data='+d;(document.head||document.getElementsByTagName('head')[0]).appendChild(s)} else{(cs_debug&&i=='')&&console.log('[CartStack] PRO - @csPROHit, Not satisfactory send')}};if(typeof _cartstack=='undefined'||!(_cartstack instanceof Array))var _cartstack=[];var cs_datatunnel=!1;cs_datatunnel=!0;_cartstack.push(['setDataItem',{'account_number':'17486'}]);_cartstack.push(['setDataItem',{'platform_carturl':'?utm_source=CartStack&utm_medium=Email&utm_campaign=CarrinhoAbandonado'}]);var _cartstack=_cartstack||[];_cartstack.push(['setSiteID','h49djpV3aA==']);_cartstack.push(['setAPI','capture']);_cartstack.push(['setLocation','br']);if(typeof csPROHit=='function'&&document.querySelectorAll('#produtos').length>0){if(typeof csPROHitExtra==='function'){cs_debug&&console.log('Calling the new function...');csPROHitExtra()} else csPROHit(((typeof cs_pro_extradata!='undefined')?cs_pro_extradata:''))};cs_debug&&console.log('[CartStack] csCart - Loaded!');function _csCartItem(){var t=Array.prototype.slice.call(arguments),e=this;Object.keys(t[0]).forEach(function(r){var a=r,c=t[0][r];e[a]=c});this.totalPrice=function(){return(this.priceFloat>0.1)?this.priceFloat*this.quantity:0};return this};window._csCart={_cartstack:[],helper:{_cartstackFind:function(t,e,r){var s=0,c=!1;e=(this.isset(e,'boolean')&&e)?!0:!1;r=(typeof r!=='undefined'&&r!==null)?r:_csCart._cartstack;for(var a=0;a]+(>|$)/g,'');t=t.replace(/\s+/g,' ');t=t.replace(' ',' ');return t},replaceAll:function(t,e,r,a){r=this.fixStr(r);r=(r!='')?r.replace(new RegExp(t,'g'),e):!1;r=(r===!1)?a:r;return r},toFloat:function(t){t=this.fixStr(t);function e(t){if(parseInt(t)!='NaN'){t=parseFloat(t)+0;return(/[.]/.test(t)&&!/[,]/.test(t))};return!1};if(t==''||(/[.]/.test(t)&&!/[,]/.test(t)))return t;t=t.replace(/[^0-9,.]/g,'',t);t=(/[.]/.test(t)&&/[,]/.test(t))?t.replace('.','').replace(',','.',t):((!e(t))?t.replace(',','.',t.replace('.','',t)):t);return t},toCurrency:function(t){var a=null,e=null,r=null,c=null,s=[];t=''+t;r=t.indexOf('.',0);if(r>0){a=t.substring(0,r);e=t.substring(r+1,t.length)} else{a=t};for(c=a.length,r=0;c>0;c-=3,r++){s[r]=a.substring(c-3,c)};a='';for(r=s.length-1;r>=0;r--){a+=s[r]+'.'};a=a.substring(0,a.length-1);e=parseInt(e);if(isNaN(e)){e='00'} else{e=''+e;if(e.length===1){e=e+'0'}};t=a+','+e.substr(0,2);return t},parseURL:function(t){var e=document.createElement('a'),s={},a,c,r;e.href=t;a=e.search.replace(/^\?/,'').split('&');for(r=0;r-1)?t:((t[0]=='/'&&t[1]=='/')?_csCart.helper.getProtocol()+t:_csCart.helper.getDomain()+((t[0]=='/')?t:'/'+t));this.item.productURL=_csCart.helper.fixStr(t);if(e&&typeof e!=='undefined'){this.item.dataTransform=e}},setImageURL:function(t,e,r){e=(_csCart.helper.isset(e,'boolean'))?e:!0;if(this.item==!1||!_csCart.helper.isset(t,'string'))return!1;if(e){t=(t.toLowerCase().indexOf('http')>-1)?t:((t[0]=='/'&&t[1]=='/')?_csCart.helper.getProtocol()+t:_csCart.helper.getDomain()+((t[0]=='/')?t:'/'+t))};this.item.productImageURL=_csCart.helper.fixStr(t);if(r&&typeof r!=='undefined'){this.item.dataTransform=r}},setImageWidth:function(t){this.item.imageWidth=(t=='')?'100':t},setPrice:function(t){if(this.item==!1||!_csCart.helper.isset(t))return!1;this.item.productPrice=_csCart.helper.replaceAll('[^0-9.,]+','',t,((t==-1)?'':'Consulte'))},setButtonText:function(t){if(this.item==!1||!_csCart.helper.isset(t,'string'))return!1;this.item.viewProductLinkText=_csCart.helper.stripHTML(t)},setCallback:function(t,e){if(this.item==!1||!_csCart.helper.isset(t,'string')||typeof e!=='function')return!1;this.item[t]=!1;this.callbacks[t]=e}},clearItems:function(){_csCart._cartstack=[]},hasCart:function(){var t=xe_readCookie('cartstack.com-cart')||!1;return(t===!1)?0:parseInt(t)},createProduct:function(){this.product.item={}},addProduct:function(){var e=this.product.def_item,r=[],t=!0;Object.keys(this.product.item).forEach(function(r){var c=r,a=_csCart.product.item[r],s=_csCart.product.item.dataTransform;t=!0;switch(c){case'quantity':t=(parseInt(a)!='NaN')?!0:!1;e.quantity=(t)?a:e.quantity;break;case'productName':t=(a.length>=3)?!0:!1;a=(t)?a:e.productName;e.productName=_csCart.helper.dataTransform(a,s);break;case'productDescription':t=(a.length>3)?!0:!1;a=(t)?a:e.productDescription;e.productDescription=_csCart.helper.dataTransform(a,s);break;case'productURL':t=(a==''||a.toLowerCase().indexOf('http')>-1)?!0:!1;a=(t)?a:e.productURL;e.productURL=_csCart.helper.dataTransform(a,s);break;case'productImageURL':t=(a==''||a.toLowerCase().indexOf('http')>-1)?!0:!1;a=(t)?a:e.productImageURL;e.productImageURL=_csCart.helper.dataTransform(a,s);break;case'productPrice':t=(/[.]/.test(a)||/[,]/.test(a))?!0:!1;e.productPrice=(t)?a:e.productPrice;e.priceFloat=(e.productPrice!='Consulte')?_csCart.helper.toFloat(a):0;break;default:e.customFields=[];if(_csCart.product.callbacks[c]&&typeof _csCart.product.callbacks[c]==='function'){t=!0;try{a=_csCart.product.callbacks[c](e);cs_debug&&console.info('[CartStack] csCart - @addProduct, Callback: @'+c+' return result: '+a)}catch(o){t=!1;cs_debug&&console.t$('[CartStack] csCart - @addProduct, Callback: @'+c+' exception!')};if(t&&a!==!1){let cfield={};cfield[c]=a;e.customFields.push(cfield)}} else{cs_debug&&console.error('[CartStack] csCart - @addProduct, Callback: @'+c+' was not registered!')}}});Object.keys(e).forEach(function(t){var a=t,c=e[t];if(c===!1)r.push(a)});t=(r.length===0)?!0:!1;if(t){var c=new _csCartItem(e);for(var a=0;a0&&console.log('[CartStack] csCart - @addProduct, Product not added... Missing info: '+this.helper.replaceAll('product','',r.toString()));r.length==0&&console.log('[CartStack] csCart - @addProduct, Product not added... Duplicated product: '+e.productName)}};this.product.item=!1;return t},setTotalPrice:function(t){var e=0;if((!_csCart.helper.isset(t,'string')||t=='')){if(this.products.length>0){cs_debug&&console.log('[CartStack] csCart - @setTotalPrice, Auto calculating total price...');for(var r=0;r0){e=_csCart.helper.toCurrency(String(e));_csCart.helper._cartstackSet('setCartTotal',String(e));cs_debug&&console.log('[CartStack] csCart - @setTotalPrice, Auto calculated total price: R$ '+e)} else cs_debug&&console.log('[CartStack] csCart - @setTotalPrice, No price given and no products with price!')} else cs_debug&&console.log('[CartStack] csCart - @setTotalPrice, No products to auto calculate total price!')} else{if(this.helper.toFloat(t)!=''){e=_csCart.helper.replaceAll('[^0-9.,]+','',t,'');_csCart.helper._cartstackSet('setCartTotal',String(e));cs_debug&&console.log('[CartStack] csCart - @setTotalPrice, Total price set: R$ '+e)} else{cs_debug&&console.log('[CartStack] csCart - @setTotalPrice, No price was given...');this.setTotalPrice()}}},saveCart:function(t){if(this.cartEvent==2){cs_debug&&console.log('[CartStack] csCart - @saveCart, Can\'t save cart! Cart already sent...');return!1};t=(typeof t==='undefined'||t===null)?!0:t;if(this.products.length>0){xe_createCookie('cartstack.com-cart',this.products.length,1);for(var e=0;e0){for(var a=0;a0){cs_debug&&console.log('[CartStack] @waitFor - Element: "'+e.key+'" found! Calling callback...');if(e.active===null||r===!0||(c.helper.isset(r,'string')&&!jQuery(e.element).hasAttr(r)))e.callback(e.key,e.element);e.active=(r!==!1)?!0:!1}}}})})}),i={attributes:!0,childList:!0,characterData:!1,subtree:!0};o.observe(document,i)}};return!0}};avoidCall();_csCart.helper._cartstackSet('setDataItem',{'CartSession':'?utm_source=CartStack&utm_medium=Email&utm_campaign=CarrinhoAbandonado'});var done=!1;function cs_loadCart(){if(!done){jQuery('div.listagem-itens-carrinho:eq(0) ul').children('li').each(function(){!done&&cs_debug&&console.log('Cart Method 1')&&cs_console('Cart Method 1');_csCart.createProduct();_csCart.product.setName(jQuery(this).find('span.descricao span.titulo').text()||'');_csCart.product.setQuantity(jQuery(this).find('span.descricao span.quantidade').text()||'1');var t=jQuery(this).find('span.imagem img').attr('src')||'';if(typeof csUpdateImage!='undefined'){t=t.replace('/tiny/','/media/')};_csCart.product.setImageURL(t);_csCart.product.setPrice(jQuery(this).find('span.descricao span.valor').text()||'');_csCart.product.setURL(jQuery(this).find('a').attr('href')||'');_csCart.addProduct();done=!0});_csCart.setTotalPrice(jQuery('span.subtotal-resumo-carrinho:eq(0)').text()||'')};if(!done){!done&&cs_debug&&console.log('No Methods Found')&&cs_console('No Methods Found')};if(typeof csModifyOuterDiv!='undefined'){cs_debug&&console.log('manipulate outer div!! ');_csCart.helper._cartstackSet('setDataItem',{'MainTableCSS':'width:100%;'})};if(done==!0){_csCart.saveCart();_csCart.sendCart(!0)}};_csMutation.waitFor('ajax_shoppingcart','div.listagem-itens-carrinho:eq(0) ul li',function(t,e){window.setTimeout(function(){cs_loadCart()},2000)},!1)} else{cs_debug&&cs_console.log('Calling empty @getRefPolicy');cs_debug&&console.log('Reloading passing the window location and reseting cartstack vars...');_cartstack=[];function cs_getRefPolicy(t){t=(t&&typeof t!='undefined')?t:!1;var r=xex_cartstackbr.getProc().replace('auto',window.btoa(window.location.href))+((t)?'&store_id='+t:'')+'&ref_policy=true',a=document.getElementsByTagName('head')[0],e=document.createElement('script');e.src=r;a.appendChild(e);cs_ref_policy=!0;return!0};window.setTimeout(function(){var t=!1;cs_console.log('Reloading passing the window location...');cs_getRefPolicy(t)},1500)};cs_debug&&console.log('CartStack processing finished...');cartstackAPI.bReady=!0;