function continueAuthentication(){var i=$("#txtLogin").val(),r=$("#txtPassword").val(),n=$("#statusText"),t=$("#btnDialogLogIn")[0];$.post("/WebServices/WebService.asmx/AuthenticateLogin",{login:i,password:r,token:token}).done(function(i){var r=i.toLowerCase();r!="success"?r.startsWith("/public/setupaccount")?(n.text(loginjsVars.redirecting),window.location.assign(r)):r.startsWith("/secured/users/changepassword.aspx")?(n.text(loginjsVars.redirecting),window.location.assign(r)):(n.css({color:"red"}),n.text(i),enable(t)):(n.css({color:"green"}),n.text(loginjsVars.authenticationSuccessful),disable(t),$.post("/WebServices/WebService.asmx/GetLandingPageForUser").done(function(n){window.location.assign(n.toString())}))}).fail(function(){enable(t)})}function disable(n){n.disabled=!0}function enable(n){n.disabled=null;n.removeAttribute("disabled")}function enableLogin(){var n=$("#btnDialogLogIn")[0];enable(n)}var token="";$(document).ready(function(){if(loginjsVars===undefined)throw"ERROR: loginjsVars is undefined";$("#loginToggle,#index-search").click(function(){$("#dialogLogin").modal("show")});$(".login-control").keydown(function(n){n.keyCode==13&&$("#btnDialogLogIn").click()});$.get("/WebServices/WebService.asmx/GetTokenExpirationSeconds").success(function(n){setInterval(function(){$.get("/WebServices/WebService.asmx/GetTokenForAuthenticator").success(function(n){token=n})},n*1e3)});$.get("/WebServices/WebService.asmx/GetTokenForAuthenticator").success(function(n){token=n});$("#btnDialogLogIn").click(function(){var n=this;disable(n);var t=$("#txtLogin").val(),r=$("#txtPassword").val(),i=$("#statusText");if(!(t.length&&r.length))return i.css({color:"red"}),i.text(loginjsVars.invalidCredentials),enable(n),!1;$.post("/WebServices/WebService.asmx/GetAccountSignupAgreementStatus",{login:t,token:token}).done(function(n){var t=JSON.parse(n),i;t.showTermsOfService?(t.fileType==="text/html"?(i=$.parseHTML(t.content.trim()),$(i).remove("script").prop("onclick",null).removeAttr("onkeypress onkeydown onkeyup").removeAttr("onmousedown onmouseup onmouseenter onmouseleave onmousemove onmouseover onmouseout onwheel").removeAttr("onfocus onblur onchange onload onscroll onscroll onerror"),$("#dialogTosBody").html(i)):$("#dialogTosBody").text(t.content.trim()),$("#AgreementVersion").val(t.version),$("#dialogTos").modal("show")):continueAuthentication()}).fail(function(){$("dialogTosError").text("Error");enable(n)})});$("#dialogTos").on("show.bs.modal",function(){$("body").css("overflow","hidden");$(this).css({"overflow-y":"scroll"});$("#dialogLogin").modal("hide")});$("#dialogTos").on("hidden.bs.modal",function(){$("body").css({overflow:"","padding-right":""});$(this).css({"overflow-y":""})});$("#btnDialogTosCancel").click(function(){$("#dialogTos").modal("hide");$("#dialogTosBody").empty();enableLogin()});$('input[name="HasUserAcceptedTerms"]').change(function(n){n.stopPropagation();$(this).is(":checked")?$("#btnDialogTosContinue").removeAttr("disabled").removeProp("disabled").removeClass("disabled"):$("#btnDialogTosContinue").prop("disabled",!0).addClass("disabled")});$("#btnDialogTosContinue").click(function(){if(!$(this).is("[disabled]")){var n=$("#txtLogin").val(),t=$("#AgreementVersion").val();$.ajax({url:"/WebServices/WebService.asmx/UpdateUserAgreementVersion",type:"POST",data:{login:n,token:token,version:t}}).done(function(){$("#dialogTos").modal("hide");$("#dialogLogin").modal("show");continueAuthentication()}).fail(function(n,t,i){let r=$("#statusText");r.css({color:"red"});r.text(i);console.error(n)})}})})