function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function validate_form(thisform)
{
	with (thisform)
	{
		nom.value = trim(nom.value);
	
		if (validate_required(nom,"Nom manquant")==false)
		{nom.focus();return false;}
		
		courriel.value = trim(courriel.value);
		
		if (validate_required(courriel, "Courriel manquant")==false)
		{courriel.focus();return false;}
				
		if (validate_email(courriel, "Ce courriel n'est pas valide")==false)
		{courriel.focus();return false;}
		
		texte.value = trim(texte.value);
		
		if (validate_required(texte, "Texte manquant")==false)
		{texte.focus();return false;}
	}
}

function trim(strText) {
    while('' + strText.charAt(0) == ' ') {
        strText = strText.substring(1, strText.length);
    }
    while('' + strText.charAt(strText.length-1)==' ') {
        strText = strText.substring(0, strText.length-1);
    }
    return strText;
}