var currentPage=2;"function"!=typeof String.prototype.replaceSpecialChars&&(String.prototype.replaceSpecialChars=function(){var b={"ç":"c","æ":"ae","œ":"oe","á":"a","é":"e","í":"i","ó":"o","ú":"u","à":"a","è":"e","ì":"i","ò":"o","ù":"u","ä":"a","ë":"e","ï":"i","ö":"o","ü":"u","ÿ":"y","â":"a","ê":"e","î":"i","ô":"o","û":"u","å":"a","ã":"a","ø":"o","õ":"o",u:"u","Á":"A","É":"E","Í":"I","Ó":"O","Ú":"U","Ê":"E","Ô":"O","Ü":"U","Ã":"A","Õ":"O","À":"A","Ç":"C"};return this.replace(/[\u00e0-\u00fa]/g,function(a){return"undefined"!=typeof b[a]?b[a]:a})}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),jQuery.fn.vtexSmartResearch=function(opts){$this=jQuery(this);var log=function(msg,type){"object"==typeof console&&console.log("[Smart Research - "+(type||"Error")+"] "+msg)},defaults={fullResults:!0,pageLimit:null,filtersFullWrapper:"#filters",loadContent:".prateleira[id^=ResultItems]",shelfClass:".prateleira",filtersMenu:".search-multiple-navigator",linksMenu:".search-single-navigator",menuDepartament:".navigation .menu-departamento",mergeMenu:!1,insertMenuAfter:".search-multiple-navigator h3:first",emptySearchElem:jQuery('
'),elemLoading:'
Loading...
',emptySearchMsg:"

There are no results matching your filters

",filterErrorMsg:"Theres was an error whle filtering the results.",smartFilters:void 0,trackGTM:!1,showFiltersQty:!0,searchUrl:null,showLinks:!1,orderByToCustom:!1,orderByCustomPlace:null,showAppliedFilters:!1,showAppliedFiltersTags:!1,clearFiltersLink:!1,clearFiltersLinkPlace:null,clearFiltersLinkText:"Borrar Filtros",productsMergeClass:"product-list n1colunas",callback:function(){},getShelfHeight:function(container){return container.scrollTop()+container.height()},shelfCallback:function(){},ajaxCallback:function(){},emptySearchCallback:function(){},authorizeScroll:function(){return!0},authorizeUpdate:function(){return!0},labelCallback:function(data){}},options=jQuery.extend(defaults,opts),$empty=("object"==typeof console,jQuery("")),elemLoading=jQuery(options.elemLoading),moreResults=!0,_window=jQuery(window),body=(jQuery(document),jQuery("html,body"),jQuery("body")),currentSearchUrl="",urlFilters="",searchUrl="",animatingFilter=!1,loadContentE=jQuery(options.loadContent),filtersMenuE=jQuery(options.filtersMenu),filtersFullWrapperE=jQuery(options.filtersFullWrapper),smartFiltersWrapperE=jQuery(options.smartFilters),ajaxCallbackObj={requests:0,filters:0,isEmpty:!1},trackGTM=options.trackGTM,orderByToCustom=options.orderByToCustom,orderByCustomPlace=jQuery(options.orderByCustomPlace),labelCallbackData={},fn={getUrl:function(scroll){var s=scroll||!1;return s?currentSearchUrl.replace(/PageNumber=[0-9]*/,"PageNumber="+currentPage):(searchUrl+urlFilters).replace(/PageNumber=[0-9]*/,"PageNumber="+pageNumber)},getSearchUrl:function(){var url,content,preg;return jQuery("script:not([src])").each(function(){if(content=jQuery(this)[0].innerHTML,preg=/\/buscapagina\?.+&PageNumber=/i,content.search(/\/buscapagina\?/i)>-1)return url=preg.exec(content),!1}),"undefined"!=typeof url&&"undefined"!=typeof url[0]?url[0]:(log("Search Page URL not found.\n Try adding the .js file at the end of the document. \n[Method: getSearchUrl]"),"")},infinitScroll:function(){var elementPages,pages,currentStatus,tmp;elementPages=body.find(".pager:first").attr("id"),tmp=(elementPages||"").split("_").pop(),pages=null!==options.pageLimit?options.pageLimit:window["pagecount_"+tmp],currentStatus=!0,"undefined"==typeof pages&&(pages=99999999),_window.bind("scroll",function(){var _this=jQuery(this);if(!(!animatingFilter&¤tPage<=pages&&moreResults&&options.authorizeScroll(ajaxCallbackObj)))return!1;if(_this.scrollTop()+_this.height()>=options.getShelfHeight(loadContentE)&¤tStatus){var currentItems=loadContentE;loadContentE.find(options.shelfClass).length>0&&(currentItems=loadContentE.find(options.shelfClass)),filtersFullWrapperE.addClass("locked"),smartFiltersWrapperE.length>0&&smartFiltersWrapperE.find(".filter-group").addClass("locked"),jQuery("#filters .mobile-wrapper .info span").addClass("show"),currentItems.after(elemLoading),currentStatus=!1,pageJqxhr=jQuery.ajax({url:fn.getUrl(!0),success:function(data){data.trim().length<1?(moreResults=!1,log("No more resultas after page "+(currentPage-1),"Warning")):(data=data.replace('
',""),data=data.replace("
",""),currentItems.append(data)),currentStatus=!0,elemLoading.remove(),filtersFullWrapperE.removeClass("locked"),smartFiltersWrapperE.length>0&&smartFiltersWrapperE.find(".filter-group").removeClass("locked"),jQuery("#filters .mobile-wrapper .info span").removeClass("show"),ajaxCallbackObj.requests++,options.ajaxCallback(ajaxCallbackObj)}}),currentPage++}})}};if(currentSearchUrl=searchUrl=null!==options.searchUrl?options.searchUrl:fn.getSearchUrl(),$this.length<1)return log("No filters options found","Warning"),options.showLinks&&jQuery(options.linksMenu).css("visibility","visible").show(0),fn.infinitScroll(),$this;if(loadContentE.length<1)return log("Results container Element not found \n ("+loadContentE.selector+")"),!1;filtersMenuE.length<1&&log("Filters menu not found \n ("+filtersMenuE.selector+")");var linksMenuE=(document.location.href,jQuery(options.linksMenu)),prodOverlay=jQuery('
'),departamentE=jQuery(options.menuDepartament),pageNumber=(loadContentE.offset(),1),shelfJqxhr=null,pageJqxhr=null;options.emptySearchElem.append(options.emptySearchMsg),loadContentE.before(prodOverlay);var fns={exec:function(){fns.fieldsetFormat(),$this.each(function(){var _this=jQuery(this),label=_this.parent();_this.is(":checked")&&(urlFilters+="&"+(_this.attr("rel")||""),label.addClass("sr_selected")),fns.adjustText(_this),_this.bind("change",function(){fns.inputAction(_this),_this.is(":checked")?fns.addFilter(_this):fns.removeFilter(_this),ajaxCallbackObj.filters=$this.filter(":checked").length,fns.evaluateNextSmartFilter()})}),smartFiltersWrapperE.length>0&&(jQuery("#filters fieldset label").click(function(e){e.stopPropagation()}),smartFiltersWrapperE.find("a").each(function(){jQuery(this).click(function(e){e.preventDefault();var fiterToApply="."+jQuery(this).data("filter");jQuery(fiterToApply).trigger("click")})}),jQuery(".filter-group").eq(0).addClass("open")),""!==urlFilters&&fns.addFilter($empty)},evaluateNextSmartFilter:function(){var currentFilterGroup=filtersMenuE.find('fieldset:not(".clear-filters-link, .orderBy")').not(":has(.sr_selected)").first().attr("class");currentFilterGroup?(currentFilterGroup=currentFilterGroup.replace("refino","").replace("even","").replace("Características","").replace("open","").replace(/\s/g,""),currentFilterGroup="."+currentFilterGroup,currentFilterGroup=currentFilterGroup.replace(/[[]/g,"").replace(/]/g,"_"),smartFiltersWrapperE.find(".filter-group").removeClass("open"),smartFiltersWrapperE.find(currentFilterGroup).addClass("open")):smartFiltersWrapperE.find(".filter-group").removeClass("open")},mergeMenu:function(){if(!options.mergeMenu)return!1;var elem=departamentE;elem.insertAfter(options.insertMenuAfter),fns.departamentMenuFormat(elem)},mergeMenuList:function(){var i=0;filtersMenuE.find("h3,h4").each(function(){var ul=linksMenuE.find("h3,h4").eq(i).next("ul");ul.insertAfter(jQuery(this)),fns.departamentMenuFormat(ul),i++})},departamentMenuFormat:function(elem){elem.find("a").each(function(){var a=jQuery(this);a.text(fns.removeCounter(a.text()))})},fieldsetFormat:function(){function getFieldOrder(fieldTitle){var fieldOrder=fieldTitle.text().match(/\[([^)]+)\]/);return null!=fieldOrder?(fieldTitle.text(fieldTitle.text().replace(/\[.*?\]/g,"")),fieldTitle.parent().css("order",fieldOrder[1]),fieldOrder[1]):(fieldTitle.parent().css("order",noFieldOrderBase.toString()),noFieldOrderBase++,noFieldOrderBase-1)}function sortMe(a,b){return a.className>b.className}var smartFiltersTemplateCollection=new Array,noFieldOrderBase=99;if(labelCallbackData.fieldsetCount=0,labelCallbackData.tmpCurrentLabel={},filtersMenuE.find("fieldset").each(function(){var smartFiltersTemplate,$t=jQuery(this),label=$t.find("label"),currentFieldOrder=getFieldOrder($t.find("h5:first")),fieldsetClass=($t.find("h5:first").text()||"").toLowerCase().replaceSpecialChars().replace(/\s/g,"-").replace(/[[]/g,"").replace(/]/g,"_").replace(/[0-9]/g,"");return fieldsetClass="filtro_"+currentFieldOrder+"_"+fieldsetClass,labelCallbackData[fieldsetClass]={},label.length<1?void $t.hide():(smartFiltersWrapperE.length>0&&(smartFiltersTemplate='

SELECCIONÁ '+$t.find("h5:first").text()+':

'),$t.removeClass("even"),$t.addClass(fieldsetClass),options.showAppliedFilters&&$t.find("h5").html($t.find("h5").html()+""),label.each(function(ndx){var t=jQuery(this),v=t.find("input").val()||"",labelClass="sr_"+v.toLowerCase().replaceSpecialChars().replace(/\s/g,"-").replace(/[^a-zA-Z0-9]/g,"_");if(Boolean(fieldsetClass.match(/preco/))!==!0&&Boolean(fieldsetClass.match(/precio/))!==!0||(labelClass=labelClass.replace(/[.[\]]/g,"")),!options.showFiltersQty){var tempInputE=t.find("input");t.text(t.text().replace(/ *\([^)]*\) */g,"")),t.prepend(tempInputE)}labelCallbackData.tmpCurrentLabel={fieldsetParent:[$t,fieldsetClass],elem:t},labelCallbackData[fieldsetClass][ndx.toString()]={className:labelClass,title:v},t.addClass(labelClass).attr({title:v,index:ndx}),smartFiltersWrapperE.length>0&&(smartFiltersTemplate+=''+v+""),options.labelCallback(labelCallbackData)}),smartFiltersWrapperE.length>0&&(smartFiltersTemplate+="
"),smartFiltersWrapperE.length>0&&(smartFiltersTemplateCollection[currentFieldOrder]=smartFiltersTemplate),labelCallbackData.fieldsetCount++,void $t.css("opacity",1))}),smartFiltersWrapperE.length>0)for(i=0;i';noFieldOrderBase++,orderByCustomTemplate+="
"+orderByOriginalE.find("option:first").text()+"
",orderByOriginalE.find("option:not(:first)").each(function(){var currentOptionE=jQuery(this),currentOptionTemplate='",orderByCustomTemplate+=currentOptionTemplate}),orderByCustomTemplate+="
",orderByCustomPlace.append(jQuery(orderByCustomTemplate)),orderByCustomPlace.find("input[type='checkbox']").each(function(){var _this=jQuery(this),label=_this.parent();_this.is(":checked")&&(urlFilters+="&O="+(_this.attr("rel")||""),label.addClass("sr_selected")),_this.bind("change",function(){fns.inputAction(_this),_this.is(":checked")?fns.addFilter(_this):fns.removeFilter(_this),ajaxCallbackObj.filters=$this.filter(":checked").length,fns.evaluateNextSmartFilter()})})}if(options.clearFiltersLink){var tempClearE='",null!=options.clearFiltersLinkPlace?jQuery(options.clearFiltersLinkPlace).append(tempClearE):filtersMenuE.append(tempClearE),jQuery(".clear-filters-link a").click(function(e){e.preventDefault(),filtersFullWrapperE.find("input:checked").click(),options.showAppliedFiltersTags&&jQuery(options.showAppliedFiltersTags).find(".filter-tag").remove()})}},inputAction:function(_this){null!==pageJqxhr&&pageJqxhr.abort(),null!==shelfJqxhr&&shelfJqxhr.abort(),currentPage=2,moreResults=!0},addFilter:function(input){if(input.hasClass("order")?(jQuery(options.orderByCustomPlace+" .orderBy input:checked").click(),urlFilters+="&O="+(input.attr("rel")||"")):urlFilters+="&"+(input.attr("rel")||""),prodOverlay.fadeTo(300,.6),filtersFullWrapperE.addClass("locked"),smartFiltersWrapperE.length>0&&smartFiltersWrapperE.find(".filter-group").addClass("locked"),jQuery("#filters .mobile-wrapper .info span").addClass("show"),currentSearchUrl=fn.getUrl(),shelfJqxhr=jQuery.ajax({url:currentSearchUrl,success:fns.filterAjaxSuccess,error:fns.filterAjaxError}),input.parent().addClass("sr_selected"),options.showAppliedFiltersTags){var currentTagId=input.parent().prop("classList")[0],appliedFilterTagTemplate=''+input.parent().text().toLowerCase()+"";jQuery(options.showAppliedFiltersTags).prepend(appliedFilterTagTemplate),jQuery(options.showAppliedFiltersTags).find("#"+currentTagId).click(function(e){e.preventDefault(),filtersFullWrapperE.find("."+currentTagId).click(),jQuery(this).remove()})}input.closest("fieldset").find("input:checked").length>0&&(input.closest("div").siblings("h5").find("b").text(input.closest("fieldset").find("input:checked").length),options.clearFiltersLink&&jQuery(".clear-filters-link").addClass("active")),trackGTM&&dataLayer.push({event:"trackEvent",eventCategory:"grilla-productos",eventAction:"filtro-"+input.parents("fieldset").find("h5").text().toLowerCase().replaceSpecialChars().replace(/\s/g,"-"),eventLabel:input.val().toLowerCase().replaceSpecialChars().replace(/\s/g,"-")})},removeFilter:function(input){if(input.hasClass("order"))var url="O="+(input.attr("rel")||"");else var url=input.attr("rel")||"";if(prodOverlay.fadeTo(300,.6),filtersFullWrapperE.addClass("locked"),smartFiltersWrapperE.length>0&&smartFiltersWrapperE.find(".filter-group").addClass("locked"),jQuery("#filters .mobile-wrapper .info span").addClass("show"),""!==url&&(urlFilters=urlFilters.replace("&"+url,"")),currentSearchUrl=fn.getUrl(),shelfJqxhr=jQuery.ajax({url:currentSearchUrl,success:fns.filterAjaxSuccess,error:fns.filterAjaxError}),input.parent().removeClass("sr_selected"),input.closest("fieldset").find("input:checked").length>0?input.closest("div").siblings("h5").find("b").text(input.closest("fieldset").find("input:checked").length):(input.closest("div").siblings("h5").find("b").text(""),options.clearFiltersLink&&jQuery(".clear-filters-link").removeClass("active")),options.showAppliedFiltersTags){var currentTagId=input.parent().prop("classList")[0];jQuery(options.showAppliedFiltersTags).find("#"+currentTagId).remove()}},filterAjaxSuccess:function(data){var $data=jQuery(data);prodOverlay.fadeTo(300,0,function(){jQuery(this).hide()}),filtersFullWrapperE.removeClass("locked"),smartFiltersWrapperE.length>0&&smartFiltersWrapperE.find(".filter-group").removeClass("locked"),jQuery("#filters .mobile-wrapper .info span").removeClass("show"),fns.updateContent($data,data),ajaxCallbackObj.requests++,options.ajaxCallback(ajaxCallbackObj)},filterAjaxError:function(){prodOverlay.fadeTo(300,0,function(){jQuery(this).hide()}),filtersFullWrapperE.removeClass("locked"),smartFiltersWrapperE.length>0&&smartFiltersWrapperE.find(".filter-group").removeClass("locked"),log("There was an error on the filtered Ajax call.")},updateContent:function($data,response){if(screen.width>=1024&&(jQuery("fieldset.refino-filter").removeClass("highlight"),jQuery("html,body").animate({scrollTop:330},700)),animatingFilter=!0,!options.authorizeUpdate(ajaxCallbackObj))return!1;var shelf=$data.filter(options.shelfClass),shelfPage=loadContentE.find(options.shelfClass);jQuery(shelfPage).remove(),options.emptySearchElem.remove(),shelf.length>0?(console.log(response),response=response.replace('
',""),response=response.replace("
",""),loadContentE.find("ul").remove(),loadContentE.append(response),options.shelfCallback(),animatingFilter=!1,ajaxCallbackObj.isEmpty=!1):(ajaxCallbackObj.isEmpty=!0,loadContentE.empty(),loadContentE.append(options.emptySearchElem),options.emptySearchElem.addClass("loaded"),options.emptySearchCallback(ajaxCallbackObj))},adjustText:function(input){var label=input.parent(),text=label.text();qtt="",label.text(text).prepend(input)},removeCounter:function(text){return text.replace(/\([0-9]+\)/gi,function(a){return qtt=a.replace(/\(|\)/,""),""})},setFilterMenu:function(){filtersMenuE.length>0&&(linksMenuE.hide(),filtersMenuE.show())}};fns.exec(),fn.infinitScroll(),options.callback()};