function uncheck(name1, name2) {
 if(name1.checked) {
  name2.checked = false;
 } else {
  name2.checked = true;
 }
}

function checkbox_toggle(chbx, hiddenfield, aan_value, uit_value) {
 //hiddenfield = "document.frm_refund."+hidden_name;
 //window.alert(hiddenfield);
 
 checkbox = document.getElementById(chbx);
 hiddenfield = document.getElementById(hiddenfield);
 
 if (checkbox.checked) {
  hiddenfield.value = aan_value;
 } else {
  hiddenfield.value = uit_value;
 }
}

function CheckNumber(checkString) {
	newString = "";
	count = 0;
	
	for (i = 0; i < checkString.length; i++) {
		ch = checkString.substring(i, i+1);
		if ((ch >= "0" && ch <= "9") || (ch == ".") || (ch == ",")) {
			newString += ch;
		}
	}
	if (checkString != newString) {
		res = false; 
	} else {
		res = true;
	}
	
	if (checkString.length ==0) {
		res = false; 
	}
return res
}

function CheckEmail(address) {
return address.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.int)|(\.gov)|(\.org)|(\.biz)|(\.info)|(\..{2,2}))$)\b/gi);
}

function daysInFebruary(year) {
	return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

function CheckDate(name) {
var daysInMonth = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);

el_month = eval("document.frm_refund."+name+"Month")
el_day = eval("document.frm_refund."+name+"Day")
el_year = eval("document.frm_refund."+name+"Year")
	
	if (el_day.value == '-1') return false;
	if (el_month.value == '-1') return false;
	if (el_year.value == '-1') return false;    

month = el_month.options[el_month.selectedIndex].value;
day = el_day.options[el_day.selectedIndex].value;
year = el_year.options[el_year.selectedIndex].value;

// Explicitly change type to integer to make code work in both
// JavaScript 1.1 and JavaScript 1.2.
var intYear = parseInt(year);
var intMonth = parseInt(month);
var intDay = parseInt(day);

// catch invalid days, except for February
if ((intMonth != 2) && (intDay > daysInMonth[intMonth])) return false;

if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;

return true;
}

function CheckForm(theForm) {

			   result=true;

			   if (theForm.geslacht[0].checked == false && theForm.geslacht[1].checked == false ) {
				   window.alert("U moet hier een keuze maken: 'geslacht'");
				   result=false;
			   } 
			   else if (theForm.voornaam.value == "") {
				 	window.alert("Dit veld mag niet leeg zijn: 'voornaam'");
				 	theForm.voornaam.focus();
				 	result=false;
			   } 
			   
			   else if (theForm.achternaam.value == "") {
				 	window.alert("Dit veld mag niet leeg zijn: 'achternaam'");
				 	theForm.achternaam.focus();
				 	result=false;
			   } 
			   else if (theForm.email.value == "") {
					  window.alert("U dient een e-mail adres in te vullen");
					  theForm.email.focus();
					  result=false;
					} else if (theForm.email.value!="" && !CheckEmail(theForm.email.value)) {
					  window.alert("Dit e-mail adres is niet geldig!");
					  theForm.email.focus();
					  result=false;
					}  
			   
			   else if (theForm.email.value == "") {
				 	window.alert("Dit veld mag niet leeg zijn: 'email'");
				 	theForm.email.focus();
				 	result=false;
			   }
			   
			   else if (theForm.bankgiro.value == "") {
				 	window.alert("Dit veld mag niet leeg zijn: 'Bank/Giro rekening'");
				 	theForm.bankgiro.focus();
				 	result=false;
			   }	   

			   else if (theForm.straat.value == "") {
				 	window.alert("Dit veld mag niet leeg zijn: 'Straatnaam'");
				 	theForm.straat.focus();
				 	result=false;
			   }
			   
			   else if (theForm.huisnummer.value == "") {
				 	window.alert("Dit veld mag niet leeg zijn: 'Huisnummer'");
				 	theForm.huisnummer.focus();
				 	result=false;
			   }
			   
			   else if (theForm.woonplaats.value == "") {
				 	window.alert("Dit veld mag niet leeg zijn: 'Woonplaats'");
				 	theForm.woonplaats.focus();
				 	result=false;
			   }
			   
			   else if(theForm.dummy__akkoord.checked == false ) {
					window.alert("U moet akkoord gaan met de deelname voorwaarden");
				 	result=false;
				}
				
	if(result) {
		if(theForm.geslacht[0].checked) {
			g='Man';
		} else {
			g='Vrouw';
		}		

		pageTracker._trackPageview('/print/kortingsbon');
		
		document.getElementById('redirect').value = 'http://www.minderzout.nl/korting-print.php?g='+g+'&voornaam='+theForm.voornaam.value+'&achternaam='+theForm.achternaam.value+'&tussenvoegsel='+theForm.tussenvoegsel.value+'&email='+theForm.email.value+'&bankgiro='+theForm.bankgiro.value+'&woonplaats='+theForm.woonplaats.value+'&straat='+theForm.straat.value+'&huisnummer='+theForm.huisnummer.value;
		
		theForm.submit();
	}
	
}

