
//////////////////////////////////////////////
// Hide or display some area on the page
//////////////////////////////////////////////
function display(calque)
{
	// Display layer with id 'calque'
	document.getElementById(calque).style.display=document.getElementById(calque).style.display=="none"?"block":"none";
}
//////////////////////////////////////////////
// Show other function field if 'other'
// selected in function field
//////////////////////////////////////////////
function showOtherFunctionField(afficher)
{
	var obj = document.getElementById('autreFonctionDiv');
	if (afficher == '1') {
		obj.style.display = 'block';
	} else if (afficher == '0') {
		obj.style.display = 'none';	
	}
}

function showAutre()
{
	var src = document.getElementById('fonction').value;
	var dst = document.getElementById('autreFonctionDiv');

	if (src == 'autre')
	{
		dst.style.display = 'block';
	}
	else
	{
		dst.style.display = 'none';
	}
}

////////////////////////////////////////////////////////////////////
// fonction trim (enléve les espaces en début et en fin  de chaine)
// Trouvé sur le web : ici --> 
// http://green-goblin.org/log/2006/03/16/6-fonctions-trim-en-javascript
////////////////////////////////////////////////////////////////////
function trim(s) {    return s.replace(/^\s+/, '').replace(/\s+$/, '');}
////////////////////////////////////////////////////
// Check the add comment FORM, and submit it if OK
////////////////////////////////////////////////////
function checkForm()
{
// Initialize form label color to 'black'
   document.getElementById('lbl_nom').style.color="black";
   document.getElementById('lbl_prenom').style.color="black";
   document.getElementById('lbl_institutionScolaire').style.color="black";
   document.getElementById('lbl_courriel').style.color="black";   
   document.getElementById('lbl_pays').style.color="black";    

// Hide error message panel
   	document.getElementById("feedback").innerHTML = "";
    

  if(trim(document.demandeCreation.nom.value) === "")  {
   	document.demandeCreation.nom.focus();
   	document.getElementById('lbl_nom').style.color="red";
	document.getElementById("feedback").innerHTML = "<img class=\"attention\" src=\"images/avertissement.gif\" alt=\"\" width=\"44\" height=\"38\" />Please enter your name.";  
	
	return false;
  }
  
 if(trim(document.demandeCreation.prenom.value) === "") {

   	document.demandeCreation.prenom.focus();
   	document.getElementById('lbl_prenom').style.color="red";
	document.getElementById("feedback").innerHTML = "<img class=\"attention\" src=\"images/avertissement.gif\" alt=\"\" width=\"44\" height=\"38\" />Please enter your first name.";  	
   	
   	return false;
  }

 if(trim(document.demandeCreation.institutionScolaire.value) === "") {

   	document.demandeCreation.institutionScolaire.focus();
   	document.getElementById('lbl_institutionScolaire').style.color="red"; 
	document.getElementById("feedback").innerHTML = "<img class=\"attention\" src=\"images/avertissement.gif\" alt=\"\" width=\"44\" height=\"38\" />Please enter the name of your educational institution.";   
     
   	return false;
  }
  
  
   if(trim(document.demandeCreation.pays.value) === "") {

   	document.demandeCreation.pays.focus();
   	document.getElementById('lbl_pays').style.color="red"; 
	document.getElementById("feedback").innerHTML = "<img class=\"attention\" src=\"images/avertissement.gif\" alt=\"\" width=\"44\" height=\"38\" />Please enter the name of your country.";   
     
   	return false;
  }

 if(document.demandeCreation.courriel.value.indexOf('@') === -1 || document.demandeCreation.courriel.value.indexOf('.') === -1) {
  	document.demandeCreation.courriel.focus();
 	document.getElementById('lbl_courriel').style.color="red";   
	document.getElementById("feedback").innerHTML = "<img class=\"attention\" src=\"images/avertissement.gif\" alt=\"\" width=\"44\" height=\"38\" />Please enter a valid email address.";  
   
   	return false;
 }
 
  if(document.demandeCreation.courriel.value.indexOf('@') === -1 || document.demandeCreation.courriel.value.indexOf('.') === -1) {
  	document.demandeCreation.courriel.focus();
 	document.getElementById('lbl_courriel').style.color="red";   
	document.getElementById("feedback").innerHTML = "<img class=\"attention\" src=\"images/avertissement.gif\" alt=\"\" width=\"44\" height=\"38\" />Please enter a valid email address.";  
   
   	return false;
 }
 
  if(document.demandeCreation.courriel2.value.indexOf('@') === -1 || document.demandeCreation.courriel2.value.indexOf('.') === -1) {
  	document.demandeCreation.courriel2.focus();
 	document.getElementById('lbl_courriel2').style.color="red";   
	document.getElementById("feedback").innerHTML = "<img class=\"attention\" src=\"images/avertissement.gif\" alt=\"\" width=\"44\" height=\"38\" />Please enter a valid email address.";  
   
   	return false;
 }
 
  if(document.demandeCreation.courriel2.value != document.demandeCreation.courriel.value) {
  	document.demandeCreation.courriel2.focus();
	document.getElementById('lbl_courriel').style.color="red";
 	document.getElementById('lbl_courriel2').style.color="red";   
	document.getElementById("feedback").innerHTML = "<img class=\"attention\" src=\"images/avertissement.gif\" alt=\"\" width=\"44\" height=\"38\" />The values in the Email and Confirm Email fields must be identical.";  
   
   	return false;
 }
 
  

// If All is OK   
  document.forms.demandeCreation.submit();
  
  return true;
  }
