$(".lazy").length&&$((function(){$(".lazy").lazy({threshold:100,onError:function(element){$(element).find("source").remove(),$(element).find("img").attr("src","img/default_full.png")}})}));var key_cat=0;function buscarCategoria(cat_id,obj){$("#btn_q_txt").html($(obj).text()),key_cat=cat_id}function update_carrito(){$(".carrito_menu_conteo").html("-"),$(".carrito_menu_conteo").load("productos_carrito_conteo.php",{tipo:"numero"},(function(){$("#nav-menu-carrito").html("

Actualizando...

"),$("#nav-menu-carrito").load("productos_carrito_menu.php")}))}function carrito_eliminar_item(sku,pro_nombre){var eliminar;if(!confirm("¿Desea quitar '"+pro_nombre+"' de su carrito?"))return!1;var dataString="pro_sku="+sku+"&pro_nombre="+pro_nombre+"&pro_cantidad=0";$.ajax({type:"POST",url:"productos_carrito_sumar.php",data:dataString,dataType:"json",timeout:45e3,success:function(response){if(!0===response.success){if($("#carrito_menu_resumen").length){var items_carrito=[],items_carrito_precio=0;$("#carrito_menu_resumen > ul > li.aux-ga-data").each((function(k,v){$(this).data("ga-sku")==sku&&(items_carrito.push({item_name:$(this).data("ga-nombre"),item_id:$(this).data("ga-id").toString(),price:parseFloat($(this).data("ga-precio-final")),discount:parseFloat($(this).data("ga-precio-discount")),item_brand:""!=$(this).data("ga-marca")?$(this).data("ga-marca"):"DeSillas",item_category:$(this).data("ga-categoria"),item_category2:$(this).data("ga-subcategoria"),item_variant:$(this).data("ga-sku").toString(),quantity:parseInt($(this).data("ga-cantidad"))}),items_carrito_precio=parseFloat($(this).data("ga-precio-final"))*parseInt($(this).data("ga-cantidad")))})),ga_datalayer_data={event:"remove_from_cart",ecommerce:{currency:"ARS",value:items_carrito_precio,items:items_carrito}},GoogleDataLayerPush(ga_datalayer_data)}update_carrito(),$("#carrito_detalle_tabla").length&&"undefined"!=typeof cargarTabla&&$.isFunction(cargarTabla)&&cargarTablaCarrito()}else console.log(JSON.stringify(response))},error:function(jqXHR,textStatus,errorThrown){console.log("Error: "+textStatus+" -- "+errorThrown)},complete:function(){$("#dropdown-menu-carrito").addClass("open")}})}function scroll2id(destino){$("html, body").animate({scrollTop:$("#"+destino).offset().top-60},800)}function refreshCaptcha(t){var img=document.images.captcha_image;img.src=img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+1e3*Math.random()+"&t="+t}function GoogleDataLayerPush(data){dataLayer=window.dataLayer||[],dataLayer.push({ecommerce:null}),dataLayer.push(data),console.log("GA dataLayer PUSH"),console.log(JSON.stringify(data,null,4))}window.addEventListener("load",(function(){setTimeout((function(){$("#chat-aux").length&&$.getScript("js/ZendeskChat.js")}),1e4)}),!1),$(document).ready((function(){$.each($("[data-integraciones-js]"),(function(){""!=$(this).data("integraciones-js")&&$.getScript("js/"+$(this).data("integraciones-js")+".min.js").done((function(script,status){console.log(status)})).fail((function(jqxhr,settings,exception){console.log(exception)}))})),$(".banner_etiquetas_container").length&&$.getScript("js/banners_etiquetados.min.js").done((function(script,status){$(".etiqueta-tooltipstered").tooltipster({content:"Cargando...",theme:["tooltipster-light","tooltipster-light-customized"],animation:"fade",animationDuration:200,interactive:!0,delay:50,contentAsHTML:!0,minWidth:150,maxWidth:170,functionBefore:function(instance,helper){var pro_sku_tooltip=helper.origin.getAttribute("data-pro-sku"),$origin=$(helper.origin);!0!==$origin.data("loaded")&&(""!=pro_sku_tooltip?$.get("banner-etiquetados-tooltip.php",{pro_sku:pro_sku_tooltip},(function(data){instance.content(data)})):instance.content("DeSillas"),$origin.data("loaded",!0))}})})).fail((function(jqxhr,settings,exception){console.log("Banners Etiquetados: "+exception)})),$(".aux-ga-event").click((function(){var data_label="",data_category="";$(this).data("label")&&(data_label=$(this).data("label")),$(this).data("category")&&(data_category=$(this).data("category")),dataLayer.push({event:"HomeSlider",category:"click",action:"click",label:data_label})})),update_carrito(),$("#dropdown-menu-carrito").on("shown.bs.dropdown",(function(){if($("#carrito_menu_resumen").length){var items_carrito=[],items_carrito_suma_precio=0;$("#carrito_menu_resumen > ul > li.aux-ga-data").each((function(k,v){items_carrito.push({item_name:$(this).data("ga-nombre"),item_id:$(this).data("ga-id").toString(),price:parseFloat($(this).data("ga-precio-final")),discount:parseFloat($(this).data("ga-precio-discount")),item_brand:""!=$(this).data("ga-marca")?$(this).data("ga-marca"):"DeSillas",item_category:$(this).data("ga-categoria"),item_category2:$(this).data("ga-subcategoria"),item_variant:$(this).data("ga-sku").toString(),quantity:parseInt($(this).data("ga-cantidad"))}),items_carrito_suma_precio+=parseFloat($(this).data("ga-precio-final"))*parseInt($(this).data("ga-cantidad"))})),ga_datalayer_data={event:"view_cart",ecommerce:{currency:"ARS",value:items_carrito_suma_precio,items:items_carrito}},GoogleDataLayerPush(ga_datalayer_data)}}));var items_max=10;function buscar(c){var q=$.trim($("#"+c).val());""!=q&&(location.href=key_cat>0?"productos-busqueda.html?key="+encodeURIComponent(q)+"&key_cat="+key_cat:"productos-busqueda.html?key="+encodeURIComponent(q))}$("#q").typeahead({autoSelect:!1,minLength:3,delay:300,items:10,fitToElement:!0,source:function(query,process){objects=[],map={},$.ajax({url:"menu_superior_buscador_sugerencias.php",data:{q:query,m:10},dataType:"json",beforeSend:function(){$("#q_url").val("")}}).done((function(response){$.each(response,(function(i,object){map[object.PRO_NOMBRE]=object,objects.push(object.PRO_NOMBRE)})),process(objects)}))},updater:function(item){return $("#q_url").val(map[item].PRO_URL),item},afterSelect:function(item){""!=$("#q_url").val()?location.href=$("#q_url").val():buscar("q")}}),$("#q").keypress((function(e){13==e.which&&(e.preventDefault(),buscar("q"))})),$("#buscador_header_btn").click((function(){buscar("q")})),$("#form_busqueda").submit((function(e){e.preventDefault()}));var cat_select_menu=$("#menu_superior_key_cat").find("li[data-cat-select='1']").text();function obtenerDatosCP(cp){$.ajax({type:"POST",url:"envio_cp.php",data:"cp="+cp,dataType:"json",timeout:15e3,beforeSend:function(){$("#btn_modal_cp").prop("disabled",!0),$("#modal_cp_response").removeClass().addClass("text-center").html(""),$("#modal_cp_table_container").slideUp("fast"),$("#modal_cp_table tbody").html("")},success:function(response){if(!0===response.success)if($("#modal_cp_response").html(""),0==response.datos.count)$("#modal_cp_response").removeClass().addClass("alert alert-warning").text("No se han encontrado resultados con los datos suministrados. Por favor, revise el código postal y vuelva a intentarlo.");else if(1==response.datos.count)resolverZonaCP(response.datos.data[0].ID);else{var t=document.querySelector("#modal_cp_table_template");$.each(response.datos.data,(function(i,item){t.content.querySelector(".modal_cp_table_aux_tr").id="modal_cp_zona_"+item.ID,t.content.querySelector("span.modal_cp_table_aux_zona").textContent=item.ZONA,t.content.querySelector("span.modal_cp_table_aux_provincia").textContent=item.PROVINCIA,t.content.querySelector(".modal_cp_table_aux_tr").setAttribute("data-zona-id",item.ID);var clone=document.importNode(t.content,!0);$("#modal_cp_table tbody").append(clone)})),$("#modal_cp_table_container").slideDown("fast"),$("#modal_cp_response").removeClass().addClass("alert text-success").text("Se han encontrado varias coincidencias. Por favor, seleccioná la más adecuada."),$(".modal_cp_table_aux_tr").click((function(){resolverZonaCP($(this).data("zona-id"))}))}else $("#modal_cp_response").removeClass().addClass("alert alert-warning").text("No se han encontrado resultados con los datos suministrados ("+response.msg+")")},error:function(jqXHR,textStatus,errorThrown){$("#modal_cp_response").removeClass().addClass("alert alert-danger").text("Un error ha impedido obtener los datos solicitados ("+textStatus+" - "+errorThrown+")")},complete:function(){$("#btn_modal_cp").prop("disabled",!1)}})}function resolverZonaCP(id){if(null==id||""==id)return!1;$.ajax({type:"POST",url:"envio_cp_geocode.php",data:"cp_id="+id,dataType:"json",timeout:15e3,beforeSend:function(){$("#btn_modal_cp").prop("disabled",!0),$("#modal_cp_response").removeClass().addClass("text-center").html(""),$("#modal_cp_table_container").slideUp("fast"),$("#modal_cp_table tbody").html("")},success:function(response){!0===response.success?($("#modal_cp").modal("hide"),$("#modal_cp_response").removeClass().html(""),actualizarCPheader(),$("#pro_envio_container").length&&"function"==typeof cargarEnvio&&cargarEnvio()):($("#modal_cp_response").removeClass().addClass("alert alert-warning").text("Un error ha impedido obtener los datos ("+response.msg+")"),$("#modal_cp_table_container").slideDown("fast"))},error:function(jqXHR,textStatus,errorThrown){console.log("Error: "+textStatus+" -- "+errorThrown)},complete:function(){$("#btn_modal_cp").prop("disabled",!1)}})}function actualizarCPheader(){$("#cp_header_container").fadeTo("fast",.5),$("#cp_header_container").load("menu_superior_location.php",{},(function(){$("#cp_header_container").fadeTo("fast",1),$("#pro_envio_container").length&&null==Cookies.get("ds_geocoding")&&(null==Cookies.get("ds_geocoding_flag")?(Cookies.set("ds_geocoding_flag","1"),modal_cp_show_flag=!0):(ds_geocoding_flag_count=parseInt(Cookies.get("ds_geocoding_flag"))+1,ds_geocoding_flag_count<=2?modal_cp_show_flag=!0:modal_cp_show_flag=!1,Cookies.set("ds_geocoding_flag",ds_geocoding_flag_count)),modal_cp_show_flag&&$("#modal_cp").modal("show"))}))}""!=cat_select_menu&&$("#btn_q_txt").html(cat_select_menu),$("#btn_mc_suscribirse").click((function(){var mc_email=$("#mc_email").val();$("#btn_mc_suscribirse").prop("disabled",!0),$("#mc_alert").html("Enviando..."),$("#mc_alert").removeClass().addClass("alert alert-info"),""!=mc_email?$.ajax({type:"POST",url:"mailchimp_suscribir.php",data:"mc_email="+mc_email,dataType:"json",timeout:15e3,success:function(response){!0===response.success?($("#mc_alert").removeClass().addClass("alert alert-success"),$("#mc_email").val("")):$("#mc_alert").removeClass().addClass("alert alert-warning"),$("#mc_alert").html(response.msg)},error:function(jqXHR,textStatus,errorThrown){$("#mc_alert").html("Se ha producido un error. Por favor, inténtelo nuevamente."),$("#mc_alert").removeClass().addClass("alert alert-danger")}}):($("#mc_alert").html("Debe ingresar su dirección de email."),$("#mc_alert").removeClass().addClass("alert alert-danger"),$("#mc_email").focus()),$("#btn_mc_suscribirse").prop("disabled",!1)})),$("#modal_cp").length&&($("#cp_header_container").length&&actualizarCPheader(),$("#modal_cp_table_container").length&&$("#modal_cp_table_container").hide()),$("#modal_cp").on("shown.bs.modal",(function(e){$("#modal_cp_input").focus(),$("#modal_cp_input").select()})),$("#btn_modal_cp").click((function(){var modal_cp_input=$("#modal_cp_input").val();let check_num;if(!/^\d+$/.test(modal_cp_input))return console.log("CP no válido."),!1;obtenerDatosCP(modal_cp_input)})),$("#modal_cp_input").keypress((function(event){var keycode;if("13"==(event.keyCode?event.keyCode:event.which)){var modal_cp_input=$("#modal_cp_input").val();let check_num;if(!/^\d+$/.test(modal_cp_input))return $("#modal_cp_response").removeClass().addClass("alert alert-warning").text("El código postal no es válido.").slideDown("fast"),!1;obtenerDatosCP(modal_cp_input)}}))}));