function GetSpinnerForButton(){return'<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"><\/span>'}function RemoveCustomerFromPanel(n){$.ajax({type:"POST",url:"/Panel/API/RemoveCustomerFromPanel",data:JSON.stringify(n),contentType:"application/json; charset=utf-8",success:function(t){n.OnSuccess!=null&&n.OnSuccess(t)},error:function(t){n.OnError!=null&&n.OnError(t)}})}function SearchRegion(n){$.ajax({type:"POST",url:"/Panel/API/SearchRegion",data:JSON.stringify(n),contentType:"application/json; charset=utf-8",success:function(t){n.OnSuccess!=null&&n.OnSuccess(t)},error:function(t){n.OnError!=null&&n.OnError(t)}})}function SearchCompany(n){$.ajax({type:"POST",url:"/Panel/API/SearchCompany",data:JSON.stringify(n),contentType:"application/json; charset=utf-8",success:function(t){n.OnSuccess!=null&&n.OnSuccess(t)},error:function(t){n.OnError!=null&&n.OnError(t)}})}function SearchJobRole(n){$.ajax({type:"POST",url:"/Panel/API/SearchJobRole",data:JSON.stringify(n),contentType:"application/json; charset=utf-8",success:function(t){n.OnSuccess!=null&&n.OnSuccess(t)},error:function(t){n.OnError!=null&&n.OnError(t)}})}function GetCustomerEnrollmentStatus(n){$.ajax({type:"POST",url:"/Panel/API/GetCustomerEnrollmentStatus",data:JSON.stringify(n),contentType:"application/json; charset=utf-8",success:function(t){n.OnSuccess!=null&&n.OnSuccess(t)},error:function(t){n.OnError!=null&&n.OnError(t)}})}function RecordTagsFromPanelQuestions(n){$.ajax({type:"POST",url:"/Panel/API/RecordTagsFromPanelQuestions",data:JSON.stringify(n),contentType:"application/json; charset=utf-8",success:function(t){n.OnSuccess!=null&&n.OnSuccess(t)},error:function(t){n.OnError!=null&&n.OnError(t)}})}function GetCustomerDiversityByCustomerId(n){$.ajax({type:"POST",url:"/Panel/API/GetCustomerDiversityByCustomerId",data:JSON.stringify(n),contentType:"application/json; charset=utf-8",success:function(t){n.OnSuccess!=null&&n.OnSuccess(t)},error:function(t){n.OnError!=null&&n.OnError(t)}})}function SetDemographicAnswers(n){if($("input[name='racialIdentity']").val(n.RacialIdentity.split("|")),n.RacialIdentity&&n.RacialIdentity!="Prefer not to answer"){var t="",r=$(".racialPrimaryGroup .dni-answers"),i=$(".racialIdentityGroup input[type = 'checkbox']:not(#racialIdentityNoAnswer):checked");i.length<2?$(".racialPrimaryGroup").hide():($(".racialPrimaryGroup").show(),i.each(function(){var i=$(this).val();t+=n.RacialPrimary==i?"<label><input type='radio' name='racialPrimary' checked value='"+i+"'> "+i+"<\/label>":"<label><input type='radio' name='racialPrimary' value='"+i+"'> "+i+"<\/label>"}),t+=n.RacialPrimary=="Prefer not to answer"?"<label><input type='radio' name='racialPrimary' checked value='Prefer not to answer'> Prefer not to answer<\/label>":"<label><input type='radio' name='racialPrimary' value='Prefer not to answer'> Prefer not to answer<\/label>",r.html(t))}$("input[name='genderIdentity']").val([n.GenderIdentity]);$("input[name='transgenderIdentity']").val([n.TransgenderIdentity]);$("input[name='sexualOrientation']").val(n.SexualOrientation.split("|"));$("input[name='numberHouseholdSupport']").val([n.NumberHouseholdSupport]);$("input[name='householdIncome']").val([n.HouseholdIncome]);$("input[name='disability']").val(n.Disability.split("|"))}function validateForms(){var n=document.getElementsByClassName("needs-validation"),t=Array.prototype.filter.call(n,function(n){n.addEventListener("submit",function(t){n.checkValidity()===!1&&(t.preventDefault(),t.stopPropagation());n.classList.add("was-validated")},!1)})}function CheckForEnrollmentStatus(){$(window).on("focus",function(){for(var n=0;n<10;n++)GetCustomerEnrollmentStatus({OnSuccess:function(n){n===3&&setTimeout(function(){RedirectTo("/Panel/Main")},2e3)},OnError:function(){}})})}var searchTimeout=null,chinaAccept=null;$(document).ready(function(){var i,e,t,n;$(".datepicker").each(function(){var n=$(this);n.datepicker()});i=GetCookie("cookie-agreement");i!="showed"&&$(".cookie-agreement-container").slideDown("fast");validateForms();var r=$("#modalNewPWF"),u=$("#hasSignedWaiver"),f=GetCookie("waiver-notification");(f==null||f!="off")&&(IsNull(u)||(e=u.val(),IsNull(r)||e||r.modal("show")));t=$(".racialPrimaryGroup");t&&t.hide();Number($("#edit-profile").val())==1&&(n=null,GetCustomerDiversityByCustomerId({OnSuccess:function(t){(n=$.parseJSON(t),Number(n.Id)!=0)&&SetDemographicAnswers(n)},OnError:function(n){console.log(JSON.stringify(n))}}))});$(document).delegate(".racialIdentityGroup input[type='checkbox']","click",function(){var n="",i=$(".racialPrimaryGroup .dni-answers"),t=$(".racialIdentityGroup input[type = 'checkbox']:not(#racialIdentityNoAnswer):checked");if(t.length<2){$(".racialPrimaryGroup").hide();return}$(".racialPrimaryGroup").show();t.each(function(){var t=$(this).val();n+="<label><input type='radio' name='racialPrimary' value='"+t+"'> "+t+"<\/label>"});n+="<label><input type='radio' name='racialPrimary' value='Prefer not to answer'> Prefer not to answer<\/label>";i.html(n)});$(document).delegate(".button-next-time","click",function(){SetCookie("waiver-notification","off")});$(document).delegate(".close-cookie-agreement","click",function(n){n.preventDefault();SetCookie("cookie-agreement","showed");$(".cookie-agreement-container").slideUp("fast")});$(document).delegate(".top-bar > .right > .email","mouseover",function(n){n.preventDefault();var t=$(this).find(".logout");t.show()});$(document).delegate(".top-bar > .right i","click",function(n){var t,i;n.preventDefault();t=$(document).width();t<800&&(i=$(this).next(),i.show())});$(document).delegate(".top-bar > .right .logout","mouseout",function(n){n.preventDefault();$(this).hide()});$(document).delegate("#opt-out-panel","click",function(n){var t,i;n.preventDefault();t=$(this);t.empty();t.attr("disabled","disabled");t.append(GetSpinnerForButton()+" Processing...");i=$("#panelId").val();RemoveCustomerFromPanel({PanelId:i,OnSuccess:function(){t.empty();t.append(GetSpinnerForButton()+" Successfully opted out.");setTimeout(function(){RedirectTo("/Panel/OptOutPanel/Completed")},1e3)},OnError:function(){t.empty();t.append("Something went wrong. Please try again later.")}})});$(document).delegate("#export-profile","click",function(n){var i,r,t;n.preventDefault();i="data:text/csv;charset=utf-8,";$(".label").each(function(){var t=$(this).text(),n=$(this).next().text();n=$.trim(n);i+=t+","+n+"\n"});r=encodeURI(i);t=document.createElement("a");t.setAttribute("href",r);t.setAttribute("download","MyProfile.csv");document.body.appendChild(t);t.click();document.body.removeChild(t)});$(document).delegate("input[name='Region'],input[name='Company'],input[name='JobRole']","keyup",function(n){var f,t,u;if(n.preventDefault(),f=$.trim($(this).val()),t=$(this).attr("name"),f.length>2){searchTimeout!==null&&clearTimeout(searchTimeout);var i=$(this).parent().find(".dynamic-list"),e=i.find(".loader"),o=i.find(".none-found"),r=i.find(".result");i.show();e.show();o.hide();r.hide();u={Search:f,OnSuccess:function(n){var s,h,u,f;if(r.empty(),n.length>0){if(t==="Region"){for(s=null,h=-1,u=0;u<n.length;u++)f=n[u],f.Id===244&&f.Name==="United States"&&(s=f,h=u);s!=null&&h>0&&(n.splice(h,1),n.unshift(s))}for(u=0;u<n.length;u++)f=n[u],r.append("<a href='#' role='option'>"+f.Name+"<\/a>");r.show();i.find(".suggestions-help").text("There are "+n.length+" suggestions.")}else o.show(),r.hide();e.hide()},OnError:function(){e.hide()}};searchTimeout=setTimeout(function(){searchTimeout=null;t==="Region"?SearchRegion(u):t==="Company"?SearchCompany(u):t==="JobRole"&&SearchJobRole(u)},750)}});$(document).delegate("#form-profile","submit",function(n){var i=$("select[name='RegionId']").val(),t;if(["46"].includes(i)&&!chinaAccept)return n.preventDefault(),t=$("#modalCPIP"),t.modal("show"),!1});$(document).delegate(".button-ok-cpip","click",function(){var n=$("#modalCPIP");n.modal("hide");chinaAccept=1;$("#form-profile").submit()});$(document).delegate("body","click",function(){var n=$(document.activeElement),t=n.parent().hasClass("result");t||$(".dynamic-list").hide()});$(document).delegate(".result > a","click",function(){$(this).parent().hide();$(this).parent().parent().parent().prev().focus()});$(document).delegate(".dynamic-list > .result > a","click",function(n){n.preventDefault();var t=$(this).text(),i=$(this).parents(".dynamic-list-wrapper").parent().find("input");i.val(t)});$(document).delegate(".button-update-new-survey","click",function(n){var u,t,r,f,e;if(n.preventDefault(),u=document.getElementById("form-panel-questions"),u.checkValidity()===!0){t=$(this);t.empty();t.attr("disabled","disabled");t.append(GetSpinnerForButton()+" Processing...");var l=$("#customerId").val(),h=$("#panelId").val(),c=Number($("#requiredCount").val()),o=$(".section-update-new-survey .errorMessage"),i="",s=[];for(r=1;r<=c;r++)f=!1,e="",$(".customer-answer[data-required-id='"+r+"']").each(function(){var n=$(this);n.prop("checked")?f=!0:e=n.data("id")}),f||(i.length>0&&(i+=", "),i+="<b>Q"+e+"<\/b>");if(i.length>0){o.html("Make at least one choice for the following question(s): "+i);t.empty();t.append("Update");t.removeAttr("disabled");return}o.html("");$(".customer-answer:checked").each(function(){s.push(Number($(this).val()))});RecordTagsFromPanelQuestions({PanelId:h,QuestionResponseIds:s,OnSuccess:function(){t.empty();t.append(GetSpinnerForButton()+" Successfully updated survey.");setTimeout(function(){RedirectTo("/Panel/Main")},1e3)},OnError:function(){t.empty();t.removeAttr("disabled");t.append("Something went wrong. Please try again later.")}})}u.classList.add("was-validated")})