function highlightFhSearch(){if(!$(".fh-search-fade").length){$("#search-form-wrap").css({"z-index":"1000"});$(".fh-search-wrap .btn-echovita").addClass("active");var n=document.createElement("div");$(n).addClass("fh-search-fade");$(n).addClass("none");$("body").append(n);$(".fh-search-fade").fadeIn(300);$(".fh-search-fade").bind("click",function(){closeFHHighlight()})}}function clearLocationSearch(){var n='<div class="item pointer geo"><p class="mb-0"><i class="fal fa-location-arrow" aria-hidden="true"><\/i>&nbsp;&nbsp;'+Resources.Global.CurrentLocation+"<\/p><\/div>";$(".s-by-location .content").html(n);$(".s-by-location").show();initFHSearchListItems()}function initFHSearchListItems(){$(".s-by-name .item").each(function(){$(this).bind("click",function(){selectFHItem(0,$(this))})});$(".s-by-location .item").each(function(){$(this).bind("click",function(){$(this).hasClass("geo")?getGeoLocation():selectFHItem(1,$(this));closeFHHighlight()})});$(".s-by-first-name .item").each(function(){$(this).bind("click",function(){selectFHItem(2,$(this))})});$(".s-by-last-name .item").each(function(){$(this).bind("click",function(){selectFHItem(3,$(this))})})}function selectFHItem(n,t){n==0?($(".search-fh-name").val($(t).find("p").text()),closeFHHighlight(),clearFHNameSearch()):n==1?($(".search-fh-location").val($(t).attr("data-name")),$(".search-fh-location-id").val($(t).attr("data-id")),closeFHHighlight(),$(".s-by-location").hide()):n==2?($(".search-h-first-name").val($(t).find("p").text()),closeFHHighlight(),clearObiNameSearch()):n==3&&($(".search-h-last-name").val($(t).find("p").text()),closeFHHighlight(),clearObiNameSearch())}function closeFHHighlight(){$(".search-helper-wrap").fadeOut(200,function(){$(".search-helper-wrap .content").html("")});$(".fh-search-fade").fadeOut(300,function(){$(this).remove();$("#search-form-wrap").css({"z-index":"1"});$(".fh-search-wrap .btn-echovita").hasClass("active")&&$(".fh-search-wrap .btn-echovita").removeClass("active")})}function clearFHNameSearch(){$(".s-by-name .content").html("");$(".s-by-name").hide()}function clearObiNameSearch(){$(".s-by-first-name .content").html("");$(".s-by-first-name").hide();$(".s-by-last-name .content").html("");$(".s-by-last-name").hide()}function getGeoLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(getGeoPosition,getGeoError):setCurrentLocation(!1)}function getGeoPosition(n){$(".search-fh-latitude").val(n.coords.latitude);$(".search-fh-longitude").val(n.coords.longitude);setCurrentLocation(!0)}function getGeoError(n){var t="";switch(n.code){case n.PERMISSION_DENIED:t="User denied the request for Geolocation.";break;case n.POSITION_UNAVAILABLE:t="Location information is unavailable.";break;case n.TIMEOUT:t="The request to get user location timed out.";break;case n.UNKNOWN_ERROR:t="An unknown error occurred."}setCurrentLocation(!1)}function setCurrentLocation(){$(".search-fh-location").val(Resources.Global.CurrentLocation);$(".search-fh-location-id").val(0);$(".search-fh-current-location").val(1);$(".input-box.ib-loc").addClass("current");$(".s-by-location").hide()}$(".fh-header-search").length&&($(".fh-header-search .basic-button").each(function(){$(this).bind("click",function(){$("#frmFullHeaderSearch").length?$("#frmFullHeaderSearch").submit():$("#frmSearchUser").length&&$("#frmSearchUser").submit()})}),$(".fh-header-search .search-fh-name").length&&($(".fh-header-search .search-fh-name").bind("focus",function(){$(".s-by-location").hide()}),$(".fh-header-search .search-fh-name").bind("keyup",function(){var n=$(this).val().length;n>=3&&(highlightFhSearch(),$.ajax({url:ajaxBaseUrl()+"funeralhome/getfuneralhomes",data:{name:$(this).val(),isNewspaper:$("#fh-page-type").val()},type:"POST",dataType:"json",success:function(n){var i,t;if(n!=null){if(n.length==0){clearFHNameSearch();return}if(n.errormessage&&n.errormessage!="")clearFHNameSearch();else{for(i="",t=0;t<n.length;t++)i+='<a href="'+n[t].f_url+'" class="eh-btn-link-black"><div class="item '+((t+1)%2==0?"grey":"")+'" data-id="'+n[t].f_id+'"><p class="mb-0">'+n[t].f_name+"<\/p><\/div><\/a>";$(".s-by-name .content").html(i);$(".s-by-name").show();initFHSearchListItems()}}else clearFHNameSearch()},error:function(){clearFHNameSearch()}}))})),$(".fh-header-search .search-fh-location").length&&($(".fh-header-search .search-fh-location").bind("focus",function(){$(".s-by-name").hide();highlightFhSearch();clearLocationSearch()}),$(".fh-header-search .search-fh-location").bind("keyup",function(){var n=$(this).val().length;n>=3?(highlightFhSearch(),$.ajax({url:ajaxBaseUrl()+"funeralhome/getlocations",data:{name:$(this).val(),isNewspaper:$("#fh-page-type").val(),needFuneralHome:$(this).attr("data-needFuneralHome")},type:"POST",dataType:"json",success:function(n){var i,r,t;if(n!=null){if(n.length==0){clearLocationSearch();return}if(n.errormessage&&n.errormessage!="")clearLocationSearch();else{for(i='<div class="item pointer geo"><p class="mb-0"><i class="fal fa-location-arrow" aria-hidden="true"><\/i>&nbsp;&nbsp;'+Resources.Global.UseCurrentLocation+"<\/p><\/div>",i+='<div class="item grey"><p class="mt-1 mb-1"><b>'+Resources.Global.SuggestLocation+"<\/b><\/p><\/div>",r="",t=0;t<n.length;t++)r=n[t].c_p_abr_name!=null&&n[t].c_p_abr_name!=""?", "+n[t].c_p_abr_name:"",i+='<div class="pointer item '+((t+1)%2==0?"":"")+'" data-id="'+n[t].c_id+'" data-name="'+n[t].c_name+'"><p class="mb-0">'+n[t].c_name+""+r+"<\/p><\/div>";$(".s-by-location .content").html(i);$(".s-by-location").show();initFHSearchListItems()}}else clearLocationSearch()},error:function(){clearLocationSearch()}})):($(".input-box.ib-loc").hasClass("current")&&$(".input-box.ib-loc").removeClass("current"),$(".search-fh-location-id").val(0),$(".search-fh-current-location").val(0))})),$(".fh-header-search .search-h-first-name").length&&$(".fh-header-search .search-h-first-name").bind("keyup",function(n){n.which==13&&$("#frmSearchUser").submit()}),$(".fh-header-search .search-h-last-name").length&&$(".fh-header-search .search-h-last-name").bind("keyup",function(n){n.which==13&&$("#frmSearchUser").submit()}))