$(document).ready(function(){function n(){let n=$("#EmailAddress").val();return n==""||!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(n)?!1:!0}$(".date-field").mask("99/99/9999");$("#btnClearName").off("click").on("click",function(){$("#FirstName").val("");$("#LastName").val("");$("#NameBirthMonth").get(0).selectedIndex=0;$("#NameBirthYear").val("");$("#ZipCode").val("");$("#FirstName-error").text("");$("#LastName-error").text("");$("#NameBirthMonth-error").text("");$("#NameBirthYear-error").text("");$("#ZipCode-error").text("");$("#FirstName").removeClass("input-validation-error").addClass("valid");$("#LastName").removeClass("input-validation-error").addClass("valid");$("#NameBirthMonth").removeClass("input-validation-error").addClass("valid");$("#NameBirthYear").removeClass("input-validation-error").addClass("valid");$("#ZipCode").removeClass("input-validation-error").addClass("valid");$("#name-Form").find($(".field-validation-error")).html("");$("#name-Form").find($(".field-validation-error")).removeClass("field-validation-error").addClass("field-validation-valid")});$("#btnClearDLN").off("click").on("click",function(){$("#Dln").val("");$("#DlnBirthMonth").get(0).selectedIndex=0;$("#DlnBirthYear").val("");$("#Dln-error").text("");$("#DlnBirthMonth-error").text("");$("#DlnBirthYear-error").text("");$("#Dln").removeClass("input-validation-error").addClass("valid");$("#DlnBirthMonth").removeClass("input-validation-error").addClass("valid");$("#DlnBirthYear").removeClass("input-validation-error").addClass("valid");$("#dln-Form").find($(".field-validation-error")).html("");$("#dln-Form").find($(".field-validation-error")).removeClass("field-validation-error").addClass("field-validation-valid")});$("#btnSearchName").off("click").on("click",function(n){if(n.preventDefault(),!$("#name-Form").valid())return!1;var t={FirstName:$("#FirstName").val(),LastName:$("#LastName").val(),NameBirthMonth:$("#NameBirthMonth").val(),NameBirthYear:$("#NameBirthYear").val(),ZipCode:$("#ZipCode").val(),Dln:"",DlnBirthMonth:0,DlnBirthYear:"",DpaID:0,Months:null,VoterNotFound:!1,TransistionVoter:!1};$.ajax({method:"POST",cache:!1,url:"/Voter/SearchByName",data:t,success:function(n){$("#body").html(n);$("#page-title").text($("#hfPageTitle").val());$("#hfnotfound").val()=="True"?$("#hfmultiplevoterrecords").val()=="True"?$("#mulitpleNameRecords").modal("show"):$("#voternotfound").modal("show"):$("#hfAcpaParticipant").val()=="True"?$("#AcpaParticipantIdModal").modal("show"):window.location.hash="#registeredVoter"},error:function(){$("#hfmultiplevoterrecords").val()=="True"?$("#mulitpleNameRecords").modal("show"):QVFtoastr.Error("Voter information is not available at this time.")}})});$("#btnSearchDln").off("click").on("click",function(n){if(n.preventDefault(),!$("#dln-Form").valid())return!1;var t={FirstName:"",LastName:"",NameBirthMonth:0,NameBirthYear:"",ZipCode:"",Dln:$("#Dln").val(),DlnBirthMonth:$("#DlnBirthMonth").val(),DlnBirthYear:$("#DlnBirthYear").val(),DpaID:0,Months:null,VoterNotFound:!1,TransistionVoter:!1};$.ajax({method:"POST",cache:!1,url:"/Voter/SearchByDln",data:t,success:function(n){$("#body").html(n);$("#page-title").text($("#hfPageTitle").val());$("#hfnotfound").val()=="True"?$("#hfmultiplevoterrecords").val()=="True"?$("#mulitpleDlnRecords").modal("show"):$("#voternotfound").modal("show"):$("#hfAcpaParticipant").val()=="True"?$("#AcpaParticipantIdModal").modal("show"):window.location.hash="#registeredVoter"},error:function(){$("#hfmultiplevoterrecords").val()=="True"?$("#mulitpleDlnRecords").modal("show"):QVFtoastr.Error("Voter information is not available at this time.")}})});$("#EmailAddress").on("input",function(){$("#spanEmailMessage").hide();$("#EmailAddress").val()==""?$("#btnVoterEmailSubscribeSubmit").prop("disabled",!0):$("#btnVoterEmailSubscribeSubmit").prop("disabled",!1)});$("#btnVoterEmailSubscribeCanel").off("click").on("click",function(){window.location.href="/"});$("#btnVoterEmailUnSubscribeCanel").off("click").on("click",function(){window.location.href="/"});$("#btnVoterEmailUnSubscribeSubmit").off("click").on("click",function(n){n.preventDefault();var t=$("#hdnSearchBy").val(),i={VoterId:$("#SearchVoterId").val(),SearchBy:t.substring(1,t.length-1)};$.ajax({method:"POST",cache:!1,url:"/Voter/VoterEmailUnSubscribe",data:i,success:function(n){n.Status==undefined||n.Status?($("#divUnsubscribeMain").hide(),$("#divSuccess").show(),$("#h1UnsubscribeMessage").html("Thank you for your update!"),$("#spanMessage").html("Your email has been unsubscribed from ballot tracking notifications. You are no longer on the email notifications list and will stop receiveing email notifications.")):($("#divUnsubscribeMain").hide(),$("#divSuccess").show(),$("#h1UnsubscribeMessage").html("Unsubscribe unsuccessful!"),$("#spanMessage").html("Your email could not be unsubscribed. Please contact your local clerk to resolve this situation.;"),$("#spHome").hide())},error:function(){}})});$("#btnVoterEmailSubscribeSubmit").off("click").on("click",function(t){t.preventDefault();$("#spanEmailMessage").hide();var i=$("#hdnSearchBy").val(),r={EmailAddress:$("#EmailAddress").val(),VoterId:$("#SearchVoterId").val(),EmailNotificationSignup:$("#EmailNotificationSignup").is(":checked"),SearchBy:i.substring(1,i.length-1)};if(!n())return $("#spanEmailMessage").show(),$("#spanEmailMessage > span").html("Please enter a valid email address."),!1;$.ajax({method:"POST",cache:!1,url:"/Voter/VoterEmailSubscribe",data:r,success:function(n){n.Status==undefined||n.Status?($("#EmailAddress").val(""),$("#EmailNotificationSignup").prop("checked",!1),$("#divMain").hide(),n.Type=="EMAIL_UPDATE"?$("#spanMessage").html("Your email has been successfully updated in your voter record."):$("#spanMessage").html("Your email has been successfully updated and you have been subscribed to email notifications for ballot tracking"),$("#divSuccess").show()):($("#spanEmailMessage").show(),$("#spanEmailMessage > span").html(n.Error))},error:function(){}})});$("#btnViewVoterInfo").off("click").on("click",function(n){n.preventDefault();$.ajax({method:"GET",cache:!1,url:"/Voter/EmailVoterInfo",success:function(n){$("#body").html(n)},error:function(){}})});$("#btngotohome").off("click").on("click",function(n){n.preventDefault();window.loation.href=window.location.host});$("#btnRegisterForPermAV").off("click").on("click",function(n){n.preventDefault();$.ajax({method:"POST",cache:!1,data:{VoterAddressID:$("#hfVoterAddressID").val()},url:"/Voter/RegisterForPermAV",success:function(n){$("#body").html(n);$("#page-title").text($("#hfPageTitle").val())},error:function(){QVFtoastr.Error("Sorry, we cannot process your request at this time. Please try again later or contact your local clerk.")}})});$("#btnValidateDL").off("click").on("click",function(n){var t,i,r,u,f;if(n.preventDefault(),$('#name-Form [data-valmsg-for="Birthdate"]').text(""),$('#name-Form [data-valmsg-for="Birthdate"]').removeClass("field-validation-error field-validation-valid").addClass("field-validation-valid"),!$("#name-Form").valid())return!1;if(!isDate($("#Birthdate").val()))return $('#name-Form [data-valmsg-for="Birthdate"]').text("Please enter a valid birthdate."),$('#name-Form [data-valmsg-for="Birthdate"]').removeClass("field-validation-valid").addClass("field-validation-error"),!1;if(t=moment($("#Birthdate").val(),"MM/DD/YYYY").format("YYYYMMDD"),i=moment().subtract(192,"months").format("YYYYMMDD"),t>i)return $('#name-Form [data-valmsg-for="Birthdate"]').text("You must be at least 16 years old to register to vote using this website."),$('#name-Form [data-valmsg-for="Birthdate"]').removeClass("field-validation-valid").addClass("field-validation-error"),!1;if(r=moment($("#Birthdate").val(),"MM/DD/YYYY").format("YYYY"),u=(new Date).getFullYear(),u-r>110)return $('#name-Form [data-valmsg-for="Birthdate"]').text("Please enter a valid birth year."),$('#name-Form [data-valmsg-for="Birthdate"]').removeClass("field-validation-valid").addClass("field-validation-error"),!1;f={FullName:$("#FullName").val(),Dln:$("#Dln").val(),Birthdate:$("#Birthdate").val(),EyeColor:$("#EyeColor").val(),SSN:$("#SSN").val(),Months:null,Days:null,VoterNotFound:!1};$.ajax({method:"POST",cache:!1,url:"/Voter/ValidateDL",data:f,success:function(n){$("#body").html(n);$("#page-title").text($("#hfPageTitle").val())},error:function(){QVFtoastr.Error("Sorry, we cannot process your request at this time. Please try again later or contact your local clerk.")}})});$(".transition-voter").off("click").on("click",function(n){var r=n.target.innerText,t,i;n.preventDefault();t=$(n.target).attr("id");$("html").find(".transition-voter").removeClass("disabled");$("html").find("#"+t).addClass("disabled");i={VoterID:0,VoterAddressID:$("#Voter_"+t+"__VoterAddressID").val(),CountyID:$("#Voter_"+t+"__CountyID").val(),JurisdictionID:$("#Voter_"+t+"__JurisdictionID").val(),LastDayToVote:$("#Voter_"+t+"__LastDayToVote").val(),EffectiveRegistrationDate:$("#Voter_"+t+"__EffectiveRegistrationDate").val(),DpaID:$("#Voter_"+t+"__DpaID").val(),MVIP:$("#Voter_"+t+"__MVIP").val(),IsActive:"",Heading:"",StreetRangeID:$("#Voter_"+t+"__StreetRangeID").val(),IdConfirmed:$("#Voter_"+t+"__IdConfirmed").val(),IsPermAV:$("#Voter_"+t+"__IsPermAV").val(),HidePollingLocation:$("#Voter_"+t+"__HidePollingLocation").val(),SkipPermAvText:$("#Voter_"+t+"__SkipPermAvText").val()};$.ajax({type:"POST",cache:!1,dataType:"json",url:"/Voter/SwitchVoter",data:i,success:function(n){$("#registeredVoter").html(n);$("#lblJurisdiction").append(" ("+r+")")},error:function(){QVFtoastr.Error("Voter information is not available at this time.")}})});$("#confirm-id-help").off("click").on("click",function(n){n.preventDefault();document.getElementById("confirm-id-modal").open()});$("#btnSubmitParticipantId").off("click").on("click",function(n){if(n.preventDefault(),$("#participantId").val().length<1)return QVFtoastr.Error("You must enter a value for your Address Confidentialiy Participant ID."),!1;var t={FirstName:$("#FirstName").val(),LastName:$("#LastName").val(),NameBirthMonth:$("#NameBirthMonth").val(),NameBirthYear:$("#NameBirthYear").val(),ZipCode:$("#ZipCode").val(),Dln:$("#Dln").val(),DlnBirthMonth:$("#DlnBirthMonth").val(),DlnBirthYear:$("#DlnBirthYear").val(),AddressId:$("#hfAddressId").val(),ParticipantId:$("#participantId").val()};$.ajax({method:"POST",cache:!1,data:t,url:"/Voter/ValidateParticipantId",success:function(n){n.IdValidation==!1?QVFtoastr.Error("We could not find a match. Please verify your entry."):($("#AcpaParticipantIdModal").modal("toggle"),$("#body").html(n),$("#page-title").text($("#hfPageTitle").val()))},error:function(){QVFtoastr.Error("Sorry, we cannot process your request at this time. Please try again later or contact your local clerk.")}})})});RemainingHours=function(n){event.preventDefault();$(`#${n}RemainingHours`).data("collapsed")?($(`#${n}RemainingHours`).text("Show Remaining Hours"),$(`#${n}RemainingHours`).data("collapsed",!1)):($(`#${n}RemainingHours`).text("Hide Remaining Hours"),$(`#${n}RemainingHours`).data("collapsed",!0));document.getElementById(`${n}`).toggle()}