var formatEmail =/^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
var formatCodePostal =/[a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d/;

function validate_cyber(){

//var formatEmail =/^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9.-]{2,4}$/;


if (document.cyber.courriel.value == "") {
	alert("Please enter your email address");
	document.cyber.courriel.focus();
	return;
}
if (! formatEmail.test(document.cyber.courriel.value)){
	alert("Please correct your email address, \nvalid format should look like this : user@company.com");
	document.cyber.courriel.focus();
	return;
}
document.cyber.submit();
}

function validate_courriel(){

//var formatEmail =/^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

if (document.theForm.courriel.value == "") {
	alert("Please enter your email address");
	document.theForm.courriel.focus();
	return(false);
}
if (! formatEmail.test(document.theForm.courriel.value)){
	alert("Please correct your email address, \nvalid format should look like this : user@company.com");
	document.theForm.courriel.focus();
	return(false);
}
return(true);
}

function validate_courriel_lachez(){

//var formatEmail =/^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

if (document.theForm.courriel.value == "") {
	alert("Please enter your email address");
	document.theForm.courriel.focus();
	return(false);
}
if (! formatEmail.test(document.theForm.courriel.value)){
	alert("Please correct your email address, \nvalid format should look like this : user@company.com");
	document.theForm.courriel.focus();
	return(false);
}
return(true);
}

function validate_FullCyberForm(){

//var formatEmail =/^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

if (document.theForm.courriel.value == "") {
	alert("Please enter your email address");
	document.theForm.courriel.focus();
	return(false);
}
if (document.theForm.genre[0].checked == false && document.theForm.genre[1].checked == false) {
	alert("Please check Mr or Ms/Miss");
	return(false);
}
if (document.theForm.prenom.value == "") {
	alert("Please enter your first name");
	document.theForm.prenom.focus();
	return(false);
}
if (document.theForm.nom.value == "") {
	alert("Please enter your last name");
	document.theForm.nom.focus();
	return(false);
}
if (document.theForm.occupation.value == "") {
	alert("Please enter your occupation");
	document.theForm.occupation.focus();
	return(false);
}
if (document.theForm.age.value == "") {
	alert("Please enter your age");
	document.theForm.age.focus();
	return(false);
}
if (document.theForm.pays[0].checked == false && document.theForm.pays[1].checked == false) {
	alert("Please check a country");
	return(false);
}
if ((document.theForm.codePostal.value == "") && (document.theForm.pays[0].checked == true)) {
	alert("Please enter your postal code");
	document.theForm.codePostal.focus();
	return(false);
}
if (! formatEmail.test(document.theForm.courriel.value)){
	alert("Please correct your email address, \nvalid format should look like this : user@company.com");
	document.theForm.courriel.focus();
	return(false);
}
if (document.theForm.pays[0].checked == true ){
	if (! formatCodePostal.test(document.theForm.codePostal.value)){
		alert("Please correct your postal code, \nvalid format should look like this : A1A 1A1");
		document.theForm.codePostal.focus();
		return(false);
	}
}
return(true);
}
function validate_titans(){

//var formatEmail =/^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

if (document.titans.innovation.value == "") {
	alert("You have to choose an innovation!");
	document.titans.innovation.focus();
	return(false);
}
if (document.titans.pourquoi.value == "") {
	alert("Please give us a reason \nwhy you think this innovation \nis the most useful to our society \nor to the planet.");
	document.titans.pourquoi.focus();
	return(false);
}
if (document.titans.genre.value == "") {
	alert("You have to tell us if you're a boy or a girl");
	document.titans.genre.focus();
	return(false);
}
if (document.titans.prenom.value == "") {
	alert("You have to type your first name");
	document.titans.prenom.focus();
	return(false);
}
if (document.titans.nom.value == "") {
	alert("You have to type your name");
	document.titans.nom.focus();
	return(false);
}
if (document.titans.adresse.value == "") {
	alert("You have to type your address");
	document.titans.adresse.focus();
	return(false);
}
if (document.titans.ville.value == "") {
	alert("You have to type your city");
	document.titans.ville.focus();
	return(false);
}

if (! formatCodePostal.test(document.titans.codepostal.value)){
	alert("Please correct your postal code, the right way is: A1A 1A1");
	document.titans.codepostal.focus();
	return(false);
}

if (! formatEmail.test(document.titans.courriel.value)){
	alert("Please correct your email address, \nthe right way is: user@example.com");
	document.titans.courriel.focus();
	return(false);
}

if (document.titans.telephone.value == "") {
	alert("You have to type your telephone number");
	document.titans.telephone.focus();
	return(false);
}

if (document.titans.age.value == "") {
	alert("You have to tell us your age group");
	document.titans.age.focus();
	return(false);
}

return(true);
}

function validate_lachez(){

//var formatEmail =/^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
/*
var cumul;
cumul = 0;
if (document.lachez.enonces(0).checked)
	cumul += 1;
if (document.lachez.enonces(1).checked)
	cumul += 1;
if (document.lachez.enonces(2).checked)
	cumul += 1;
if (document.lachez.enonces(3).checked)
	cumul += 1;
if (cumul != 2){
	alert("Please choose 2 false statements.");
	return(false);
}*/


if ( ( document.lachez.enonces[0].checked == false )
    && ( document.lachez.enonces[1].checked == false )
	&& ( document.lachez.enonces[2].checked == false )
	&& ( document.lachez.enonces[3].checked == false ))
    {
        alert ( "Please indicate which statement is true." );
        valid = false;
		return(false);
    }

if (document.lachez.enonces.value == "") {
	alert("Please indicate which statement is true.");
	document.lachez.enonces.focus();
	return(false);
}

if (document.lachez.genre.value == "") {
	alert("You have to tell us \nif you're a boy or a girl");
	document.lachez.genre.focus();
	return(false);
}
if (document.lachez.prenom.value == "") {
	alert("You have to type your first name.");
	document.lachez.prenom.focus();
	return(false);
}
if (document.lachez.nom.value == "") {
	alert("You have to type your last name.");
	document.lachez.nom.focus();
	return(false);
}
if (document.lachez.adresse.value == "") {
	alert("You have to type your address.");
	document.lachez.adresse.focus();
	return(false);
}
if (document.lachez.ville.value == "") {
	alert("You have to type your city.");
	document.lachez.ville.focus();
	return(false);
}
if (! formatCodePostal.test(document.lachez.codepostal.value)){
	alert("Please correct your postal code, the right way is: A1A 1A1");
	document.lachez.codepostal.focus();
	return(false);
}

if (! formatEmail.test(document.lachez.courriel.value)){
	alert("Please correct your email address, \nthe right way is: user@example.com");
	document.lachez.courriel.focus();
	return(false);
}

if (document.lachez.telephone.value == "") {
	alert("Please type your telephone number.");
	document.lachez.telephone.focus();
	return(false);
}

if (document.lachez.age.value == "") {
	alert("You have to tell us your age group.");
	document.lachez.age.focus();
	return(false);
}

return(true);
}

