var SNSajaxLogon={};SNSajaxLogon.xmlHttp=null;SNSajaxLogon.FormId="";SNSajaxLogon.FieldId="";SNSajaxLogon.Type="";SNSajaxLogon.cFieldResponse="response";SNSajaxLogon.cFieldChallenge="hidden_challenge";SNSajaxLogon.cFieldDigipas="hidden_digipasid";SNSajaxLogon.cFieldTicket="hidden_ticket";SNSajaxLogon.cFieldUsername="username";SNSajaxLogon.cFieldPassword="password";SNSajaxLogon.createXMLHttpRequest=function(){var A;if(window.XMLHttpRequest){A=new XMLHttpRequest()}else{if(window.ActiveXObject){A=new ActiveXObject("Microsoft.XMLHTTP")}}return A};SNSajaxLogon.GETRequest=function(A,B){SNSajaxLogon.xmlHttp=SNSajaxLogon.createXMLHttpRequest();var C=A;if(B!=""){C=C+"?"+B}SNSajaxLogon.xmlHttp.onreadystatechange=SNSajaxLogon.handleStateChange;SNSajaxLogon.xmlHttp.open("GET",C,true);SNSajaxLogon.xmlHttp.send(null)};SNSajaxLogon.POSTRequest=function(A,B){SNSajaxLogon.xmlHttp=SNSajaxLogon.createXMLHttpRequest();SNSajaxLogon.xmlHttp.open("POST",A,true);SNSajaxLogon.xmlHttp.onreadystatechange=SNSajaxLogon.handleStateChange;SNSajaxLogon.xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");SNSajaxLogon.xmlHttp.send(B)};SNSajaxLogon.handleStateChange=function(){if(SNSajaxLogon.xmlHttp.readyState==4){if(SNSajaxLogon.xmlHttp.status!=null&&SNSajaxLogon.xmlHttp.status==200){SNSajaxLogon.parseResults()}else{if(SNSajaxLogon.xmlHttp.status==403){SNSajaxLogon.showHTTPError(SNSajaxLogon.xmlHttp.status);SNSajaxLogon.nextFormStep()}else{SNSajaxLogon.showHTTPError(SNSajaxLogon.xmlHttp.status)}}}};SNSajaxLogon.parseResults=function(){var G;var F=-1;var D="";G=SNSajaxLogon.trim(SNSajaxLogon.xmlHttp.responseText);try{if(G.length>=3){F=parseInt(G.substring(0,3));D=G.substring(3)}}catch(E){F=-1;D=""}switch(F){case 100:SNSajaxLogon.showError(D);break;case 200:if(SNSajaxLogon.Type=="SIA"){var A=document.getElementById(SNSajaxLogon.cFieldPassword);var C="";for(var B=0;B<A.value.length;B++){C=C+"*"}A.value=C}SNSajaxLogon.nextFormStep();break;case 300:if(SNSajaxLogon.Type=="DGP"){SNSajaxLogon.goDGP()}if(SNSajaxLogon.Type=="SIA"){SNSajaxLogon.goSIA()}break;default:SNSajaxLogon.showUnknownError()}};SNSajaxLogon.logonDGP=function(B,A){SNSajaxLogon.FormId=B;SNSajaxLogon.Type="DGP";SNSajaxLogon.FieldId=A;if(SNSajaxLogon.checkResultFieldDGP(B,A)){SNSajaxLogon.GETRequest("/gxlogin/secure/succes.jsp","")}return false};SNSajaxLogon.logonSIA=function(C,B,A){SNSajaxLogon.FormId=C;SNSajaxLogon.Type="SIA";SNSajaxLogon.FieldId=A;if(SNSajaxLogon.checkResultFieldSIA(C,B,A)){SNSajaxLogon.GETRequest("/gxlogin/secure/succes.jsp","")}return false};SNSajaxLogon.checkLoggedIn=function(A){SNSajaxLogon.xmlHttp=SNSajaxLogon.createXMLHttpRequest();SNSajaxLogon.xmlHttp.onreadystatechange=function(){if(SNSajaxLogon.xmlHttp.readyState==4){logon_response=-1;if(SNSajaxLogon.xmlHttp.status!=null&&SNSajaxLogon.xmlHttp.status==200){strXML=SNSajaxLogon.trim(SNSajaxLogon.xmlHttp.responseText);if(strXML.length>=3){logon_response=parseInt(strXML.substring(0,3))}}if(logon_response!=200){A()}}};SNSajaxLogon.xmlHttp.open("GET","/gxlogin/secure/succes.jsp",true);SNSajaxLogon.xmlHttp.send(null)};SNSajaxLogon.checkDigipas=function(C,B){var A=true;SNSajaxLogon.FormId=C;A=SNSajaxLogon.checkResultFieldDGP(C,B);if(A){objForm=document.getElementById(C);if(objForm!=null){objForm.submit()}}return false};SNSajaxLogon.nextFormStep=function(){var A=document.getElementById(SNSajaxLogon.FormId);if(A!=null){A.submit()}};SNSajaxLogon.goDGP=function(){var B="1";var D=document.getElementById(SNSajaxLogon.cFieldTicket).value;var A=document.getElementById(SNSajaxLogon.cFieldChallenge).value;var C=document.getElementById(SNSajaxLogon.cFieldResponse).value;SNSajaxLogon.POSTRequest("/gxlogin/secure/j_security_check","j_username="+B+" "+document.getElementById(SNSajaxLogon.cFieldDigipas).value+" "+D+" "+A+"&j_password="+C);return false};SNSajaxLogon.goSIA=function(){var A="5";var B=document.getElementById(SNSajaxLogon.cFieldPassword).value;B=escape(B);SNSajaxLogon.POSTRequest("/gxlogin/secure/j_security_check","j_username="+A+" "+document.getElementById(SNSajaxLogon.cFieldUsername).value+"&j_password="+B);return false};SNSajaxLogon.checkResultFieldEmpty=function(D,A,C){var B=document.getElementById(A);if(C==true&&B!=null){removeError(D,A);if(B.value==""){setError(D,A,"Dit is een verplicht veld. Vul dit veld in.");C=false}}return C};SNSajaxLogon.checkResultFieldMinSize=function(E,A,D,C){var B=document.getElementById(A);if(C==true&&B!=null){removeError(E,A);if(B.value.length<D){setError(E,A,"De invoer in het veld is niet lang genoeg, voer minimaal "+D+" tekens in");C=false}}return C};SNSajaxLogon.checkResultFieldNumeric=function(E,A,D){var B=document.getElementById(A);var C=/^\d*$/;if(D==true&&B!=null&&B.value!=""){removeError(E,A);if(!C.test(B.value)){setError(E,A,"Dit is geen correct nummer. Vul een nummer in zonder toevoeging.");D=false}}return D};SNSajaxLogon.checkResultFieldDGP=function(D,B){var C=document.getElementById(B);var E=document.getElementById(D);var A=true;A=SNSajaxLogon.checkResultFieldEmpty(E,B,A);A=SNSajaxLogon.checkResultFieldNumeric(E,B,A);A=SNSajaxLogon.checkResultFieldMinSize(E,B,6,A);return A};SNSajaxLogon.checkResultFieldSIA=function(D,C,A){var E=document.getElementById(D);var B=true;B=SNSajaxLogon.checkResultFieldEmpty(E,C,B);B=SNSajaxLogon.checkResultFieldEmpty(E,A,B);return B};SNSajaxLogon.showUnknownError=function(){var A="Er is een fout opgetreden waardoor er momenteel niet ingelogd kan worden. Probeer het later nog een keer. Ons excuus voor het ongemak.";var B=document.getElementById(SNSajaxLogon.FormId);if((B!=null)&&(SNSajaxLogon.FieldId!=null)&&(SNSajaxLogon.FieldId!="")){removeError(B,SNSajaxLogon.FieldId)}SNSajaxLogon.showError(A)};SNSajaxLogon.showError=function(A){var B=document.getElementById(SNSajaxLogon.FormId);if((B!=null)&&(SNSajaxLogon.FieldId!=null)&&(SNSajaxLogon.FieldId!="")){setError(B,SNSajaxLogon.FieldId,A)}else{A=A.replace(/\. /g,".\n");alert(A)}if(SNSajaxLogon.Type=="DGP"){setTimeout("history.go(-1)",2000)}};SNSajaxLogon.showHTTPError=function(A){var C="Er is een fout opgetreden waardoor er momenteel niet ingelogd kan worden. %text%. Probeer het later nog een keer. Ons excuus voor het ongemak.";var D=document.getElementById(SNSajaxLogon.FormId);var B="";if(A==403){B="U heeft momenteel geen rechten om een pagina te benaderen"}else{if(A==404){B="Een pagina kon niet gevonden worden"}else{if(A==408){B="Er is een timeout opgetreden"}else{B=""}}}C=C.replace("%text%",B);SNSajaxLogon.showError(C)};SNSajaxLogon.stopEnterKey=function(A){if(A==null){if(event==null){A=null}else{A=event}}var B;if(A.target==null){if(A.srcElement==null){B=null}else{B=A.srcElement}}else{B=A.target}if((A.keyCode==13)&&((B.type=="text")||(B.type=="password"))){return false}};SNSajaxLogon.trim=function(A){A=A.replace(/^\s+/,"");A=A.replace(/\s+$/,"");return A};document.onkeypress=SNSajaxLogon.stopEnterKey;
