
function show_situation_fields(situation)
{ document.getElementById("proj_table").style.display = "none";
  document.getElementById("entp_table").style.display = "none";
  document.getElementById("part_table").style.display = "none";
  document.getElementById("autre_table").style.display = "none";
  switch(situation)
  { case 0: document.getElementById("proj_table").style.display = "block"; break;
    case 1: document.getElementById("entp_table").style.display = "block"; break;
    case 2: document.getElementById("part_table").style.display = "block"; break;
    case 3: document.getElementById("autre_table").style.display = "block"; break;
  }
}
  
the_return = true;
message = "";
focused = false;

normal_color = "#ffffff";
warn_color = "#d2e3ae";

function check_contact_form()
{ message = "";
  focused = false;
  res = true;
  res = res & is_not_empty("contact_form", "nom", " - votre nom\n");
  res = res & is_not_empty("contact_form", "prenom", " - votre prenom\n");
  res = res & is_not_empty("contact_form", "telephone", " - un numero de téléphone\n");
  if(is_not_empty("contact_form", "email", " - votre email\n"))
  { res = res & is_email("contact_form", "email", " - une adresse mail valide\n");
  }
  else res = false;
  res = res & is_not_empty("contact_form", "sujet", " - un sujet\n");
  res = res & is_not_empty("contact_form", "message", " - un message\n");
  if(!res) { alert(message); return false; }
  return true;
}

function is_not_empty(form, id, mess)
{ document.getElementById(id).style.backgroundColor = normal_color;
  if(eval("document.forms[\"" + form + "\"]." + id + ".value == \"\""))
  { if(message == "") message = "vous devez préciser:\n";
    message += mess;
    document.getElementById(id).style.backgroundColor = warn_color;
    if(!focused)
	{ document.getElementById(id).focus();
	  focused = true;
	}
    return false;
  }
  return true;
}

function is_email(form, id, mess)
{ var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  document.getElementById(id).style.backgroundColor = normal_color;
  if(!eval("filter.test(document.forms[\"" + form + "\"]." + id + ".value)"))
  { if(message == "") message = "vous devez préciser:\n";
    message += mess;
    document.getElementById(id).style.backgroundColor = warn_color;
    if(!focused)
	{ document.getElementById(id).focus();
	  focused = true;
	}
    return false;
  }
  return true;
}