// Only script specific to this form goes here.
// General-purpose routines are in a separate file.
  function validateOnSubmit() {
    var elem;
    var errs=0;
    // execute all element validations in reverse order, so focus gets
    // set to the first one in error.
    if (!validateAge(document.forms.reg.txt_age,  'inf_age', true)) errs += 1; 
    if (!validatePresent(document.forms.reg.txt_age,  'inf_age')) errs += 2; 
    if (!validatePresent(document.forms.reg.txt_age,  'inf_age')) errs += 2; 
    if (!validatePresent(document.forms.reg.txt_country,  'inf_country')) errs += 2; 
    if (!validateEmail(document.forms.reg.txt_email,  'inf_email', true)) errs += 2; 
    if (!validatePresent(document.forms.reg.txt_email,  'inf_email')) errs += 2; 
    if (!validatePresent(document.forms.reg.txt_lastname,  'inf_lastname')) errs += 2; 
    if (!validatePresent(document.forms.reg.txt_firstname,  'inf_firstname')) errs += 2; 

	if ((errs<2) && (document.forms.reg.txt_age.value == '12')){
		window.location.href="error_a.html"; 
		return false;
	} else	if (errs>2) {
		alert('There are fields which need correction before sending.');
	} else if (errs==2) {
		alert('There is a field which needs correction before sending.');
	}		
    return (errs==0);
  };
 
 
 
 
