<!-- Vérification de formulaire
//Supprime le caractère (tel qu'un espace) qui apparaît éventuellement 
//au début ou à la fin de la chaîne donnée.
function jsTrim (inputString) 
{
        var returnString = inputString;
		var removeChar = ' ';
        if (removeChar.length)
        {
          while(''+returnString.charAt(0)==removeChar)
                {
                  returnString=returnString.substring(1,returnString.length);
                }
                while(''+returnString.charAt(returnString.length-1)==removeChar)
          {
            returnString=returnString.substring(0,returnString.length-1);
          }
        }
        return returnString;
}

function isInteger(inputString)
{
	if (inputString.length == 0)
		return false;
	var searchForNonDigits = /[^0-9]/;
	return (!searchForNonDigits.test(inputString));
}
//Menu Date
function getYear(d) { 
   return (d < 1000) ? d + 1900 : d;
}
//Est date
function isDate (year, month, day) {
	// month argument must be in the range 1 - 12
	month = month - 1;  // javascript month range : 0- 11
	var tempDate = new Date(year,month,day);
	if ( (getYear(tempDate.getYear()) == year) &&
		(month == tempDate.getMonth()) &&
		(day == tempDate.getDate()) )
		return true;
	else
	  return false
}
//Date d'adhesion
function jsCheckDate(madate)
{
	day = madate.substr(0,2);		
	month = madate.substr(3,2);
	year = madate.substr(6,4);
	month = month - 1;  // javascript month range : 0- 11
	var tempDate = new Date(year,month,day);
	if ( (getYear(tempDate.getYear()) == year) &&
		(month == tempDate.getMonth()) &&
		(day == tempDate.getDate()) )
		return true;
	else
	  return false;
}
function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("L'adresse email que vous avez saisie est incorrecte\n (Vérifier la présence de @ et les .)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("La partie gauche de l'adresse email que vous avez saisie est incorrecte !")
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("L'adresse IP de destination n'est pas correcte !")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Le domaine de l'adresse email que vous avez saisie est incorrect !")
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
   alert("L'adresse email que vous avez saisie est incorrecte. Elle doit se terminer par 2,3 ou 4 lettres !\n(Exemple : .com ou .fr)")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="Le domaine de l'adresse email que vous avez saisie est incorrect !"
   alert(errStr)
   return false
}
return true;
}

//  End -->
