var PageConfig={BaseUrl:wvsos.siteRoot+"Register/",ContentDiv:"#voteContent",NextButton:".NextButton",BackButton:".BackButton",LoadingDisplay:'<i class="fa fa-spinner fa-pulse"><\/i> Loading...',TimeoutModal:"#timeoutModal",LogoutModal:"#logoutModal",LogoutButton:".Logout"},SetHash,LoadPage;$(function(){DisableTimeout()});var SessionWarningTimeout,SessionTimeout,DisableTimeout=function(){clearTimeout(SessionWarningTimeout);clearTimeout(SessionTimeout)},ResetTimeout=function(){clearTimeout(SessionWarningTimeout);clearTimeout(SessionTimeout);SessionWarningTimeout=setTimeout(ShowTimeoutModal,wvsos.SessionWarning);SessionTimeout=setTimeout(Logout,wvsos.SessionTimeout)},ShowTimeoutModal=function(){$(PageConfig.TimeoutModal).modal("show")},Logout=function(){_ignoreModalHide=!0;$(PageConfig.LogoutModal).modal("show");$(PageConfig.TimeoutModal).modal("hide");$("#noChangesNecessary").modal("hide");LoadPage("Index");_ignoreModalHide=!1};_ignoreModalHide=!1;$("body").on("hide.bs.modal",PageConfig.TimeoutModal,function(){_ignoreModalHide||$.ajax({url:PageConfig.BaseUrl+"ResetTimeout",cache:!1}).done(function(){ResetTimeout()})});$("body").on("click",PageConfig.LogoutButton,function(){Logout()});$("body").on("change","#Consent",function(){var n=$("#NoDMVNumber");this.checked||n.prop("checked")?$(".DoesNotConsent").hide():$(".DoesNotConsent").show()});$("body").on("click","#DownloadPdf",function(){$("#DownloadPdfModal").modal("show")});$(window).on("hashchange",function(){var n=window.location.hash;n!=null&&lastHash!=null&&(n=n.substring(1,n.length),n==""&&LoadPage("Index"),n.indexOf("#")===-1&&n!="mainContent"&&lastHash!=n&&LoadPage(n))});SetHash=function(n){lastHash=n;window.location.hash=n};LoadPage=function(n,t,i){$(PageConfig.ContentDiv).html(PageConfig.LoadingDisplay);$.ajax({type:t,url:PageConfig.BaseUrl+n,data:i,cache:!1}).done(function(t){$(PageConfig.ContentDiv).html(t);$("[autofocus]").focus();$("#MainForm")!=null&&(n=$("#MainForm").attr("action"),n=n.split("/")[2]);SetHash(n);$("#MainForm").attr("data-paper")=="True"?($("#RegisterHeader").hide(),$("#AlternateHeader").show()):($("#RegisterHeader").show(),$("#AlternateHeader").hide());n=="Landing"?($("#ForceLogoutButton").hide(),DisableTimeout()):($("#ForceLogoutButton").show(),ResetTimeout());n=="Identification"&&$("#NoDMVNumber").is(":checked")&&($(".NoDMVNumber").show(),updateContinueMessage())}).fail(function(n){n.status==400&&lastHash=="Finished"?$(PageConfig.ContentDiv).html("Your registration was submitted and your information has been cleared for security reasons.  Please refresh to return to the home page."):n.status==400?$(PageConfig.ContentDiv).html("Something went wrong.  Please logout and try again."):n.status==404?$(PageConfig.ContentDiv).html("Something went wrong.  Please logout and try again."):$(PageConfig.ContentDiv).html("Something went wrong.  Please logout and try again.")})};$("body").on("submit","#MainForm",function(n){var i,t,r;n.preventDefault();i=$(this).attr("method");t=$(this).attr("action");t.indexOf("/")!==-1&&(t=t.split("/")[2]);r=$(this).serialize();LoadPage(t,i,r)});$("body").on("click",PageConfig.NextButton,function(n){n.preventDefault();var t=$(this).attr("data-method");t!=null&&t.toUpperCase()=="POST"?LoadPage($(this).attr("data-action"),"POST",$($(this).attr("data-target")).serialize()):LoadPage($(this).attr("data-action"))});$("body").on("click",PageConfig.BackButton,function(n){n.preventDefault();LoadPage($(this).attr("data-action"))});$("body").on("click","#printPage",function(){window.print()});$("body").on("click","#ForceLogoutButton",function(){Logout()});$("body").on("click","#InformationCurrent",function(){$("#noChangesNecessary").modal("show")});$("body").on("keypress","#PartyOther",function(n){if(n.keyCode>64&&n.keyCode<91||n.keyCode>96&&n.keyCode<123||n.keyCode>47&&n.keyCode<58){var t=[];$("input[name='Party']").each(function(){var n=$.Deferred();t.push(n.promise());this.checked=!1;n.resolve()});$.when(t).done(function(){$("#PartyOther").prev().prev().children().first().prop("checked",!0)})}});$("body").on("click keypress",'input[name="Gender"]',function(){$(this).prop("prevChecked")&&$(this).prop("checked",!1);$('input[name="Gender"]').prop("prevChecked",!1);$(this).prop("prevChecked",$(this).prop("checked"))});$("body").on("click keypress",'input[name="UOCAVAStatus"]',function(){$(this).prop("prevChecked")&&$(this).prop("checked",!1);$('input[name="UOCAVAStatus"]').prop("prevChecked",!1);$(this).prop("prevChecked",$(this).prop("checked"))});$("body").on("click","#Party",function(){$(this).val()=="Other"&&($("#PartyOther").focus(),$("#PartyOther").select())});$("body").on("change","#NewRegistration",function(){var n=$(this).prop("checked");n==!0&&($("#PartyChange").prop("checked",!1),$("#NameChange").prop("checked",!1),$("#AddressChange").prop("checked",!1))});$("body").on("change","#PartyChange",function(){var n=$(this).prop("checked");n==!0&&$("#NewRegistration").prop("checked",!1)});$("body").on("change","#NameChange",function(){var n=$(this).prop("checked");n==!0&&$("#NewRegistration").prop("checked",!1)});$("body").on("change","#AddressChange",function(){var n=$(this).prop("checked");n==!0&&$("#NewRegistration").prop("checked",!1)})