function changedItem(elem, oblig){ if(elem.value.length == 0) elem.style.border=(oblig)?'1px solid #F00':'1px solid #666'; else elem.style.border= '1px solid #FFF'; }  var ajaxReturn = ""; var toReturn = ""; var ok = false;  function verifForm(form) {  if(ok == true) { return true; } document.getElementById('form').style.visibility = 'hidden'; document.getElementById('wait').style.display = 'block'; toReturn = ""; toReturn += verifNotNull(form); toReturn += verifEmail(form); setTimeout("verifCaptcha('"+form.id+"')", 5); return false; }  function affichResult(myForm) { if(toReturn.length>0 || ajaxReturn.length>0 ) { ok = false; document.getElementById('form').style.visibility = 'visible'; document.getElementById('wait').style.display = 'none'; alert('Le formulaire n\'a pas été envoyé car :\n' + toReturn + ajaxReturn); } else { ok = true; myForm.submit(); } }  function verifEmail(myForm) { var toReturn = ""; for(var i = 0; i < myForm.length ; i++) { if(myForm[i].value.length>0 && myForm[i].id.match("^(.*)Mail(.*)$") && !myForm[i].value.match("^([a-z0-9]|\.|-)+@(([a-z0-9]|-)+\.)+\.[a-z]{2,4}$")) toReturn += "- Le champ " + myForm[i].id.replace(/_oblig/g, '').replace(/_/g, ' ') + " n'est pas une adresse e-Mail valide.\n";     } return toReturn; }  function verifNotNull(myForm) { var toReturn = ""; for(var i = 0; i < myForm.length ; i++) { if(myForm[i].value.length==0 && myForm[i].id.match("^(.*)_oblig$")) toReturn += "- Le champ " + myForm[i].id.replace(/_oblig/g, '').replace(/_/g, ' ') + " est vide.\n";     } return toReturn; }  function verifCaptcha(myForm) { myForm = document.getElementById(myForm); if(myForm.captcha.value.length==0) { affichResult(myForm); return; } var url = window.location.href.replace('contacter-notre-agence.html', 'root.php?controlleur=Captcha'); new Ajax.Request(url, { method: 'post',  parameters: {'captcha': encodeURIComponent(myForm.captcha.value)}, onSuccess: function(transport) { if (transport.responseText == true) ajaxReturn = ""; else ajaxReturn = "- Le code anti-spam rentré ne correspond pas à celui affiché.\n"; affichResult(myForm); } }); }