
/* function to highlight the background of formfield on error */
function HiLite(fieldname) {
	$(fieldname).style.backgroundColor  = "#ff0000";
	
	}
	
/* function to reset the background color formfield  */
function LoLite(fieldname) {
	$(fieldname).style.backgroundColor  = "#ffffff";
	}


/* check form velden stap 2*/

function checkStep2() {

		var goodToGo = "yes";
		var FieldArray = new Array()
		
		/* array with fields when person 1 is checked */
		if (($F('p1_geslacht_m')) || ($F('p1_geslacht_v'))) {
			FieldArray[0]="p1_achternaam"
			FieldArray[1]="p1_voorletters"
			FieldArray[2]="p1_geboortedatum"
			FieldArray[3]="p1_adres"
			FieldArray[4]="p1_postcode"
			FieldArray[5]="p1_woonplaats"
			FieldArray[6]="p1_land"
			FieldArray[7]="p1_email"
			FieldArray[8]="p1_telefoon"
		} 
		
		if (($F('p2_geslacht_m')) || ($F('p2_geslacht_v'))) {
			FieldArray[9]="p2_achternaam"
			FieldArray[10]="p2_voorletters"
			FieldArray[11]="p2_geboortedatum"
			FieldArray[12]="p2_adres"
			FieldArray[13]="p2_postcode"
			FieldArray[14]="p2_woonplaats"
			FieldArray[15]="p2_land"
			FieldArray[16]="p2_email"
			FieldArray[17]="p2_telefoon"
		}
		
		/* Walkthru Array of formfields and check value */
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});
  		
  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			document.persoonsgegevens.submit();
		}
}



/* check form velden stap 2*/

function checkStep3(p1,p2) {

		var goodToGo = "yes";
		
		if ($('p1_opgave_via').value == ""){
		HiLite($('p1_opgave_via'));
		goodToGo = "no";}
		
		if ($('p2_opgave_via').value == ""){
		HiLite($('p2_opgave_via'));
		goodToGo = "no";}
		
		var FieldArray = new Array()
		
		/* array with fields when person 1 is checked */
		if (p1) {
			FieldArray[0]="p1_inkomen"
		} 
		
		if (p2) {
			FieldArray[1]="p2_inkomen"
		}
		
		/* Walkthru Array of formfields and check value */
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});
  		
  		
  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			/* Get the value of the type opgave to find out wich step to do next, 3a_1 or 4 */
			if (($('p1_opgave_via').value == "jaaropgave") && ($('p2_opgave_via').value == "salarisspecificatie")) {
				$('inkomen').action = 'index.php?action=step3a_2';
			} else if ($('p1_opgave_via').value == "salarisspecificatie") {
				$('inkomen').action = 'index.php?action=step3a_1';
			} else {
				$('inkomen').action = 'index.php?action=step4';
			}
			document.inkomen.submit();
		}
}




/* check form velden stap 3a*/

function checkStep3a(sequence,zelfstandig) {

		var goodToGo = "yes";
		var FieldArray = new Array()

		FieldArray[0]="inkomen_dienst"

		
		/* Walkthru Array of formfields and check value */
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});
  		
  		
  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			/* Get the value of the type opgave to find out wich step to do next, 3a_1 or 4 */
			if (zelfstandig == "1") {
				$('inkomenspecs').action = 'index.php?action=step3b_'+ sequence;
			} else {
				$('inkomenspecs').action = 'index.php?action=step4';
			}
			document.inkomenspecs.submit();
		}
}


/* check form velden stap 3b*/

function checkStep3b(sequence) {

		var goodToGo = "yes";
		var FieldArray = new Array()

		FieldArray[0]="inkomen_winst"

		
		/* Walkthru Array of formfields and check value */
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});
  		
  		
  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			/* Get the value of the type opgave to find out wich step to do next, 3a_1 or 4 */
			if (sequence == "1") {
				$('inkomen_zelfstandig_specs').action = 'index.php?action=step3a_2';
			} else {
				$('inkomen_zelfstandig_specs').action = 'index.php?action=step4';
			}
			document.inkomen_zelfstandig_specs.submit();
		}
}



/* check form velden stap 4a*/

function checkStep4a(p1,p2) {

		var goodToGo = "yes";
		var FieldArray = new Array()
		
		/* array with fields when person 1 is checked */
		if (p1) {
			FieldArray[0]="p1_lasten_zorgverzekering"
		} 
		
		if (p2) {
			FieldArray[1]="p2_lasten_zorgverzekering"
		}
		
		/* Walkthru Array of formfields and check value */
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});

  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			document.lasten_a.submit();
		}
}


/* check form velden stap 4b*/

function checkStep4b(p1,p2) {

		var goodToGo = "yes";
		var FieldArray = new Array()
		
		/* array with fields when person 1 is checked */
		if (p1) {
			//FieldArray[0]=""
		} 
		
		if (p2) {
			//FieldArray[1]=""
		}
		
		/* Walkthru Array of formfields and check value */
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});

  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			document.lasten_b.submit();
		}
}



/* check form velden stap 5*/

function checkStep5() {

		var goodToGo = "yes";
		var FieldArray = new Array()

		FieldArray[0]="kind1_naam"
		FieldArray[1]="kind1_geboortedatum"

		
		/* Walkthru Array of formfields and check value */
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});
  		
  		
  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			document.kinderen_a.submit();
		}
}


/* check form velden stap 5b*/

function checkStep5b() {

		var goodToGo = "yes";
		/*
		//var FieldArray = new Array()

		FieldArray[0]="p1_verblijf"
		FieldArray[1]="p2_verblijf"
		* /

		
		/* Walkthru Array of formfields and check value */
		
		/*
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});
  		
  		*/
  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			document.kinderen_b.submit();
		}
}


/* check form velden stap 5c*/

function checkStep5c() {

		var goodToGo = "yes";
		/*
		//var FieldArray = new Array()

		FieldArray[0]="p1_verblijf"
		FieldArray[1]="p2_verblijf"
		* /

		
		/* Walkthru Array of formfields and check value */
		
		/*
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});
  		
  		*/
  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			/* Timeout added because otherwise problems with ajaxrequests & submitting form */
			setTimeout("document.kinderen_c.submit();", 1000); 
		}
}


/* check form velden stap 5c*/

function checkStep6() {

		var goodToGo = "yes";
		/*
		//var FieldArray = new Array()

		FieldArray[0]="p1_verblijf"
		FieldArray[1]="p2_verblijf"
		* /

		
		/* Walkthru Array of formfields and check value */
		
		/*
		FieldArray.each(function(i) {
			
			if ($F(i) == '') {
		 		HiLite(i);
		 		goodToGo = "no";
		 		}
			
  		});
  		
  		*/
  		
		if (goodToGo == "no") {
			alert("Niet alle velden zijn juist ingevuld, controleer de velden welke rood zijn gemarkeerd.");
		} 
		else 
		{
			/* Timeout added because otherwise problems with ajaxrequests & submitting form */
			document.gezin.submit();
		}
}

