var PatternsDict = new Object();
PatternsDict.zipPat = /^(\d{5})?$/;
PatternsDict.notNullZipPat = /^\d{5}$/;
PatternsDict.timePat = /^(\d{2}:\d{2})?$/;
PatternsDict.notNullTimePat = /^\d{2}:\d{2}$/;
//PatternsDict.emailPat = /^([^@]+@.+[.][^.]{2,4}?)?$/;
//PatternsDict.notNullEmailPat = /^[^@]+@.+[.][^.]{2,4}?$/;
PatternsDict.emailPat = /^[a-z_A-Z_0-9][a-z_A-Z_0-9\.\-]+@[a-z_A-Z_0-9\.\-]+\.[a-z_A-Z]{2,4}$/;
PatternsDict.notNullEmailPat = /^[a-z_A-Z_0-9][a-z_A-Z_0-9\.\-]+@[a-z_A-Z_0-9\.\-]+\.[a-z_A-Z]{2,4}$/
PatternsDict.datePat = /^([0-9][0-9]?.[0-9][0-9]?.[0-9][0-9][0-9][0-9])?$/;
PatternsDict.notNullDatePat = /^[0-9][0-9]?.[0-9][0-9]?.[0-9][0-9][0-9][0-9]$/;
PatternsDict.digitPat = /^[0-9]*$/;
PatternsDict.notNullDigitPat = /^[0-9]+$/;
PatternsDict.notNullAreaPat = /.+/;
PatternsDict.notNullPat = /^.+$/;
PatternsDict.phonePat = /^(\d{10})?$/;
PatternsDict.notNullPhonePat = /^\d{10}$/;
function testDate(elt)
{
var datestring = elt.value ;
if (datestring == "") {return true ;}
if (PatternsDict.datePat.exec(datestring)) {
var month = datestring.slice(3,5) - 1 ;
var theDate = new Date(datestring.slice(6,10), month, datestring.slice(0,2))
var ok = datestring.slice(6,10) == theDate.getFullYear() && month == theDate.getMonth() && datestring.slice(0,2) == theDate.getDate() ;
} else {
var ok = false ;
}
if (!ok) {
alert("Le champ " + elt.name + " a une valeur incorrecte " + elt.value);
elt.focus();
return false;
} else {
return true ;
}
}
function validateForm(theForm){
var elArr = theForm.elements;
for(var i = 0; i < elArr.length; i++)
with(elArr[i]){
var v = elArr[i].validator;
if(!v) continue;
if(v == "realdate") {
if (!testDate(elArr[i])) {
return false ;
}
} else {
var thePat = PatternsDict[v];
var gotIt = thePat.exec(value);
if(!gotIt){
alert("Le champ " + elArr[i].nomvalidator + " a une valeur incorrecte " + value);
focus();
return false;
}
}
} return true; 
}
function openErrorWin(badFields) {
var msg = '<table width=100% border=0 cellpadding=0 cellspacing=0>';
msg = msg + '<tr bgcolor="#FFFFFF"></a><td></a><img src="/img/dot.gif" width=1 height=7 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td bgcolor="#abbfcc"></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td bgcolor="#abbfcc" align=left></a><font face="Arial, Helvetica, sans-serif" size=2 color="#FFFFFF"><i></a><b></a> Q U E S T I O N S &nbsp; / &nbsp;R &Eacute; P O N S E S</b></a></i></a></font></a></td></a></tr></a>';
msg = msg + '<tr></a><td bgcolor="#abbfcc"></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr bgcolor="#FFFFFF"></a><td></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td></a><font face="Arial, Helvetica, sans-serif" size=3 color="#000000"><b></a>Le formulaire n\'est pas complet !</b></a><br></a></font></a></td></a></tr></a>';
msg = msg + '<tr></a><td></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td></a><font face="Arial, Helvetica, sans-serif" size=3 color="#000000">Les champs suivants sont vides ou incorrects :</font></a><br></a><font face="Arial, Helvetica, sans-serif" size=2 color="#000000">';
var msg1 = '';
for (var i = 0; i < badFields.length; i++) {
msg1 = msg1 + "-" + badFields[i] + "<br></a>" ;
}
msg = msg + msg1; 
msg = msg + '<br></a></font></a></td></a></tr></a></table></a>';
msgWindow=window.open('','','toolbar=no,scrollbars=no,width=400,height=300') ;
msgWindow.document.open() ;
msgWindow.document.write(msg) ;
msgWindow.document.close() ;
}
function validateForm2(theForm) {
var elArr = theForm.elements;
var badFields = new Array() ;
var j = 0 ;
for(var i = 0; i < elArr.length; i++) {
with(elArr[i]){
var v = elArr[i].validator;
if(!v) continue;
var thePat = PatternsDict[v];
var gotIt = thePat.exec(value);
if(!gotIt){
badFields[j] = name ;
j = j + 1 ;
}
}
}
if (badFields.length == 0) {return true ;} else {
openErrorWin(badFields) ;
return false ;
}
}
function openErrorWin1(badFields) {
var msg = '<table width=100% border=0 cellpadding=0 cellspacing=0>';
msg = msg + '<tr bgcolor="#FFFFFF"></a><td></a><img src="/img/dot.gif" width=1 height=7 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td bgcolor="#abbfcc"></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td bgcolor="#abbfcc" align=center></a><font face="Arial, Helvetica, sans-serif" size=2 color="#FFFFFF"><i></a><b></a>  L E S &nbsp;P E T I T E S &nbsp;A N N O N C E S</b></a></i></a></font></a></td></a></tr></a>';
msg = msg + '<tr></a><td bgcolor="#abbfcc"></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr bgcolor="#FFFFFF"></a><td></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td></a><font face="Arial, Helvetica, sans-serif" size=3 color="#000000"><b></a>Le formulaire n\'est pas complet !</b></a><br></a></font></a></td></a></tr></a>';
msg = msg + '<tr></a><td></a><img src="/img/dot.gif" width=1 height=2 border=0></td></a></tr></a>';
msg = msg + '<tr></a><td></a><font face="Arial, Helvetica, sans-serif" size=3 color="#000000">Les champs suivants sont vides ou incorrects :</font></a><br></a><font face="Arial, Helvetica, sans-serif" size=2 color="#000000">';
var msg1 = '';
for (var i = 0; i < badFields.length; i++) {
msg1 = msg1 + "-" + badFields[i] + "<br></a>" ;
}
msg = msg + msg1; 
msg = msg + '<br></a></font></a></td></a></tr></a></table></a>';
msgWindow=window.open('','','toolbar=no,scrollbars=no,width=400,height=300') ;
msgWindow.document.open() ;
msgWindow.document.write(msg) ;
msgWindow.document.close() ;
}
function validateForm3(theForm) {
var elArr = theForm.elements;
var badFields = new Array() ;
var j = 0 ;
for(var i = 0; i < elArr.length; i++) {
with(elArr[i]){
var v = elArr[i].validator;
if(!v) continue;
var thePat = PatternsDict[v];
var gotIt = thePat.exec(value);
if(!gotIt){
badFields[j] = name ;
j = j + 1 ;
}
}
}
if (badFields.length == 0) {return true ;} else {
openErrorWin1(badFields) ;
return false ;
}
}