	
 function validateForm(lang, contact){

    // Check if the email address is in a valid format
  if (checkEmail(document.mailmaniacForm, lang) == false) return false;
    // Check if the confirmation email is the same as the email
    if (document.mailmaniacForm.Adresse_Email.value != document.mailmaniacForm.Confirm_Adresse_Email.value){
        
        if (lang == 'fr')
          alert("Confirmez votre addresse email correctement.");
        else
          alert("Please confirm your email address correctly.");
        return false;
    }

    // Check if the phone number is correct
    if (checkPhone() == false)
    {
      if (lang == 'fr')
        alert("Veuillez entrer un numero de telephone valide");
      else
        alert("The phone number entered is not valid");
      return false;
    }

   // Now check the required fields
 	if(document.getElementById('required_fields') != null){
 
	 	var reqs=document.getElementById('required_fields').value;
	 	reqs = reqs.substring(0,reqs.length)	;	
	    var req_fields = new Array();
	    var req_fields = reqs.split(',');									
		nbr_fields = req_fields.length;	 		    
		var req = true;
		
		for(var i=0;i<nbr_fields;i++){ 	
    	    
	      if(document.getElementById(req_fields[i]).value.length <=0){       
	   	   req = false;																				
	       break;		
	      }		
	    } 
     
		if(!req)
    {
		  if (lang == 'fr')
		    alert('Veuillez remplir tous les champs ayant une *');
		  else
		    alert('All the fields marked with a * are compulsory. Please provide all the required fields');
		  
      return false;
		}		
		//return false;
  }		
  
   // Set the week to not disabled so that it appears in the email
   if (!contact)
   {
      document.mailmaniacForm.SemaineReservation.disabled=false;
  	} 
  	
   document.mailmaniacForm.submit();
  // }		 		
}

function checkEmail(myForm, lang) 
{
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.mailmaniacForm.Adresse_Email.value)){
        return (true)
    }
    
    if (lang == 'fr')
      alert("L'adresse email specifi‚e n'est pas valide");
    else
      alert("The email address specified is not valid");
    return (false);
}

function ValidateNo(NumStr, String)
{
    for(var Idx=0; Idx<NumStr.length; Idx++)
    {
        var Char = NumStr.charAt(Idx);
        var Match = false;

        for(var Idx1=0; Idx1<String.length; Idx1++)
        {
            if(Char == String.charAt (Idx1))
                Match = true;
        }

        if (!Match)
            return false;
    }
    return true;
} 

// Returns true of all ok
function checkPhone () 
{
    if (document.mailmaniacForm.Numero_de_Telephone.value == "")
    {
      return (false);
    }

    if(!ValidateNo(document.mailmaniacForm.Numero_de_Telephone.value,"1234567890+- ")) 
    {
       document.mailmaniacForm.Numero_de_Telephone.focus();
       return (false);  
    }

    return (true);
}
