var avadaLiveSearch=function(){var e=[];avadaLiveSearchVars.live_search&&jQuery(".fusion-live-search-input").each((function(){var s,a=jQuery(this),i=a.closest(".fusion-live-search"),t=i.find(".fusion-search-button"),n=i.find(".fusion-search-submit"),o=i.find(".fusion-search-results"),r=i.find('input[name^="post_type"]'),d=i.find('input[name^="include_terms"]'),l=i.find('input[name^="exclude_terms"]'),u=i.find('input[name="search_limit_to_post_titles"]'),c=i.find('input[name="add_woo_product_skus"]'),v=i.find('input[name="live_min_character"]'),f=i.find('input[name="live_posts_per_page"]'),h=i.find('input[name="live_search_display_featured_image"]'),_=i.find('input[name="live_search_display_post_type"]'),p=i.find('input[name="live_results_scrollbar"]'),g=o.closest(".fusion-builder-row"),m=i.closest(".fusion-header"),y=void 0!==v.val()?parseInt(v.val()):avadaLiveSearchVars.min_char_count,C=void 0!==f.val()?parseInt(f.val()):avadaLiveSearchVars.per_page,j=void 0!==h.val()?parseInt(h.val()):avadaLiveSearchVars.show_feat_img,w=void 0!==_.val()?parseInt(_.val()):avadaLiveSearchVars.display_post_type;function S(e){var s="";o.html(""),o.removeClass("suggestions-empty"),o.addClass("suggestions-added"),L("add"),jQuery.isEmptyObject(e)?(o.addClass("suggestions-empty"),s+='<div class="fusion-search-result">'+avadaLiveSearchVars.no_search_results+"</div>",o.append(s)):jQuery.each(e,(function(e,a){s="",s+='<a class="fusion-search-result" href="'+a.post_url+'" title="'+a.title+'">',a.image_url&&(s+='<div class="fusion-search-image"><img class="fusion-search-image-tag" src="'+a.image_url+'" alt="Post Thumb'+a.id+'"/></div>'),s+='<div class="fusion-search-content">',s+='<div class="fusion-search-post-title">'+a.title+"</div>",a.type&&(s+='<div class="fusion-search-post-type">'+a.type+"</div>"),s+="</div>";let i={value:s+="</a>",suggestion:a};jQuery(window).trigger("awb_live_search_result_suggestion_html",[i]),s=i.value,o.append(s)}))}function b(){var s,t;if(i=a.closest(".fusion-live-search"),s=a.val(),s+=(t=function(){var e=[];return r.each((function(){e.push(this.value)})),e})().toString(),y<=a.val().length){if(void 0!==e[s])return void S(e[s]);i.find(".fusion-slider-loading").show(),i.find(".fusion-search-submit").css("color","transparent"),n.css("color","transparent");let o={action:"live_search_retrieve_posts",search:a.val(),per_page:C,show_feat_img:j,display_post_type:w,post_type:t(),search_limit_to_post_titles:u.val(),add_woo_product_skus:c.val()};d.length&&(o.include_terms=d.val()),l.length&&(o.exclude_terms=l.val()),jQuery.ajax({url:avadaLiveSearchVars.ajaxurl,type:"post",data:o}).done((function(a){e[s]=a,S(a),i.find(".fusion-slider-loading").hide(),n.css("color",n.attr("data-color"))}))}else i.find(".fusion-slider-loading").hide(),n.css("color",n.attr("data-color")),o.removeClass("suggestions-added"),L("remove")}function L(e){g.length&&("add"===e?g.css("z-index","11"):g.css("z-index","")),m.length&&("add"===e?m.addClass("live-suggestion-added"):m.removeClass("live-suggestion-added"))}n.attr("data-color",n.css("color")),void 0!==p.val()&&p.val()&&o.addClass("live-results-scrollbar-"+p.val()),a.on("focusin",(function(){y<=jQuery(this).val().length&&o.children(".fusion-search-result").length&&(o.addClass("suggestions-added"),L("add"))})),a.on("focusout",(function(){o.is(":hover")||t.is(":hover")||(o.removeClass("suggestions-added"),L("remove"),o.addClass("suggestions-transition"),setTimeout((function(){o.removeClass("suggestions-transition")}),300))})),jQuery(t,o).on("mouseleave",(function(){a.is(":focus")||(o.removeClass("suggestions-added"),L("remove"),o.addClass("suggestions-transition"),setTimeout((function(){o.removeClass("suggestions-transition")}),300))})),a.on("keyup",(function(){clearTimeout(s),s=setTimeout(b,500)})),a.on("keydown",(function(){clearTimeout(s)}))}))};jQuery(document).ready((function(){avadaLiveSearch()}));