/* Globals */
var islive = true;
var CurrentFormPage = 0;
var Page_ValidationSummaries;
var Page_Validators;
var Page_ValidationActive = false;
var dovalidate = true;
var skipPage2 = false;

  var arr_fields = new Array('P1Voorletters','P1Voorvoegsel','P1Naam','P1Straat','P1Huisnummer','P1HuisnrToev','P1Postcode','P1Plaats','P1TelPrive','P1EMail');
  function disablefields(disabled) {
   for(var i=0;i<arr_fields.length; i++) {
    document.getElementById(arr_fields[i]).disabled = disabled;
   } 
  }

  function load_validation_page1() { 
	CurrentFormPage = 1;
    
	Page_ValidationSummaries =  new Array(document.all["layercheck"]);
//	Page_ValidationSummaries =  new Array(top.frames[0].document.all["layercheck"]);
	
    Page_Validators =  new Array(document.all["_ctl19"], document.all["_ctl20"], document.all["_ctl21a"],document.all["_ctl21b"],document.all["_ctl21c"], document.all["_ctl23"], document.all["_ctl24a"],document.all["_ctl24b"],document.all["_ctl24c"], document.all["_ctl25"], document.all["_ctl26"], document.all["_ctl27"], document.all["_ctl28"], document.all["_ctl30"],document.all["_ctl30b"], document.all["_ctl31"], document.all["_ctl33a"],document.all["_ctl33b"],document.all["_ctl33c"], document.all["_ctl34"], document.all["_ctl35"], document.all["_ctl36a"],document.all["_ctl36b"],document.all["_ctl36c"], document.all["_ctl37a"],document.all["_ctl37b"],document.all["_ctl37c"]);
    
    if (typeof(clientInformation) != "undefined" && clientInformation.appName.indexOf("Explorer") != -1) {
	  if (typeof(Page_ValidationVer) == "undefined")
		alert("Unable to find script library '/aspnet_client/system_web/1_0_3705_288/WebUIValidation.js'. Try placing this file manually, or reinstall by running 'aspnet_regiis -c'.");
	  else if (Page_ValidationVer != "125")
		alert("This page uses an incorrect version of WebUIValidation.js. The page expects version 125. The script library is " + Page_ValidationVer + ".");
	  else
		ValidatorOnLoad();
    }

    initForm();
  }

  function Validate_Page1() {
   if (dovalidate) {
    if (Page_ClientValidate()) { 
	 if (skipPage2 == false) {
		  NextPage(1); 
	 }
	 else {
		 NextPage(2);
	 }
	}
   } else { 
	   	 if (skipPage2 == false) {
		  NextPage(1); 
	 }
	 else {
		 NextPage(2);
	 }

	}
  }

  function load_validation_page2() { 
   CurrentFormPage = 2;
//   Page_ValidationSummaries =  new Array(document.all["layercheck"]);
   Page_Validators =  new Array(document.all["_ctl68"], document.all["_ctl69"], document.all["_ctl71a"],document.all["_ctl71b"],document.all["_ctl71c"], document.all["_ctl73a"],document.all["_ctl73b"],document.all["_ctl73c"], document.all["_ctl74"]);
   ValidatorOnLoad();
   initForm();
  }

  function Validate_Page2() {
   if (dovalidate) {
    if (Page_ClientValidate()) { 
	 NextPage(2); 
	}
   } else { NextPage(2); }
  }

  function load_validation_page3() { 
   CurrentFormPage = 3;
 //  Page_ValidationSummaries =  new Array(document.all["layercheck"]);
   Page_Validators =  new Array(document.all["_ctl89"], document.all["_ctl90"], document.all["_ctl91"]);
   ValidatorOnLoad();
   initForm();
  }

  function Validate_Page3() {
   if (dovalidate) {
    if (Page_ClientValidate()) { 
	 NextPage(3); 
	}
   } else { NextPage(3); }
  }
  	
  function load_validation_page4() { 
   CurrentFormPage = 4;
   //  Page_ValidationSummaries =  new Array(document.all["layercheck"]);
   Page_Validators =  new Array(document.all["_ctl96"], document.all["_ctl97"], document.all["_ctl98"], document.all["_ctl99"], document.all["_ctl100"]);
 //  Page_Validators =  new Array(document.all["_ctl96"]);
   ValidatorOnLoad();
   initForm();
  }

  function Validate_Page4() {
   if (dovalidate) {
    if (Page_ClientValidate()) { 
	 submitform();
	}
   } else { 
    submitform(); 
   }
  }


function submitform() {

/*
 var tempstr,str = '';
 for (i=0;i<=document.forms["_ctl0"].elements.length-1;i++) {
  tempstr = document.forms["_ctl0"].elements[i].name;
  str = str + '"' + tempstr + '",';
  
 }
// alert(str);
  
 document.write('<textarea name="fields" cols="" rows="">' + str + '</textarea>');
*/

 document.forms["_ctl0"].submit();
}


function PrintPages() {
 oldaction = document.forms['_ctl0'].action;
 oldtarget = document.forms['_ctl0'].target;
 
 if (islive) {
  w = window.open('/formulier/blank.html','print','status=yes,scrollbars=yes,width=560,height=600');
  document.forms['_ctl0'].action = '/formulier/print-hypotheek.php'; 
 } else {
  w = window.open('/easyflow-live/formulier/blank.html','print','status=yes,scrollbars=yes,width=560,height=600'); 
  document.forms['_ctl0'].action = '/easyflow-live/formulier/print-hypotheek.php';
 }
 

 document.forms['_ctl0'].target = 'print';
 document.forms['_ctl0'].submit();
 
 document.forms['_ctl0'].action = oldaction;
 document.forms['_ctl0'].target = oldtarget;
}


function PrevPage(pagenum) {
 if (pagenum == 2) {
   document.getElementById('divPage1').style.display = '';
   document.getElementById('divPage2').style.display = 'none';
   load_validation_page1();
 } else if (pagenum == 3) {
   if (skipPage2 == true){
	   document.getElementById('divPage2').style.display = '';
	   document.getElementById('divPage3').style.display = 'none';
   }
   else {
	   document.getElementById('divPage2').style.display = '';
	   document.getElementById('divPage3').style.display = 'none';
   }
   load_validation_page2();
 } else if (pagenum == 4) {
   document.getElementById('divPage3').style.display = '';
   document.getElementById('divPage4').style.display = 'none';
   load_validation_page3();
 }
}

function NextPage(pagenum) {
 if (pagenum == 1) {
   document.getElementById('divPage1').style.display = 'none';
   document.getElementById('divPage2').style.display = '';
   load_validation_page2();
 } else if (pagenum == 2) {
   document.getElementById('divPage1').style.display = 'none';
   document.getElementById('divPage2').style.display = 'none';
   document.getElementById('divPage3').style.display = '';
   load_validation_page3();
 } else if (pagenum == 3) {
   document.getElementById('divPage1').style.display = 'none';
   document.getElementById('divPage2').style.display = 'none';
   document.getElementById('divPage3').style.display = 'none';
   document.getElementById('divPage4').style.display = '';
   load_validation_page4();   
 }
}
/* Format TextBox value to initials string */
function FormatInitials(TBControl) {
    TBControl.value = removeSpaces(TBControl.value.toUpperCase());

	var retour = new String();
	for (var i=0; i < TBControl.value.length; i++) {
		if (isInAlfabet(TBControl.value.charAt(i))) {
			retour += (TBControl.value.charAt(i) + ".");
		}
	}
	TBControl.value = retour;
}


/* Check if value is Numeric */
function removeSpaces(waarde) {
	var retour = new String();
	for (var i=0; i < waarde.length; i++) {
		if (!(waarde.charAt(i) == " ")) {
			retour += waarde.charAt(i);
		}
	}
	return retour;
}


/* Replace (Seek)Chars in string with (Replacement)Chars */
function ReplaceChars(StringWaarde, SeekChar, ReplacementChar) {
	var retour = new String();
	for (var i=0; i < StringWaarde.length; i++) {
		if (StringWaarde.charAt(i) == SeekChar) {
			retour += ReplacementChar;
		}
		else {
			retour += StringWaarde.charAt(i);
		}
	}
	return retour;
}


/* Check if value is in alfabet */
function isInAlfabet(waarde) {
    if (((waarde>= "a") && (waarde<= "z")) || ((waarde>= "A") && (waarde<= "Z"))) {
		return true;
	}
	return false;
}


/* Check if TextBox value is valid Dutch PostalCode */
function CheckPostalcode(TBControl) {
    TBControl.value = removeSpaces(TBControl.value.toUpperCase());
    if ((TBControl.value.length != 6) ||
        (parseInt(TBControl.value) < 1000) ||
        (parseInt(TBControl.value) > 9999) ||
        (!(isInAlfabet(TBControl.value.charAt(4)))) ||
        (!(isInAlfabet(TBControl.value.charAt(5)))) ) {
			alert("Vul een geldige (Nederlandse) postcode in.");
			TBControl.focus();
			return false;
    }
}



/*
function CheckNumeric(TBControl) {
	if (TBControl.value.length > 0)	{
		if (TBControl.value != parseInt(TBControl.value)) {
			alert("Dit veld mag alleen cijfers bevatten.\nLetters en speciale tekens zijn niet toegestaan.");
			TBControl.focus();
			return false;
		}
	}
}
*/
function CheckNumeric(TBControl) {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;
   var strString = '';
   strString = TBControl.value;
   
   if (strString.length <= 0) return false;
   
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)  {
    strChar = strString.charAt(i);
    if (strValidChars.indexOf(strChar) == -1) {
     blnResult = false;
    }
   }
   if (blnResult == false) {
	 alert("Dit veld mag alleen cijfers bevatten.\nLetters en speciale tekens zijn niet toegestaan.");
	 TBControl.value = '';
	 TBControl.focus();
   }
   return blnResult;

}

function CheckNumeric2(TBControl) {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   var strString = '';
   strString = TBControl.value;
   
   if (strString.length <= 0) return false;
   
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)  {
    strChar = strString.charAt(i);
    if (strValidChars.indexOf(strChar) == -1) {
     blnResult = false;
    }
   }
   if (blnResult == false) {
	 alert("Dit veld mag alleen cijfers bevatten.\nLetters en speciale tekens zijn niet toegestaan.");
	 TBControl.value = '';
	 TBControl.focus();
   }
   return blnResult;

}


/* Check if TextBox value is valid BankAccount */
function ValidateAccount(s, e) {
	var waarde	= e.Value;
	var lengte	= waarde.length;
	
	if (lengte >= 9) {
		var sum = 0;
		var startNummer = (((waarde.charAt(0) == 0) && (lengte > 9)) ? 1 : 0);
		
		for (i=startNummer; i<lengte; i++) {
			sum += (lengte-i)*waarde.charAt(i);
		}
		
		e.IsValid = (((sum/11) - (parseInt(sum/11))) == 0);
	}
	else  {
	   e.IsValid = ((lengte <=7) && (lengte >= 3));
	}	   
}


/* Change the first character into an uppercase character  */
function FirstToUpper(TBControl) {
	if (TBControl.value.length > 0)	{
		TBControl.value = TBControl.value.charAt(0).toUpperCase() + TBControl.value.substring(1);
	}
}


/* Check if TextBox value is TextOnly */
function CheckTextOnly(TBControl) {
	for (var LnIndex = 0; LnIndex < TBControl.value.length; LnIndex++) {
   		if (! isInAlfabet(TBControl.value.charAt(LnIndex))) {
			TBControl.focus();
			alert("Dit veld mag alleen letters bevatten.\nLeestekens en cijfers zijn niet toegestaan.");
			return false;
			break;
		}
	}
}


/* Change the first character into an uppercase character And Check if TextBox value is TextOnly */
function CheckFirstToUpperTextOnly(TBControl) {
	FirstToUpper(TBControl);
	CheckTextOnly(TBControl);
}


/* Format TextBox value to rounded currency value */
function FormatCurrency(TBControl) {
    TBControl.value = Math.round(parseFloat(ReplaceChars("0" + TBControl.value, "," , ".")));
}


function P1Burgerlijkestaat_Change() {
 var list = document.getElementById('P1Burgerlijkestaat');
 var listindex = document.getElementById('P1Burgerlijkestaat').selectedIndex;
 document.getElementById('P1BurgerlijkestaatText').value = list.options[listindex].text;
	
 var toToggleText = new Array("P2Voorletters","P2Naam","P2Voorvoegsel","P2GeboorteDatumDag","P2GeboorteDatumMaand","P2GeboorteDatumJaar","P2SofiNummer","P2WS_Naam","P2WS_vestigingsplaats","P2WS_Beroep_anders","P2WS_DatumSindsDag","P2WS_DatumSindsMaand","P2WS_DatumSindsJaar","P3BrutoLoonPartner","P3VerzekeringKapitaalPartner");

 var toToggleNoText = new Array("P2Nationaliteit","P2WS_Beroep","P2SoortDienstverband","P2Geslacht_0","P2Geslacht_1");

if (document.getElementById('P1Burgerlijkestaat').selectedIndex == 0) {
	//alert('partner velden non-actief');


	for (i=0;i < toToggleText.length; i++ ) {
		document.getElementById(toToggleText[i]).style.backgroundColor = '#aaaaaa';
		document.getElementById(toToggleText[i]).value = 'nvt';
		document.getElementById(toToggleText[i]).disabled = true;		
	}
	for (i=0;i < toToggleNoText.length; i++ ) {
		document.getElementById(toToggleNoText[i]).style.backgroundColor = '#aaaaaa';
		document.getElementById(toToggleNoText[i]).disabled = true;		
	}
skipPage2 = true;
}
else {
	
	for (i=0;i < toToggleText.length ;i++ ) {
		document.getElementById(toToggleText[i]).disabled = false;
		//document.getElementById(toToggleText[i]).value = '';
		document.getElementById(toToggleText[i]).style.backgroundColor = 'white';
	}
	for (i=0;i < toToggleNoText.length ;i++ ) {
		document.getElementById(toToggleNoText[i]).style.backgroundColor = 'white';
		document.getElementById(toToggleNoText[i]).disabled = false;		
	}

skipPage2 = false;
}




/* if (document.getElementById('P1Burgerlijkestaat').value == '02') {
      document.getElementById('TD_P1BSDatum').style.fontWeight	= 'bold';
   }
   else {
      document.getElementById('TD_P1BSDatum').style.fontWeight	= '';
   }
   
   for (var i = 0; i < Page_Validators.length; i++) {
      if ((Page_Validators[i].controltovalidate == 'P1BSDatum') &&
          (Page_Validators[i].EvalTag == 'Required')) {
         Page_Validators[i].enabled = (document.getElementById('P1Burgerlijkestaat').value == '02');
      }
   }
*/
}

function P1Nationaliteit_Change () {
   if (document.getElementById('P1Nationaliteit').value == 'NLD') {
      document.getElementById('divNonDutchP1').style.display		= 'none';
      document.getElementById('P1InNLSindsDag').disabled			= 'true';
      document.getElementById('P1InNLSindsDag').value			    = '';
      document.getElementById('P1InNLSindsMaand').disabled			= 'true';
      document.getElementById('P1InNLSindsMaand').value			    = '';
      document.getElementById('P1InNLSindsJaar').value			    = '';
      document.getElementById('P1InNLSindsJaar').disabled			= 'true';
      document.getElementById('P1Verblijfsvergunning_1').checked    = 'true';
	  document.getElementById('P1Verblijfsvergunning').disabled	    = 'true';
      document.getElementById('P1Werkvergunning').disabled		    = 'true';
      document.getElementById('P1Werkvergunning_1').checked		    = 'true';
   }
   else {
      document.getElementById('divNonDutchP1').style.display		= '';
      document.getElementById('P1InNLSindsDag').disabled			= '';
      document.getElementById('P1InNLSindsMaand').disabled			= '';
      document.getElementById('P1InNLSindsJaar').disabled			= '';
      document.getElementById('P1Verblijfsvergunning').disabled	= '';
      document.getElementById('P1Werkvergunning').disabled		= '';
   }
   
   for (var i = 0; i < Page_Validators.length; i++) {
      if (Page_Validators[i].controltovalidate == "P1InNLSindsDag") {
         Page_Validators[i].enabled = !(document.getElementById('P1Nationaliteit').value == 'NLD');
      }
   }
}

function P2Nationaliteit_Change () {
   if (document.getElementById('P2Nationaliteit').value == 'NLD') {
      document.getElementById('divNonDutchP2').style.display		= 'none';
      document.getElementById('P2InNLSindsDag').disabled			= 'true';
      document.getElementById('P2InNLSindsDag').value			    = '';
      document.getElementById('P2InNLSindsMaand').disabled			= 'true';
      document.getElementById('P2InNLSindsMaand').value			    = '';
      document.getElementById('P2InNLSindsJaar').value			    = '';
      document.getElementById('P2InNLSindsJaar').disabled			= 'true';
      document.getElementById('P2Verblijfsvergunning_1').checked    = 'true';
	  document.getElementById('P2Verblijfsvergunning').disabled	    = 'true';
      document.getElementById('P2Werkvergunning').disabled		    = 'true';
      document.getElementById('P2Werkvergunning_1').checked		    = 'true';
   }
   else {
      document.getElementById('divNonDutchP2').style.display		= '';
      document.getElementById('P2InNLSindsDag').disabled			= '';
      document.getElementById('P2InNLSindsMaand').disabled			= '';
      document.getElementById('P2InNLSindsJaar').disabled			= '';
      document.getElementById('P2Verblijfsvergunning').disabled	= '';
      document.getElementById('P2Werkvergunning').disabled		= '';
   }
   
   for (var i = 0; i < Page_Validators.length; i++) {
      if (Page_Validators[i].controltovalidate == "P2InNLSindsDag") {
         Page_Validators[i].enabled = !(document.getElementById('P2Nationaliteit').value == 'NLD');
      }
   }
}

function P1WS_Beroep_Change() {
   var list = document.getElementById('P1WS_Beroep');
   var listindex = document.getElementById('P1WS_Beroep').selectedIndex;
   document.getElementById('P1WS_BeroepText').value = list.options[listindex].text;
}

function P2WS_Beroep_Change() {
   var list = document.getElementById('P2WS_Beroep');
   var listindex = document.getElementById('P2WS_Beroep').selectedIndex;
   document.getElementById('P2WS_BeroepText').value = list.options[listindex].text;
}


function P1SoortDienstverband_Change() {
   var list = document.getElementById('P1SoortDienstverband');
   var listindex = document.getElementById('P1SoortDienstverband').selectedIndex;
   document.getElementById('P1SoortDienstverbandText').value = list.options[listindex].text;

   if ((document.getElementById('P1SoortDienstverband').value == '03') ||
       (document.getElementById('P1SoortDienstverband').value == '04') ||
       (document.getElementById('P1SoortDienstverband').value == '06')
      ) {
      document.getElementById('divP1WSEindDatum').style.display	= '';
      document.getElementById('P1WS_DatumTotDag').disabled		= '';
      document.getElementById('P1WS_DatumTotMaand').disabled	= '';
      document.getElementById('P1WS_DatumTotJaar').disabled		= '';
   }
   else {
      document.getElementById('divP1WSEindDatum').style.display	= 'none';
      document.getElementById('P1WS_DatumTotDag').disabled		= 'true';
      document.getElementById('P1WS_DatumTotDag').value			= '';
      document.getElementById('P1WS_DatumTotMaand').disabled	= 'true';
      document.getElementById('P1WS_DatumTotMaand').value			= '';
      document.getElementById('P1WS_DatumTotJaar').disabled		= 'true';
      document.getElementById('P1WS_DatumTotJaar').value			= '';
   }

   if (document.getElementById('P1SoortDienstverband').value == '07') {
      document.getElementById('TD_P1WSnaam').style.fontWeight			= 'normal';
      document.getElementById('TD_P1WS_DatumSinds').style.fontWeight	= 'normal';
   }
   else {
      document.getElementById('TD_P1WSnaam').style.fontWeight			= 'bold';
      document.getElementById('TD_P1WS_DatumSinds').style.fontWeight	= 'bold';
   }      
   
   //P1WS_SoortDV
   for (var i = 0; i < Page_Validators.length; i++) {
      if (Page_Validators[i].controltovalidate == "P1WS_DatumTotDag") {
         Page_Validators[i].enabled = ((document.getElementById('P1SoortDienstverband').value == '03') ||
								       (document.getElementById('P1SoortDienstverband').value == '04') ||
								       (document.getElementById('P1SoortDienstverband').value == '06'));
      }
      if (Page_Validators[i].controltovalidate == "P1WS_DatumTotMaand") {
         Page_Validators[i].enabled = ((document.getElementById('P1SoortDienstverband').value == '03') ||
								       (document.getElementById('P1SoortDienstverband').value == '04') ||
								       (document.getElementById('P1SoortDienstverband').value == '06'));
      }
      if (Page_Validators[i].controltovalidate == "P1WS_DatumTotJaar") {
         Page_Validators[i].enabled = ((document.getElementById('P1SoortDienstverband').value == '03') ||
								       (document.getElementById('P1SoortDienstverband').value == '04') ||
								       (document.getElementById('P1SoortDienstverband').value == '06'));
      }
	  
      if (Page_Validators[i].controltovalidate == "P1WS_Naam") {
         Page_Validators[i].enabled = (!(document.getElementById('P1SoortDienstverband').value == '07'));
      }

      if ((Page_Validators[i].controltovalidate == "P1WS_DatumSindsDag") &&
          (Page_Validators[i].EvalTag == 'Required')) {
         Page_Validators[i].enabled = (!(document.getElementById('P1SoortDienstverband').value == '07'));
      }
      if ((Page_Validators[i].controltovalidate == "P1WS_DatumSindsMaand") &&
          (Page_Validators[i].EvalTag == 'Required')) {
         Page_Validators[i].enabled = (!(document.getElementById('P1SoortDienstverband').value == '07'));
      }
      if ((Page_Validators[i].controltovalidate == "P1WS_DatumSindsJaar") &&
          (Page_Validators[i].EvalTag == 'Required')) {
         Page_Validators[i].enabled = (!(document.getElementById('P1SoortDienstverband').value == '07'));
      }

	  
   }
}

function P2SoortDienstverband_Change() {
   var list = document.getElementById('P2SoortDienstverband');
   var listindex = document.getElementById('P2SoortDienstverband').selectedIndex;
   document.getElementById('P2SoortDienstverbandText').value = list.options[listindex].text;
   
   if ((document.getElementById('P2SoortDienstverband').value == '03') ||
       (document.getElementById('P2SoortDienstverband').value == '04') ||
       (document.getElementById('P2SoortDienstverband').value == '06')
      ) {
      document.getElementById('divP2WSEindDatum').style.display	= '';
      document.getElementById('P2WS_DatumTotDag').disabled		= '';
      document.getElementById('P2WS_DatumTotMaand').disabled	= '';
      document.getElementById('P2WS_DatumTotJaar').disabled		= '';
   }
   else {
      document.getElementById('divP2WSEindDatum').style.display	= 'none';
      document.getElementById('P2WS_DatumTotDag').disabled		= 'true';
      document.getElementById('P2WS_DatumTotDag').value			= '';
      document.getElementById('P2WS_DatumTotMaand').disabled	= 'true';
      document.getElementById('P2WS_DatumTotMaand').value		= '';
      document.getElementById('P2WS_DatumTotJaar').disabled		= 'true';
      document.getElementById('P2WS_DatumTotJaar').value		= '';
   }
   

   if (document.getElementById('P2SoortDienstverband').value == '07') {
      document.getElementById('TD_P2WSnaam').style.fontWeight			= 'normal';
      document.getElementById('TD_P2WS_DatumSinds').style.fontWeight	= 'normal';
   }
   else {
      document.getElementById('TD_P2WSnaam').style.fontWeight			= 'bold';
      document.getElementById('TD_P2WS_DatumSinds').style.fontWeight	= 'bold';
   }      

   for (var i = 0; i < Page_Validators.length; i++) {
      if (Page_Validators[i].controltovalidate == "P2WS_DatumTotDag") {
         Page_Validators[i].enabled = ((document.getElementById('P2SoortDienstverband').value == '03') ||
								       (document.getElementById('P2SoortDienstverband').value == '04') ||
								       (document.getElementById('P2SoortDienstverband').value == '06'));
      }
      if (Page_Validators[i].controltovalidate == "P2WS_DatumTotMaand") {
         Page_Validators[i].enabled = ((document.getElementById('P2SoortDienstverband').value == '03') ||
								       (document.getElementById('P2SoortDienstverband').value == '04') ||
								       (document.getElementById('P2SoortDienstverband').value == '06'));
      }
      if (Page_Validators[i].controltovalidate == "P2WS_DatumTotJaar") {
         Page_Validators[i].enabled = ((document.getElementById('P2SoortDienstverband').value == '03') ||
								       (document.getElementById('P2SoortDienstverband').value == '04') ||
								       (document.getElementById('P2SoortDienstverband').value == '06'));
      }

      if (Page_Validators[i].controltovalidate == "P2WS_Naam") {
         Page_Validators[i].enabled = (!(document.getElementById('P2SoortDienstverband').value == '07'));
      }
      if ((Page_Validators[i].controltovalidate == "P2WS_DatumSindsDag") &&
          (Page_Validators[i].EvalTag == 'Required')) {
         Page_Validators[i].enabled = (!(document.getElementById('P2SoortDienstverband').value == '07'));
      }
      if ((Page_Validators[i].controltovalidate == "P2WS_DatumSindsMaand") &&
          (Page_Validators[i].EvalTag == 'Required')) {
         Page_Validators[i].enabled = (!(document.getElementById('P2SoortDienstverband').value == '07'));
      }
      if ((Page_Validators[i].controltovalidate == "P2WS_DatumSindsJaar") &&
          (Page_Validators[i].EvalTag == 'Required')) {
         Page_Validators[i].enabled = (!(document.getElementById('P2SoortDienstverband').value == '07'));
      }
	  
   }
   
   
}


function P1Gescheiden_Change() {
   if (document.getElementById('P1Gescheiden_0').checked) {
      document.getElementById('divP1GSDatumGescheiden').style.display	= '';
      document.getElementById('P1GescheidenSindsDag').disabled		    = '';
      document.getElementById('P1GescheidenSindsMaand').disabled		= '';
      document.getElementById('P1GescheidenSindsJaar').disabled		    = '';
   }
   else {
      document.getElementById('divP1GSDatumGescheiden').style.display	= 'none';
      document.getElementById('P1GescheidenSindsDag').disabled		    = 'true';
      document.getElementById('P1GescheidenSindsDag').value		    	= '';
      document.getElementById('P1GescheidenSindsMaand').disabled		= 'tru';
      document.getElementById('P1GescheidenSindsMaand').value	    	= '';
      document.getElementById('P1GescheidenSindsJaar').disabled		    = 'true';
      document.getElementById('P1GescheidenSindsJaar').value	    	= '';

   }
   
   for (var i = 0; i < Page_Validators.length; i++) {
      if (Page_Validators[i].controltovalidate == "P1GescheidenSindsDag") {
         Page_Validators[i].enabled = document.getElementById('P1Gescheiden_0').checked;
      }
   }
}

function P3SoortWoning_Change() {
   switch (document.getElementById('P3SoortWoning').value) {
      case "H":
         document.getElementById('divWoonlastenKoop').style.display		= 'none';
         document.getElementById('divWoonlastenInwonend').style.display	= 'none';
         document.getElementById('divWoonlastenHuur').style.display		= '';
         document.getElementById('P3WoonlastenKoop').disabled			= 'true';
         document.getElementById('P3WoonlastenInwonend').disabled		= 'true';
         document.getElementById('P3WoonlastenMVT').disabled			= 'true';
         document.getElementById('P3WoonlastenMVTbedrag').disabled		= 'true';
         document.getElementById('P3WoonlastenHuur').disabled			= '';
         break;
      case "K":
         document.getElementById('divWoonlastenHuur').style.display		= 'none';
         document.getElementById('divWoonlastenInwonend').style.display	= 'none';
         document.getElementById('divWoonlastenKoop').style.display		= '';
         document.getElementById('P3WoonlastenHuur').disabled		    = 'true';
         document.getElementById('P3WoonlastenInwonend').disabled	    = 'true';
         document.getElementById('P3WoonlastenKoop').disabled		    = '';
         document.getElementById('P3WoonlastenMVT').disabled		    = '';
         document.getElementById('P3WoonlastenMVTbedrag').disabled	    = '';
         break;
      case "I":
         document.getElementById('divWoonlastenHuur').style.display		= 'none';
         document.getElementById('divWoonlastenKoop').style.display		= 'none';
         document.getElementById('divWoonlastenInwonend').style.display	= '';
         document.getElementById('P3WoonlastenHuur').disabled		 	= 'true';
         document.getElementById('P3WoonlastenKoop').disabled			= 'true';
         document.getElementById('P3WoonlastenMVT').disabled			= 'true';
         document.getElementById('P3WoonlastenMVTbedrag').disabled		= 'true';
         document.getElementById('P3WoonlastenInwonend').disabled		= '';
         break;
   }
   
   for (var i = 0; i < Page_Validators.length; i++) {
      if (Page_Validators[i].controltovalidate == "P3WoonlastenHuur") {
         Page_Validators[i].enabled = (document.getElementById('P3SoortWoning').value == "H");
      }
      if (Page_Validators[i].controltovalidate == "P3WoonlastenKoop") {
         Page_Validators[i].enabled = (document.getElementById('P3SoortWoning').value == "K");
      }
      if (Page_Validators[i].controltovalidate == "P3WoonlastenInwonend") {
         Page_Validators[i].enabled = (document.getElementById('P3SoortWoning').value == "I");
      }
   }
}

function LL_Change(llnummer) {
   if (!(document.getElementById('LL_' + llnummer + 'maatschappij').value == '')) {
      document.getElementById('TD_LL' + llnummer + 'cnum').style.fontWeight  = 'bold';
      document.getElementById('TD_LL' + llnummer + 'saldo').style.fontWeight = 'bold';
   }
   else {
      document.getElementById('TD_LL' + llnummer + 'cnum').style.fontWeight  = '';
      document.getElementById('TD_LL' + llnummer + 'saldo').style.fontWeight = '';
   }
   
   for (var i = 0; i < Page_Validators.length; i++) {
      if ((Page_Validators[i].controltovalidate == ('LL_' + llnummer + 'contractnr')) ||
          (Page_Validators[i].controltovalidate == ('LL_' + llnummer + 'saldo'))) {
         Page_Validators[i].enabled = (!(document.getElementById('LL_' + llnummer + 'maatschappij').value == ''));
      }
   }
}

function voeg_lening_toe(llnummer) {
 document.getElementById('divLening' + llnummer).style.display  = '';
}


function voeg_hypotheek_toe(hhnummer) {
 document.getElementById('divHypotheek' + hhnummer).style.display  = '';
}

function initForm() {
   if (CurrentFormPage == 1) {
      P1Nationaliteit_Change();
      P1SoortDienstverband_Change();
      P1Gescheiden_Change();
      P1Burgerlijkestaat_Change();
   }
   if (CurrentFormPage == 2) {
      P2Nationaliteit_Change();
      P2SoortDienstverband_Change();
   }
   if (CurrentFormPage == 3) {
      P3SoortWoning_Change();
   }
   if (CurrentFormPage == 4) {
	  LL_Change(1);
	  LL_Change(2);
	  LL_Change(3);
	  LL_Change(4);
   }
}


function toNextField(currentFieldName,nextFieldName,charCount) {
 //keycode is global var

 ignorekeycodes = Array(8,9,16,37,39,46);
 
 check = false;
 for (i=0;i<=ignorekeycodes.length;i++) {
  if (keycode == ignorekeycodes[i]) {
   check = true;
   break;
  }
 }
 
 if (check == false) {
  currentField = document.getElementById(currentFieldName);
  nextField = document.getElementById(nextFieldName);
  if (currentField.value.length >= charCount) {
   nextField.focus(); 
  }
 }
 
}

