function ValidateForm()
{
	
	if (MM_findObj("firstName").value == "") {
		alert("Veuillez entrer votre prénom.");
		MM_findObj("firstName").focus();
		return false;
	}
	if (MM_findObj("lastName").value == "") {
		alert("Veuillez entrer votre nom de famille.");
		MM_findObj("lastName").focus();
		return false;
	}
	if (MM_findObj("address").value == "") {
		alert("Veuillez entrer votre adresse.");
		MM_findObj("address").focus();
		return false;
	}
	if (MM_findObj("city").value == "") {
		alert("Veuillez entrer la ville où vous habitez.");
		MM_findObj("city").focus();
		return false;
	}
	if (MM_findObj("provinceState").selectedIndex == 0) {
		alert("Veuillez entrer la province ou l'état où vous habitez.");
		MM_findObj("provinceState").focus();
		return false;
	}
	if (MM_findObj("provinceState").selectedIndex == 14 && MM_findObj("otherProvinceState").value == "") {
		alert("Veuillez entrer la province ou l'état où vous habitez.");
		MM_findObj("otherProvinceState").focus();
		return false;
	}
	if (MM_findObj("country").selectedIndex == 0) {
		alert("Veuillez entrer le pays où vous habitez.");
		MM_findObj("country").focus();
		return false;
	}
	if (MM_findObj("postalCode").value == "" && MM_findObj("postalCodeContinued").value == "") {
		alert("Veuillez entrer votre code postale.");
		MM_findObj("postalCode").focus();
		return false;
	}
	if (MM_findObj("telephone").value == "") {
		alert("Veuillez entrer votre numéro de téléphone.");
		MM_findObj("telephone").focus();
		return false;
	}
	if (MM_findObj("email").value == "") {
		alert("Veuillez entrer votre Courriel.");
		MM_findObj("email").focus();
		return false;
	}

	if (MM_findObj("gender")[0].checked == false && MM_findObj("gender")[1].checked == false) {
		alert("Veuillez indiquer votre sexe.");
		MM_findObj("gender")[0].focus();
		return false;
	}

	if (MM_findObj("appliedToOCT")[0].checked == false && MM_findObj("appliedToOCT")[1].checked == false) {
		alert("Veuillez indiquer si vous avez fait votre demande d'inscription à l'Ordre des enseignantes et des enseignants de l'Ontario en vue d'obtenir votre carte de compétence.");
		MM_findObj("appliedToOCT")[0].focus();
		return false;
	}
	if (MM_findObj("appliedToOCT")[0].checked == true && MM_findObj("specifyRegistrationNumber").value == "") {
		alert("Veuillez indiquer votre numéro de membre.");
		MM_findObj("specifyRegistrationNumber").focus();
		return false;
	}

	if (MM_findObj("certifiedInOntario")[0].checked == false && MM_findObj("certifiedInOntario")[1].checked == false) {
		alert("Veuillez indiquer si vous êtes certifié(e) pour enseigner en Ontario.");
		MM_findObj("certifiedInOntario")[0].focus();
		return false;
	}
	if (MM_findObj("certifiedInOntario")[1].checked == true && MM_findObj("reasonNotCertified").selectedIndex == 0) {
		alert("Veuillez préciser la raison.");
		MM_findObj("reasonNotCertified").focus();
		return false;
	}
	if (MM_findObj("certifiedInOntario")[1].checked == true && MM_findObj("reasonNotCertified").selectedIndex == 5 && MM_findObj("otherReasonNotCertified").value == "") {
		alert("Veuillez préciser la raison.");
		MM_findObj("otherReasonNotCertified").focus();
		return false;
	}

	if (MM_findObj("countryOfProfessionalTeacherEducation").value == "") {
		alert("Veuillez indiquer dans quel pays vous avez suivi votre formation à l'enseignement.");
		MM_findObj("countryOfProfessionalTeacherEducation").focus();
		return false;
	}
	if (MM_findObj("languageOfProfessionalTeacherEducation").value == "") {
		alert("Veuillez indiquer dans quelle langue vous avez suivi votre formation à l'enseignement.");
		MM_findObj("languageOfProfessionalTeacherEducation").focus();
		return false;
	}
	if (MM_findObj("countryOfPostSecondaryAcademicQualifications").value == "") {
		alert("Veuillez indiquer dans quel pays vous avez obtenu vos diplômes postsecondaires.");
		MM_findObj("countryOfPostSecondaryAcademicQualifications").focus();
		return false;
	}

	if (MM_findObj("jkQualified").checked == false &&
		MM_findObj("kQualified").checked == false &&
		MM_findObj("1Qualified").checked == false &&
		MM_findObj("2Qualified").checked == false &&
		MM_findObj("3Qualified").checked == false &&
		MM_findObj("4Qualified").checked == false &&
		MM_findObj("5Qualified").checked == false &&
		MM_findObj("6Qualified").checked == false &&
		MM_findObj("7Qualified").checked == false &&
		MM_findObj("8Qualified").checked == false &&
		MM_findObj("9Qualified").checked == false &&
		MM_findObj("10Qualified").checked == false &&
		MM_findObj("11Qualified").checked == false &&
		MM_findObj("12Qualified").checked == false ) {
		alert("Veuillez indiquer quelle année d'études votre formation à l'enseignement vous a préparé(e) à enseigner.");
		MM_findObj("jkQualified").focus();
		return false;
	}

	/*optional
	if ((MM_findObj("7Qualified").checked == true ||
		MM_findObj("8Qualified").checked == true ||
		MM_findObj("9Qualified").checked == true ||
		MM_findObj("10Qualified").checked == true) &&
		MM_findObj("preparedToTeachIntermediate")[0].checked == false && MM_findObj("preparedToTeachIntermediate")[1].checked == false) {
		alert("Veuillez indiquer si votre méthodologie d'enseignement vous a préparé(e) à enseigner au moins une matière du curriculum au cycle intermédiaire.");
		MM_findObj("preparedToTeachIntermediate")[0].focus();
		return false;
	}
	if (MM_findObj("preparedToTeachIntermediate")[0].checked == true && MM_findObj("whichIntermediateSubjects").value == "") {
		alert("Veuillez indiquer les matières.");
		MM_findObj("whichIntermediateSubjects").focus();
		return false;
	}

	if ((MM_findObj("11Qualified").checked == true ||
		MM_findObj("12Qualified").checked == true) &&
		MM_findObj("preparedToTeachSenior")[0].checked == false && MM_findObj("preparedToTeachSenior")[1].checked == false) {
		alert("Veuillez indiquer si votre formation à l'enseignement vous a préparé(e) à enseigner deux matières aux cycles supérieur.");
		MM_findObj("preparedToTeachSenior")[0].focus();
		return false;
	}
	if (MM_findObj("preparedToTeachSenior")[0].checked == true && MM_findObj("whichSeniorSubjects").value == "") {
		alert("Veuillez indiquer les matières.");
		MM_findObj("whichSeniorSubjects").focus();
		return false;
	}
	*/

	if (MM_findObj("certifiedToTeach")[0].checked == false && MM_findObj("certifiedToTeach")[1].checked == false) {
		alert("Please indicate if you have been certified to teach in another jurisdiction in any of these areas.");
		MM_findObj("certifiedToTeach")[0].focus();
		return false;
	}
	if (MM_findObj("certifiedToTeach")[0].checked == true && 
		MM_findObj("certifiedToTeachFrenchElementary").checked == false &&
		MM_findObj("certifiedToTeachFrenchSecondary").checked == false &&
		MM_findObj("certifiedToTeachMathSecondary").checked == false &&
		MM_findObj("certifiedToTeachChemistrySecondary").checked == false &&
		MM_findObj("certifiedToTeachPhysicsSecondary").checked == false &&
		MM_findObj("certifiedToTeachTechStudiesSecondary").checked == false &&
		MM_findObj("certifiedToTeachComputersSecondary").checked == false) {
		alert("Please indicate what area.");
		MM_findObj("certifiedToTeachFrenchElementary").focus();
		return false;
	}

	if (MM_findObj("supportOption1")[0].checked == false && MM_findObj("supportOption1")[1].checked == false) {
		alert("Veuillez s'il vous plaît indiquer si chacun des quatre services vous intéresse.");
		MM_findObj("supportOption1")[0].focus();
		return false;
	}
	if (MM_findObj("supportOption2")[0].checked == false && MM_findObj("supportOption2")[1].checked == false) {
		alert("Veuillez s'il vous plaît indiquer si chacun des quatre services vous intéresse.");
		MM_findObj("supportOption2")[0].focus();
		return false;
	}
	if (MM_findObj("supportOption3")[0].checked == false && MM_findObj("supportOption3")[1].checked == false) {
		alert("Veuillez s'il vous plaît indiquer si chacun des quatre services vous intéresse.");
		MM_findObj("supportOption3")[0].focus();
		return false;
	}
	if (MM_findObj("supportOption4")[0].checked == false && MM_findObj("supportOption4")[1].checked == false) {
		alert("Veuillez s'il vous plaît indiquer si chacun des quatre services vous intéresse.");
		MM_findObj("supportOption4")[0].focus();
		return false;
	}
	if (MM_findObj("supportOption1")[1].checked == true && 
		MM_findObj("supportOption2")[1].checked == true && 
		MM_findObj("supportOption3")[1].checked == true && 
		MM_findObj("supportOption4")[1].checked == true) {
		alert("Vous devriez choisir un minimum d'un service, en sélectionnant \"oui\".");
		MM_findObj("supportOption1")[0].focus();
		return false;
	}

	if (MM_findObj("consentCheck").checked == false) {
		alert("Vous devez consentir à ce que vos renseignements personnels soient recueillis, utilisés, divulgués et échangés.");
		MM_findObj("consentCheck").focus();
		return false;
	}

	return true;
}	


function validateAndSubmit() {

	errorMessage = '';

	// Check form validation here. Simply add to the variable ERRORMESSAGE a listing of all 
	// fields that are incomplete. E.g.
	//
	// 	if (document.applicatioForm.lastName.value == '') errorMessage = errorMessage + "You haven't specified LAST NAME.";
	//
	// All questions on this form are mandatory except email address. That means that anywhere 
	// there's a group of radio buttons, one must be selected, and anywhere there's a group of
	// checkboxes, AT LEAST one must be selected. It's important that none of these are selected
	// by default when the page loads, since users might simply ignore it and then there'd be
	// bad data in the system.
	//
	// Also note that the "I Consent" checkbox at the bottom of the page MUST be checked for
	// the form to be submitted. If the checkbox isn't checked, add to the error message something
	// like "You haven't clicked the CONSENT checkbox."

	if (errorMessage != '') {
		alert(errorMessage);
		return false;
	}
	else {

		// Add code here which submits the form and emails the contents to one of
		// three email addresses based on the following logic:
		//
		// - If the postal code begins with a K, submit to ws@ottawa-worldskills.org
		// - Otherwise, submit at random to one of these two email addresses:
		//   info@teachinontario.ca or sfc@skillsforchange.org 
		//
		// I've written the randomization function below to simply pop up a dialog
		// box showing where the email would go. Feel free to adapt it. The important
		// thing is that the two addresses being randomized each get about 50% of the
		// email from this form.

		if (document.applicationForm.postalCode.value.substring(0,1) == "K" || document.applicationForm.postalCode.value.substring(0,1) == "k") {
			alert("This form would be sent to ws@ottawa-worldskills.org");
			return true;
		}
		else {

			var randomNumber = parseInt(Math.random() * 10);
			if (randomNumber < 5) {
				alert("This form would be sent to info@teachinontario.ca");
				return true;
			}
			else {
				alert("This form would be sent to sfc@skillsforchange.org");
				return true;
			}

		}

	}

	return false;

}
