").addClass("breadcrumb").data("formObj",curFormObj).on("click",function(event){event.preventDefault();aanmeldForms.navigateBack($(this).data('formObj'));}).append($("")).append(this.currentStep.data("title")));if(silent){$(this).remove();}else{this.currentStep.slideUp(150,function(){$(this).remove();});}
this.currentStep=null;}
var $form=$.createFormWithUid(formObj);if((formObj.Data||null)!==null&&formObj.Data.Steps!==null){$form.data("title","Step {1} of {2} - {0}".format($form.data("title"),formObj.Data.Step,formObj.Data.Steps));}
$form.find(":data(reqsetup)").each(function(){var $me=$(this);switch($me.data("reqsetup")){case"countries":$me.empty();for(var i=0;i").data("rec",cntry).attr("value",cntry.Code).text(cntry.Name));}
break;}});$form.formHandler().fill(this.data);$form.find(".forceUpperCase").on("change",function(){$(this).val($(this).val().toUpperCase());});$form.find(".alphanumeric").on("change",function(){$(this).val($(this).val().replace(/[^0-9a-z]/gi,''));});$form.find('.formatInitials').on("change",function(){var val=$(this).val();if(val)
{val=val.replace(/\./g,'').split('').join('.')+".";$(this).val(val);}});$form.find(".capitalize").on("keydown",function(event){if(this.selectionStart===0&&event.keyCode>=65&&event.keyCode<=90&&!(event.shiftKey)&&!(event.ctrlKey)&&!(event.metaKey)&&!(event.altKey)){var $t=$(this);event.preventDefault();var char=String.fromCharCode(event.keyCode);$t.val(char+$t.val().slice(this.selectionEnd));this.setSelectionRange(1,1);}});$form.find("#Firstname").on("change",function(){var names=$(this).val();if(names)
{var initials=$form.find("#Initials");if(!initials.val())
{var first_letter=function(x){if(x){return x[0].toUpperCase();}else{return'';}};initials.val(names.split(' ').map(first_letter).join('.')+".");}}});this.currentStep=$.mysenaBox({headerText:$('').append($('')).append($('').text($form.data("title"))),body:$form,allowClose:false,showInline:true});this.currentStep.data("formObj",formObj);this.currentStep.data("title",$form.data("title"));this.navigationStack.push(formObj);$("#"+this.containerId).append(this.currentStep);if(!silent){this.currentStep.slideDown(150);}},navigateBack:function(formObj){if(formObj==null){this.navigationStack.pop();formObj=this.navigationStack.pop();}else{var curFormObj;while(this.navigationStack.length>0){curFormObj=this.navigationStack.pop();if(curFormObj===formObj){break;}}}
this.removeTill(formObj);this.currentStep=null;this.navigate(formObj);},removeTill:function(formObj){$($('#'+this.containerId).children().get().reverse()).each(function(){var curFormObj=$(this).data('formObj');$(this).slideUp(150,function(){$(this).remove();});if(curFormObj===formObj){return false;}});},disable:function(){$($('#'+this.containerId).children().get().reverse()).each(function(){var thisForm=$(this);if(!thisForm.hasClass("mysenaBox")){thisForm.addClass("breadcrumbDisabled");thisForm.removeClass("breadcrumb");thisForm.off("click");}});}};function changeLanguage(lang){app.ajax({url:"/mysena/Home/_Language",data:{Code:lang},onSuccess:function(response){document.location.reload();},onError:function(response){showGlobalError(response.Error||"Communication with the server failed");}});}
$(document).ready(function(){app.ajax({url:'/mysena/Aanmelden/_Banks',onSuccess:function(response){banks=response;},onError:function(response){$.mysenaAlert(response.Error||"Could not load banks. Please try again later.");}});$.validator.messages.required='This field is required.';$.validator.messages.email='Please enter a valid email address.';$.validator.messages.url='Please enter a valid URL.';$.validator.addMethod("date",function(value,element){if(this.optional(element)){return true;}
var ok=true;try{var calformat=$(element).data("calformat");if(calformat!=null){app.date(value,calformat,app.timeFormat);}else
ok=false;}catch(err){ok=false;}
return ok;},'The date isn't valid');$.validator.addMethod("TIN",function(value,element){if(value==null||value==='')
return true;if($(element).closest("form").find("#DutchTaxpayer").prop("checked")===true){if(value.length!==9){return false;}
var iBsn=parseInt(value);if(isNaN(iBsn)||iBsn>999999999&&iBsn<=99999999){return false;}
var lSum=0;for(var iCnt=1;iCnt<=value.length;iCnt++){lSum=lSum+(((10-iCnt)===1)?-1:(10-iCnt))*parseInt(value[iCnt-1]);}
return((lSum%11)===0);}
return true;},"The Tax Identification Number entered is not valid");$.validator.addMethod("bicifnl",function(value,element){if($(element).closest("form").find("#BankCountryCode").val()=="NL"){if($(element).closest("form").find("#BankSwift").val()!==""&&$(element).closest("form").find("#BankName").val()!==""){return true;}else{return false;}}
return true;},"Invalid IBAN number");$.validator.addMethod("ibancountry",function(value,element){if($("#BankCountryCode").find(":selected").data("rec").IbanCountry&&$(element).closest("form").find("#BankCountryCode").val()!==$(element).closest("form").find("#BankIban").val().substr(0,2)){return false;}
return true;},"The IBAN countrycode is not the same as the selected country of bank.");$.validator.addMethod("btwnr",function(value,element){if(value==null||value.length===0){return true;}
value=value.toUpperCase();element.value=value;$form=$(element).closest("form");var data=$form.formHandler().serialize();var result=false;app.ajax({url:'/mysena/Validation/IsValidVat',data:{vatNumber:value,model:data},async:false,onSuccess:function(response){result=true;},onError:function(response){}});return result;},"Invalid VAT identification number");$.validator.addMethod("zipcode",function(value,element){if(value==null||value==='')
return true;var result=true;$("#"+$(element).data("country")).first().each(function(){switch($(this).val()){case"NL":result=/^[0-9]{4}[ ]{0,1}[A-Z]{2}$/.test(value);break;case"BE":result=/^[0-9]{4}$/.test(value);break;}
return false;});return result;},"Invalid ZIP code");$.validator.addMethod("phonenumber",function(value,element){if(value==null||value==='')
return true;return/^(\(?\+?[0-9]*\)?)?[0-9_\-\(\)]*$/.test(value);},"Invalid telephone number");$.validator.addMethod("swiftcode",function(value){if(value!=null&&value!==''){return/^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$/i.test(value);}
return true;},"Invalid SWIFT code");$.validator.addMethod("iban",function(value){if(value!=null&&value!==''&&$("#BankCountryCode").find(":selected").data("rec").IbanCountry){return value.isIban();}
return true;},"Invalid IBAN number");$.validator.addMethod("max99",function(value){if((value||null)===null)
return true;return value.isNumber()&&value>0&&value<=99;},"The value must be between 1 and 99");$.validator.addMethod("max7",function(value){if((value||null)===null)
return true;return value.isNumber()&&value.length>=1&&value.length<=7;},"Value must be between 1 and 1000000");$.validator.addMethod("initials",function(value){if(value!=null&&value!==''){return/^([A-Z]\.)+$/i.test(value);}
return true;},"The initials entered are not in a valid format (in capitals with dots in between: T.T.)");$.validator.addMethod("kvk",function(value,element){if($(element).closest("form").find("#KVKCountryCode").val()==="NL"){if(value!=null&&value!==''){return/^([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])$/i.test(value);}}
return true;},"The Chamber of Commerce number entered is not valid");$(window).bind('beforeunload',function(){if(aanmeldForms.navigationStack.length>1&&!aanmeldForms.wizardFinished){return"You have not yet completed registration. Are you sure you want to leave the page?";}});aanmeldForms.navigate(aanmeldForms.welcome);});