
 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(){
    
//document.forms["formulaire"].elements["email"]
    //var formElements = document.form.elements;
var formElements = document.form.elements;    
    for (i=0; i<formElements.length; i++) {
    
        if( (formElements[i].className == "requiredField" || formElements[i].title == "requiredField") && formElements[i].value == "" ){
            
            alert("Please make sure you have filled all the fields")
            return false;
        }
        
        if( formElements[i].value != "" ) {
            
            if(formElements[i].alt == "email" ){                
                if(!validateEmail(formElements[i].value) ){
                    
                    alert("The supplied e-mail address is not valid")
                    return false;
                }
            } 
            
            if(formElements[i].name == "tel" ){
                
                if(!checkInternationalPhone(formElements[i].value) ){
                    
                    alert("The telephone number is not valid")
                    return false;
                }
            }
            
            if(formElements[i].alt == "number" ){
                
                if(!validateNumber(formElements[i].value) ){
                    
                    alert("Assurez-vous qu'il y a que des chiffres et un « . »")
                    return false;
                }
            }            
            if(formElements[i].name == "CV" ){
                
                elem=formElements[i].value
                l=elem.lastIndexOf('.')
                ext=elem.substring(l)                
                if(ext!=".doc" && ext!=".docx" && ext!=".pdf"  && ext!=".xls" && ext!=".xlsx"){
                    alert("Format de votre document est invalide.")
                    alert(ext)
                    
                    return false                }
            }
        }			  
    }return true;
}function SetMaxChar(champ, max, langue)
   {
   if (champ.value.length > max)
      {
      champ.value = champ.value.substring(0,max);
      if (langue == "en")
         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."); 
      }
   }
   
/*Fonction mod FT*/    function validation(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  validate(){
	if(!validation(document.formContact.emailFC.value) ){
	alert("The supplied e-mail address is not valid.")
}
}function  validateTEL(){
	if(!checkInternationalPhone(document.formContact.tel.value) ){
	alert("The telephone number is not valid.")
}
}
		function checkFC(){
		if(document.formContact.nom.value != "" & document.formContact.emailFC.value != "" & document.formContact.tel.value != "" & document.formContact.commentaires.value != "") {
   			 
			 // alors on envoie le formulaire
   			 document.formContact.submit();
  		}else {
   			 // sinon on affiche un message
   			 alert("Please make sure you have filled all the fields.");
  			}
		}										function checkFormInfo(){
		if(document.formInfo.nom.value != "" & document.formInfo.courriel.value != "" & document.formInfo.tel.value != "" & document.formInfo.description.value != "") {document.formInfo.submit();   			 
			 // alors on envoie le formulaire   alert("Votre demande de service a été envoyé. Merci.");     window.close();   			 
  		}else {
   			 // sinon on affiche un message
   			 alert("Please make sure you have filled all the fields.");
  			}
		}						function  validateInfo(){
	if(!validation(document.formInfo.courriel.value) ){
	alert("The supplied e-mail address is not valid.")
}
}function  validateTELInfo(){
	if(!checkInternationalPhone(document.formInfo.tel.value) ){
	alert("The telephone number is not valid.")
}
}

function  validateEmailSoumission(){
if(!validation(document.formSoumission.email.value) ){
alert("The supplied e-mail address is not valid.")
}
}function  validateTELSoumission(){
if(!checkInternationalPhone(document.formSoumission.Tel.value) ){
alert("The telephone number is not valid.")
}

}		function checkFCSoumission(){
if(document.formSoumission.nom.value != "" & document.formSoumission.email.value != "" & document.formSoumission.Tel.value != "" ) {
// alors on envoie le formulaire
 document.formSoumission.submit();
}else {
// sinon on affiche un message
 alert("Please make sure you have filled all the fields.");
}
}

