// JavaScript Document

       
    function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }
    }
	
     function validateschools() 
	 {
		var theForm =document.form1, z = 0;
		 for(z=0; z<theForm.length;z++)
		 {
		  if(theForm[z].type == 'checkbox' && theForm[z].checked )
		  {
		  //theForm[z].checked = theElement.checked;
		  return true ;
			break ;
		  }
		 }
	  return false ;
    } 
	
function MM_openBrWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}


function validateform () { 

	//Initialise variables
	var errorMsg = "";	
		  	
	//Check for a first name
	if (document.form1.user_name.value == ""){
		errorMsg += "\n\tNom       \t\t- Entrez votre nom";	
	}
	if (document.form1.user_country.value == ""){
		errorMsg += "\n\tPays  \t\t- Entrez votre pays ";	
	}

	
	 if ( !validateschools() )
	 {
		errorMsg += "\n\tEcole \t\t- Veuillez choisir une école ";	
	} 
   
		
	if ((document.form1.user_email.value == "") || (document.form1.user_email.value.length > 0 && (document.form1.user_email.value.indexOf("@",0) == - 1 || document.form1.user_email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tE-mail \t\t- Veuillez entrer une adresse e-mail valide";}
//errorMsg += "\n\tE-mail \t\t- Please enter your valid e-mail address";}
if (document.form1.subject.value == ""){
	//errorMsg += "\n\tSubject \t\t- Please enter your Subject ";	
			errorMsg += "\n\tSujet \t\t- Entrez votre sujet ";	
	}
		if (document.form1.message.value == ""){
		//errorMsg += "\n\tMessage \t\t- Please enter your message ";	
		errorMsg += "\n\tMessage \t\t- Entrez votre message ";	
	}
	
	
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
	//	msg += "the Form has not been sent because there are problem(s) with the form.\n";
		//msg += "Please correct these fields(s) and re-submit the form.\n";
	//	msg += "______________________________________________________________\n\n";
	//	msg += "The following field(s) need to be corrected: -\n";
		
		msg += "Le questionnaire n'a pas été envoyé, vérifiez que vous l'avez correctement rempli.\n";
		msg += "Corrigez les champs suivants et réessayez .\n";
		msg += "______________________________________________________________\n\n";
		msg += "Les champs suivants ne ont pas remplis correctment : -\n";

		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}

function CheckForm () {
	 if ( validateform() ) 
	 {
		 document.form1.submit();
		 }
	}
	

//////////////////price form

function validateformPrice () { 

	//Initialise variables
	var errorMsg = "";	
		  	
	//Check for a first name
	if (document.form1.user_name.value == ""){
		errorMsg += "\n\tNom       \t\t- Entrez votre nom";	
	}
	if (document.form1.user_country.value == ""){
		errorMsg += "\n\tPays  \t\t- Entrez votre pays ";	
	}

	
	 if ( !validateschools() )
	 {
		errorMsg += "\n\tEcole \t\t- Veuillez choisir une école ";	
	} 
   
		
	if ((document.form1.user_email.value == "") || (document.form1.user_email.value.length > 0 && (document.form1.user_email.value.indexOf("@",0) == - 1 || document.form1.user_email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tE-mail \t\t- Veuillez entrer une adresse e-mail valide";}
//errorMsg += "\n\tE-mail \t\t- Please enter your valid e-mail address";}
/*if (document.form1.subject.value == ""){
	//errorMsg += "\n\tSubject \t\t- Please enter your Subject ";	
			errorMsg += "\n\tSujet \t\t- Entrez votre sujet ";	
	}*/
		if (document.form1.message.value == ""){
		//errorMsg += "\n\tMessage \t\t- Please enter your message ";	
		errorMsg += "\n\tMessage \t\t- Entrez votre message ";	
	}
	
	
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
	//	msg += "the Form has not been sent because there are problem(s) with the form.\n";
		//msg += "Please correct these fields(s) and re-submit the form.\n";
	//	msg += "______________________________________________________________\n\n";
	//	msg += "The following field(s) need to be corrected: -\n";
		
		msg += "Le questionnaire n'a pas été envoyé, vérifiez que vous l'avez correctement rempli.\n";
		msg += "Corrigez les champs suivants et réessayez .\n";
		msg += "______________________________________________________________\n\n";
		msg += "Les champs suivants ne ont pas remplis correctment : -\n";

		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}
	function CheckFormPrice () {
	 if ( validateformPrice() ) 
	 {
	 document.form1.submit();
		 }
	}
