 function validateEmail(entered) {

     apos=entered.indexOf("@");
     dotpos=entered.lastIndexOf(".");
     lastpos=entered.length-1;
     if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
          return false;
     } else {
          return true;
     }
}function validateNumber(x) {

     var anum=/(^\d+$)|(^\d+\.\d+$)/;

     if (anum.test(x)){

          return true;

     } else {

          return false;

     }

}// Declaring required variables

var digits = "0123456789";

// non-digit characters which are allowed in phone numbers

var phoneNumberDelimiters = "()- ";

// characters which are allowed in international phone numbers

// (a leading + is OK)

var validWorldPhoneChars = phoneNumberDelimiters + "+";

// Minimum no of digits in an international phone no.

var minDigitsInIPhoneNumber = 10;function isInteger(s) {   

     var i;

     for (i = 0; i < s.length; i++) {

          // Check that current character is number.

          var c = s.charAt(i);

          if (((c < "0") || (c > "9"))) return false; 

     }

     // All characters are numbers.

     return true;

}function stripCharsInBag(s, bag) {

     var i;

     var returnString = "";

     // Search through string's characters one by one.

     // If character is not in bag, append to returnString.

     for (i = 0; i < s.length; i++) {

          // Check that current character isn't whitespace.

          var c = s.charAt(i);

          if (bag.indexOf(c) == -1) returnString += c;

     }

     return returnString;

}function checkInternationalPhone(strPhone){

     s=stripCharsInBag(strPhone,validWorldPhoneChars);

     return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);

}
/*
function check(){var formElements = document.form.elements;for (i=0; i max)

      {

      champ.value = champ.value.substring(0,max);

      if (langue == "_ang")

         alert("Your message has exceeded the maximum length for sending a page and has been automatically truncated to "+max+" characters.");

      else

         alert("Votre message dépasse le nombre de caractères permis et a été réduit à "+max+" caractères."); 

      }

   }

   

   

 */  
function checkFC1(){
	if(document.form.txtNom.value != "" && document.form.txtCourriel.value != "" && document.form.txtTelephone.value != "" && document.form.txtCommentaires.value != "") {
		// alors on envoie le formulaire
		//alert("Votre message a \351t\351 envoy\351.");
   		document.form.submit();
		//window.location='pournousjoindre.php';
		//windows.close();
	}else {
		// sinon on affiche un message
		alert("Assurez-vous d'avoir rempli tout les champs.");
	}
}

function  validateEmailpop(){

if(!validateEmail(document.form.txtCourriel.value) ){

alert("L'adresse courriel est incorrect.")

}

}
function  validateTELpop(){

	if(!checkInternationalPhone(document.form.txtTelephone.value) ){

	alert("Le num\351ro de t\351l\351phone est invalide.")

}

}
/*VERSION ENGLISH*/
   		function checkFC2(){
		if(document.form.txtNom.value != "" & document.form.txtCourriel.value != "" & document.form.txtTelephone.value != "" & document.form.txtCommentaires.value != "") {

			 // alors on envoie le formulaire

   			 document.form.submit();

   			 //window.location='popemail-1.php';

   			 alert("Your message have been send.");

//windows.close();

  		}else {

   			 // sinon on affiche un message

   			 alert("Make sure you have filled in all fields.");

  			}

		}
function  validateEmailpop2(){

if(!validateEmail(document.form.txtCourriel.value) ){

alert("The email address is incorrect.")

}

}

function  validateEmailSoumission(){
if(!validateEmail(document.formAnnul.email.value) ){
alert("L'adresse courriel est invalide.")
}
}

function checkFCSoumission(){
		if(document.formAnnul.email.value != "" ) {

document.formAnnul.submit();
 window.location='index.php';
alert("Votre demande d'annulation aux bulletins d'information a \351t\351 envoy\351 avec succ\350s. Merci!");
}else {
alert("Assurez-vous d'avoir rempli tout les champs obligatoires.");
}
}function checkFCSoumissionEn(){
		if(document.formAnnul.email.value != "" ) {

document.formAnnul.submit();
 window.location='index.php';
alert("Your request to cancel your registration to the newsletter was sent successfully. Thank you!");
}else {
alert("Please verify that all the field content informations.");
}
}

function  validateEmailSoumissionEn(){
if(!validateEmail(document.formAnnul.email.value) ){
alert("The email address is incorrect.")
}
}
function checkFCbulletin(){
if(document.formBulletin.email.value != "" & validateEmail(document.formBulletin.email.value) ) {
document.formBulletin.submit();
 window.location='index.php';
alert("Votre demande d'inscription aux bulletins d'information a \351t\351 envoy\351 avec succ\350s. Merci!");
}else {
alert("Assurez-vous d'avoir entr\351 une adresse \351lectronique valide.");
}
}

function checkFCbulletinEn(){
if(document.formBulletin.email.value != "" & validateEmail(document.formBulletin.email.value) ) {
document.formBulletin.submit();
 window.location='index.php';
alert("Your registration to the newsletter was sent successfully. Thank you!");
}else {
alert("Please verify that the email addresse you've entered is valid.");
}
}
function  validateTELpop2(){

	if(!checkInternationalPhone(document.form.txtTelephone.value) ){

	alert("The telephone number is incorrect.")

}

}/*VERSION ENGLISH*/
   		function checkFC3(){
		if(document.formSoumission.Nom.value != "" & document.formSoumission.email.value != "" & document.formSoumission.TypeEnt.value != "" & document.formSoumission.questions.value != "" & document.formSoumission.Tel.value != "" & document.formSoumission.Prenom.value != ""  & validation(document.formSoumission.email.value) & checkInternationalPhone(document.formSoumission.Tel.value)  ) {
			 // alors on envoie le formulaire
   			 document.formSoumission.submit();
		 //window.location='popemail-1.php';
   			 alert("Votre message à été envoyé.");
//windows.close();
  		}else {
   			 // sinon on affiche un message
   			 alert("Assurez-vous d'avoir rempli tous les champs correctement.");
  			}
		}

function  validateEmailpop2(){
if(!validateEmail(document.form.email.value) ){
alert("L'adresse courriel est incorecte.")
}
}


/*VALIDATION CONCOURS*/

function checkFConcours(){
	
	if (document.formconcours.txtReponse.value=="") {
            alert("Veuillez répondre à la question.")
            document.formconcours.txtReponse.focus()
        return false }
	
	if (document.formconcours.txtEntreprise.value=="") {
            alert("Veuillez remplir le champ Entrepise.")
            document.formconcours.txtEntreprise.focus()
        return false }	
	
	if (document.formconcours.txtNom.value=="") {
            alert("Veuillez remplir le champ Nom.")
            document.formconcours.txtNom.focus()
        return false }	

	if (document.formconcours.txtPrenom.value=="") {
            alert("Veuillez remplir le champ Prénom.")
            document.formconcours.txtPrenom.focus()
        return false }	
		
	if (document.formconcours.txtRole.value=="") {
            alert("Veuillez remplir le champ Rôle.")
            document.formconcours.txtRole.focus()
        return false }		

	if (document.formconcours.txtChamps.value=="") {
            alert("Veuillez remplir le champ Champs d'activité.")
            document.formconcours.txtChamps.focus()
        return false }	
	
	
	if (isNaN(document.formconcours.txtTel1.value)) {
            alert("Veuillez remplir le champ Téléphone avec des caractères numériques seulement.")
            document.formconcours.txtTel1.focus()
        return false }
		
	if (isNaN(document.formconcours.txtTel2.value)) {
            alert("Veuillez remplir le champ Téléphone avec des caractères numériques seulement.")
            document.formconcours.txtTel2.focus()
        return false }	
		
	if (isNaN(document.formconcours.txtTel3.value)) {
            alert("Veuillez remplir le champ Téléphone avec des caractères numériques seulement.")
            document.formconcours.txtTel3.focus()
        return false }		
		
	if (isNaN(document.formconcours.txtTel4.value)) {
            alert("Veuillez remplir le champ Téléphone avec des caractères numériques seulement.")
            document.formconcours.txtTel4.focus()
        return false }		
	
 if(!validateEmail(document.formconcours.txtCourriel.value)  ) {		 
				alert("Assurez-vous d'avoir rempli une adresse électronique valide. Merci.");
				document.formconcours.txtCourriel.focus()
				return false;
			}	
if(document.formconcours.txtAmis1.value!=""){
 if(!validateEmail(document.formconcours.txtAmis1.value)  ) {		 
				alert("Assurez-vous d'avoir rempli une adresse électronique valide. Merci.");
				document.formconcours.txtAmis1.focus()
				return false;
			}
}
if(document.formconcours.txtAmis2.value!=""){
 if(!validateEmail(document.formconcours.txtAmis2.value)  ) {		 
				alert("Assurez-vous d'avoir rempli une adresse électronique valide. Merci.");
				document.formconcours.txtAmis2.focus()
				return false;
			}
}	
if(document.formconcours.txtAmis3.value!=""){
 if(!validateEmail(document.formconcours.txtAmis3.value)  ) {		 
				alert("Assurez-vous d'avoir rempli une adresse électronique valide. Merci.");
				document.formconcours.txtAmis3.focus()
				return false;
			}
}			
   			document.formconcours.submit(); 
  	
}


 /*Antoine's script -- Because the already-written script sucks*/
if(temp=document.getElementById('name')) temp.focus();

function valid_input(id,name)
{
	if( document.getElementById(id) )
	{
		document.getElementById(id).style.color='#14214e';
		if( document.getElementById(id).value == '' )
		{
			alert('Le champ "'+name+'" est obligatoire');
			document.getElementById(id).focus();
			document.getElementById(id).style.color='red';
			return false;
		}
	}
	return true;
}

function check_input()
{	
	if(!valid_input('name','Nom')) {return false;}
	if(!valid_input('entreprise','Nom de l\'entreprise')) {return false;}
	if(!valid_input('email','Courriel')) {return false;}
	if(!valid_input('phone','T\351l\351phone')) {return false;}
	if(!valid_input('entreprise_type','Type d\'entreprise')) {return false;}
	if(!valid_input('message','Pr\351cision / Message')) {return false;}
	
	var expr=new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
	if( !document.getElementById('email').value.match(expr) )
	{
		alert('Email non valide');
		document.getElementById('email').focus();
		document.getElementById('email').style.color='red';
		return false;
	}
	else { return true; }
	
}


