/* CHECK FORM ETAPE 1 */

function checkFormecep001()
{
    var cLastName, cAdresse1, cAdresse2, cAdresse3, cZipCode, cCity, cEMail, cTelFixe, cTelMobile, cBirthDay, cBirthDay_date, cBirthDay_month, cBirthDay_year, cCommentaire ;

    with(window.document.forms['msgform0'])
    {
        cLastName        = LastName;
        cAdresse1        = Adresse1;
        cAdresse2        = Adresse2;
        cAdresse3        = Adresse3;
        cZipCode         = ZipCode;
        cCity            = City;
        cEMail           = EMail;
        cTelFixe         = TelFixe;
        cTelMobile       = TelMobile;
        cBirthDay_date   = BirthDay_date;
        cBirthDay_month  = BirthDay_month;
        cBirthDay_year   = BirthDay_year;
        cCommentaire     = Commentaire;
    }
    if (trim(cLastName.value) == '')
    {
        alert('Veuillez saisir votre Nom svp.');
        cLastName.focus();
        return false;
    }
/*
    else if (trim(cAdresse1.value) == '' && trim(cAdresse2.value) == '' && trim(cAdresse3.value) == '')
    {
        alert('Merci de renseigner un des 3 champs suivants :\n\n "APP,BAT,ETAG,RESID"\n\n "Numéro de voie et voie"\n\n ou "Lieu dit, localité supplémentaire, cedex"');
        cAdresse2.focus();
        return false;
    }
*/
    else if (trim(cZipCode.value) == '')
    {
        alert('Veuillez saisir votre Code Postal svp.');
        cZipCode.focus();
        return false;
    }
    else if (cZipCode.value.length != '5')
    {
        alert('Veuillez saisir votre Code Postal correctement : 5 caractères attendus.');
        cZipCode.focus();
        return false;
    }
    else if (trim(cCity.value) == '')
    {
        alert('Veuillez saisir votre Ville svp');
        cCity.focus();
        return false;
    }
    else if (trim(cEMail.value) == '')
    {
        alert('Veuillez saisir votre Adresse Email svp.');
        cEMail.focus();
        return false;
    }
    else if (!isEmail(trim(cEMail.value)))
    {
        alert('Veuillez saisir votre Adresse Email correctement svp.');
        cEMail.focus();
        return false;
    }
    else if (cTelFixe.value != '')
    {
        if (cTelFixe.value.length != '10' && cTelFixe.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone fixe correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0123456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330123456789)');
        cTelFixe.focus();
        return false;}
    }
    else if (cTelMobile.value != '')
    {
        if (cTelMobile.value.length != '10' && cTelMobile.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone mobile correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0623456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330623456789)');
        cTelMobile.focus();
        return false;}
    }
    else if (trim(cBirthDay_date.value) != '' || trim(cBirthDay_month.value) != '' || trim(cBirthDay_year.value) != '')
    {
        
        var strSeperator = "/";
        var thisyear = new Date().getFullYear();
        cBirthDay = trim(cBirthDay_month.value)+strSeperator+trim(cBirthDay_date.value)+strSeperator+trim(cBirthDay_year.value);
        chkBirthDay=dateValid(cBirthDay);

        if (trim(cBirthDay_year.value) < '1880'){
           alert('La date de naissance indiquée est incorrecte Veuillez corriger votre année de naissance');
           cBirthDay_year.focus();
           return false;
        }
        else if (trim(cBirthDay_year.value) > thisyear){
           alert('La date de naissance indiquée est incorrecte Veuillez corriger votre année de naissance');
           cBirthDay_year.focus();
           return false;
        }
        else if (trim(cBirthDay_month.value) > '12'){
           alert('La date de naissance indiquée est incorrecte Veuillez corriger votre mois de naissance');
           cBirthDay_month.focus();
           return false;
        }
        else if (!chkBirthDay){
           alert('La date de naissance indiquée est incorrecte format attendu :JJ/MM/AAAA');
           cBirthDay_date.focus();
           return false;
        }

    }
    else if (trim(cCommentaire.value).length < '4')
    {
        alert('Veuillez saisir votre question svp.');
        cCommentaire.focus();
        return false;
    }
    else
    {
        cFirstName.Value  = trim(cFirstName.value);
        cLastName.Value   = trim(cLastName.value.toUpperCase());
        cZipCode.value    = trim(cZipCode.value);
        cCity.value       = trim(cCity.value);
        cEMail.value      = trim(cEMail.value);
        cTelFixe          = trim(cTelFixe.value);
        cTelMobile        = trim(cTelMobile.value);
        cBirthDay_date    = trim(BirthDay_date.value);
        cBirthDay_month   = trim(BirthDay_month.value);
        cBirthDay_year    = trim(BirthDay_year.value);
        cCommentaire      = trim(cCommentaire.value);
        return true;
    }
}

function checkFormecep001light()
{
    var cLastName, cZipCode, cCity, cEMail, cTelFixe, cTelMobile ;

    with(window.document.forms['msgform0'])
    {
        cLastName        = LastName;
        cZipCode         = ZipCode;
        cCity            = City;
        cEMail           = EMail;
        cTelFixe         = TelFixe;
        cTelMobile       = TelMobile;
    }
    if (trim(cLastName.value) == '')
    {
        alert('Veuillez saisir votre Nom svp.');
        cLastName.focus();
        return false;
    }
    else if (trim(cZipCode.value) == '')
    {
        alert('Veuillez saisir votre Code Postal svp.');
        cZipCode.focus();
        return false;
    }
    else if (cZipCode.value.length != '5')
    {
        alert('Veuillez saisir votre Code Postal correctement : 5 caractères attendus.');
        cZipCode.focus();
        return false;
    }
    else if (trim(cCity.value) == '')
    {
        alert('Veuillez saisir votre Ville svp');
        cCity.focus();
        return false;
    }
    else if (trim(cEMail.value) == '')
    {
        alert('Veuillez saisir votre Adresse Email svp.');
        cEMail.focus();
        return false;
    }
    else if (!isEmail(trim(cEMail.value)))
    {
        alert('Veuillez saisir votre Adresse Email correctement svp.');
        cEMail.focus();
        return false;
    }
    else if (cTelFixe.value != '')
    {
        if (cTelFixe.value.length != '10' && cTelFixe.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone fixe correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0123456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330123456789)');
        cTelFixe.focus();
        return false;}
    }
    else if (cTelMobile.value != '')
    {
        if (cTelMobile.value.length != '10' && cTelMobile.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone mobile correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0623456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330623456789)');
        cTelMobile.focus();
        return false;}
    }
    else
    {
        cLastName.Value   = trim(cLastName.value.toUpperCase());
        cZipCode.value    = trim(cZipCode.value);
        cCity.value       = cCity.value;
        cEMail.value      = trim(cEMail.value);
        cTelFixe          = trim(cTelFixe.value);
        cTelMobile        = trim(cTelMobile.value);
        return true;
    }
}
function checkFormecep001a3light()
{
    var cLastName, cZipCode, cCity, cEMail, cTelFixe, cTelMobile, cCommentaire ;

    with(window.document.forms['msgform0'])
    {
        cLastName        = LastName;
        cZipCode         = ZipCode;
        cCity            = City;
        cEMail           = EMail;
        cTelFixe         = TelFixe;
        cTelMobile       = TelMobile;
        cCommentaire     = Commentaire;
    }
    if (trim(cLastName.value) == '')
    {
        alert('Veuillez saisir votre Nom svp.');
        cLastName.focus();
        return false;
    }
    else if (trim(cZipCode.value) == '')
    {
        alert('Veuillez saisir votre Code Postal svp.');
        cZipCode.focus();
        return false;
    }
    else if (cZipCode.value.length != '5')
    {
        alert('Veuillez saisir votre Code Postal correctement : 5 caractères attendus.');
        cZipCode.focus();
        return false;
    }
    else if (trim(cCity.value) == '')
    {
        alert('Veuillez saisir votre Ville svp');
        cCity.focus();
        return false;
    }
    else if (trim(cEMail.value) == '')
    {
        alert('Veuillez saisir votre Adresse Email svp.');
        cEMail.focus();
        return false;
    }
    else if (!isEmail(trim(cEMail.value)))
    {
        alert('Veuillez saisir votre Adresse Email correctement svp.');
        cEMail.focus();
        return false;
    }
    else if (cTelFixe.value != '')
    {
        if (cTelFixe.value.length != '10' && cTelFixe.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone fixe correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0123456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330123456789)');
        cTelFixe.focus();
        return false;}
    }
    else if (cTelMobile.value != '')
    {
        if (cTelMobile.value.length != '10' && cTelMobile.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone mobile correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0623456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330623456789)');
        cTelMobile.focus();
        return false;}
    }
    else if (trim(cCommentaire.value).length < '4')
    {
        alert('Veuillez saisir votre question svp.');
        cCommentaire.focus();
        return false;
    }
    else
    {
        cLastName.Value   = trim(cLastName.value.toUpperCase());
        cZipCode.value    = trim(cZipCode.value);
        cCity.value       = trim(cCity.value);
        cEMail.value      = trim(cEMail.value);
        cTelFixe          = trim(cTelFixe.value);
        cTelMobile        = trim(cTelMobile.value);
        cCommentaire      = trim(cCommentaire.value);
        return true;
    }
}

function checkFormecep001b3light()
{
    var cLastName, cZipCode, cCity, cEMail, cTelFixe, cTelMobile, cRefProd1, cRefProd2, cRefProd3, cRefProd4, SizeProd1, SizeProd2, SizeProd3, SizeProd4, ColorProd1, ColorProd2, ColorProd3, ColorProd4, PrixProd1, PrixProd2, PrixProd3, PrixProd4 ;

    with(window.document.forms['msgform0'])
    {
        cLastName        = LastName;
        cZipCode         = ZipCode;
        cCity            = City;
        cEMail           = EMail;
        cTelFixe         = TelFixe;
        cTelMobile       = TelMobile;
        cRefProd1        = RefProd1;
        cRefProd2        = RefProd2;
        cRefProd3        = RefProd3;
        cRefProd4        = RefProd4;
        cSizeProd1       = SizeProd1;
        cSizeProd2       = SizeProd2;
        cSizeProd3       = SizeProd3;
        cSizeProd4       = SizeProd4;
        cColorProd1      = ColorProd1;
        cColorProd2      = ColorProd2;
        cColorProd3      = ColorProd3;
        cColorProd4      = ColorProd4;
        cPrixProd1       = PrixProd1;
        cPrixProd2       = PrixProd2;
        cPrixProd3       = PrixProd3;
        cPrixProd4       = PrixProd4;
    }
    if (trim(cLastName.value) == '')
    {
        alert('Veuillez saisir votre Nom svp.');
        cLastName.focus();
        return false;
    }
    else if (trim(cZipCode.value) == '')
    {
        alert('Veuillez saisir votre Code Postal svp.');
        cZipCode.focus();
        return false;
    }
    else if (cZipCode.value.length != '5')
    {
        alert('Veuillez saisir votre Code Postal correctement : 5 caractères attendus.');
        cZipCode.focus();
        return false;
    }
    else if (trim(cCity.value) == '')
    {
        alert('Veuillez saisir votre Ville svp');
        cCity.focus();
        return false;
    }
    else if (trim(cEMail.value) == '')
    {
        alert('Veuillez saisir votre Adresse Email svp.');
        cEMail.focus();
        return false;
    }
    else if (!isEmail(trim(cEMail.value)))
    {
        alert('Veuillez saisir votre Adresse Email correctement svp.');
        cEMail.focus();
        return false;
    }
    else if (cTelFixe.value != '')
    {
        if (cTelFixe.value.length != '10' && cTelFixe.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone fixe correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0123456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330123456789)');
        cTelFixe.focus();
        return false;}
    }
    else if (cTelMobile.value != '')
    {
        if (cTelMobile.value.length != '10' && cTelMobile.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone mobile correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0623456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330623456789)');
        cTelMobile.focus();
        return false;}
    }
    else if (trim(cRefProd1.value).length < '4')
    {
        alert('Veuillez saisir votre référence \"Produit 1\" correctement :\n\n 4 caractères minimum attendus.');
        cRefProd1.focus();
        return false;
    }
    else if (trim(cRefProd2.value) != '' && trim(cRefProd2.value).length < '4')
    {
        alert('Veuillez saisir votre référence \"Produit 2\" correctement :\n\n 4 caractères minimum attendus.');
        cRefProd2.focus();
        return false;
    }
    else if (trim(cRefProd3.value) != '' && trim(cRefProd3.value).length < '4')
    {
        alert('Veuillez saisir votre référence \"Produit 3\" correctement :\n\n 4 caractères minimum attendus.');
        cRefProd3.focus();
        return false;
    }
    else if (trim(cRefProd4.value) != '' && trim(cRefProd4.value).length < '4')
    {
        alert('Veuillez saisir votre référence \"Produit 4\" correctement :\n\n 4 caractères minimum attendus.');
        cRefProd4.focus();
        return false;
    }
    else
    {
        cLastName.Value   = trim(cLastName.value.toUpperCase());
        cZipCode.value    = trim(cZipCode.value);
        cCity.value       = trim(cCity.value);
        cEMail.value      = trim(cEMail.value);
        cTelFixe          = trim(cTelFixe.value);
        cTelMobile        = trim(cTelMobile.value);
        cRefProd1         = trim(cRefProd1.value);
        cRefProd2         = trim(cRefProd2.value);
        cRefProd3         = trim(cRefProd3.value);
        cRefProd4         = trim(cRefProd4.value);
        return true;
    }
}

function checkFormecep001g2()
{
    var cLastName, cZipCode, cCity, cEMail, cTelFixe, cTelMobile, cDateCde ;

    with(window.document.forms['msgform0'])
    {
        cLastName        = LastName;
        cZipCode         = ZipCode;
        cCity            = City;
        cEMail           = EMail;
        cTelFixe         = TelFixe;
        cTelMobile       = TelMobile;
        cDateCde         = DateCde;
    }
    if (trim(cLastName.value) == '')
    {
        alert('Veuillez saisir votre Nom svp.');
        cLastName.focus();
        return false;
    }
    else if (trim(cZipCode.value) == '')
    {
        alert('Veuillez saisir votre Code Postal svp.');
        cZipCode.focus();
        return false;
    }
    else if (cZipCode.value.length != '5')
    {
        alert('Veuillez saisir votre Code Postal correctement : 5 caractères attendus.');
        cZipCode.focus();
        return false;
    }
    else if (trim(cCity.value) == '')
    {
        alert('Veuillez saisir votre Ville svp');
        cCity.focus();
        return false;
    }
    else if (trim(cEMail.value) == '')
    {
        alert('Veuillez saisir votre Adresse Email svp.');
        cEMail.focus();
        return false;
    }
    else if (!isEmail(trim(cEMail.value)))
    {
        alert('Veuillez saisir votre Adresse Email correctement svp.');
        cEMail.focus();
        return false;
    }
    else if (cTelFixe.value != '')
    {
        if (cTelFixe.value.length != '10' && cTelFixe.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone fixe correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0123456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330123456789)');
        cTelFixe.focus();
        return false;}
    }
    else if (cTelMobile.value != '')
    {
        if (cTelMobile.value.length != '10' && cTelMobile.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone mobile correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0623456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330623456789)');
        cTelMobile.focus();
        return false;}
    }
    else if (trim(cDateCde.value) != '')
    {
        var strSeperator          = "/";
        var thisyear              = new Date().getFullYear();
        var thisday               = new Date().getDate();
        var thismonth             = new Date().getMonth()+1;
        var DateCdeArray          = cDateCde.value.split("/");
        var cDateCde_year         = DateCdeArray[2];
        var cDateCde_month        = DateCdeArray[1]*1;
        var cDateCde_day          = DateCdeArray[0]*1;
        var DateVal               = cDateCde_month+strSeperator+cDateCde_day+strSeperator+cDateCde_year;
        chkDateCde                = dateValid(DateVal);
/*
alert('debug date du jour :'+thisday+thismonth+thisyear+'\n\ndebug date de commande :'+cDateCde_day+cDateCde_month+cDateCde_year);
*/
        if (cDateCde_year < thisyear-1){
           alert('La date de votre commande est trop ancienne, veuillez la corriger.');
           cDateCde.focus();
           return false;
        }
        else if (cDateCde_year > thisyear){
           alert('Votre commande ne peut avoir eut lieu à une date future :\n\n>> Veuillez corriger l\'année.');
           cDateCde.focus();
           return false;
        }
        else if (cDateCde_year == thisyear && cDateCde_month > thismonth){
           alert('Votre commande ne peut avoir eut lieu à une date future :\n\n>> Veuillez corriger le mois.');
           cDateCde.focus();
           return false;
        }
        else if (cDateCde_year == thisyear && cDateCde_month == thismonth && cDateCde_day > thisday){
           alert('Votre commande ne peut avoir eut lieu à une date future :\n\n>> Veuillez corriger le jour.');
           cDateCde.focus();
           return false;
        }
        else if (cDateCde_year == thisyear && cDateCde_month == thismonth && cDateCde_day == thisday){
           alert('Votre commande ne peut avoir eut lieu aujourd\'hui :\n\n>> Veuillez corriger le jour.');
           cDateCde.focus();
           return false;
        }
        else if (!chkDateCde){
           alert('La date de commande indiquée est incorrecte format attendu : JJ/MM/AAAA');
           cDateCde.focus();
           return false;
        }
    }
    else
    {
        cLastName.Value   = trim(cLastName.value.toUpperCase());
        cZipCode.value    = trim(cZipCode.value);
        cCity.value       = trim(cCity.value);
        cEMail.value      = trim(cEMail.value);
        cTelFixe          = trim(cTelFixe.value);
        cTelMobile        = trim(cTelMobile.value);
        cDateCde          = trim(cDateCde.value);
        return true;
    }
}

function checkFormecep001a1()
{
    var cLastName, cFirstName, cAdresse1, cAdresse2, cAdresse3, cZipCode, cCity, cEMail, cTelFixe, cTelMobile, cAncLastName, cAncFirstName, cAncAdresse1, cAncAdresse2, cAncAdresse3, cAncZipCode, cAncCity, cBirthDay, cBirthDay_date, cBirthDay_month, cBirthDay_year ;

    with(window.document.forms['msgform0'])
    {
        cLastName        = LastName;
        cFirstName       = FirstName;
        cAdresse1        = Adresse1;
        cAdresse2        = Adresse2;
        cAdresse3        = Adresse3;
        cZipCode         = ZipCode;
        cCity            = City;
        cEMail           = EMail;
        cTelFixe         = TelFixe;
        cTelMobile       = TelMobile;
        cAncLastName     = AncLastName;
        cAncFirstName    = AncFirstName;
        cAncAdresse1     = AncAdresse1;
        cAncAdresse2     = AncAdresse2;
        cAncAdresse3     = AncAdresse3;
        cAncZipCode      = AncZipCode;
        cAncCity         = AncCity;
        cBirthDay_date   = BirthDay_date;
        cBirthDay_month  = BirthDay_month;
        cBirthDay_year   = BirthDay_year;
    }
    if (trim(cAncLastName.value) == '')
    {
        alert('Veuillez saisir votre ancien Nom svp.');
        cAncLastName.focus();
        return false;
    }
    else if (trim(cAncFirstName.value) == '')
    {
        alert('Veuillez saisir votre ancien Prénom svp.');
        cAncFirstName.focus();
        return false;
    }
/*
    else if (trim(cAncAdresse1.value) == '' && trim(cAncAdresse2.value) == '' && trim(cAncAdresse3.value) == '')
    {
        alert('Merci de renseigner un des 3 champs anciennes coordonnées:\n\n "APP,BAT,ETAG,RESID"\n\n "Numéro de voie et voie"\n\n ou "Lieu dit, localité supplémentaire, cedex"');
        cAncAdresse2.focus();
        return false;
    }
*/
    else if (trim(cAncZipCode.value) == '')
    {
        alert('Veuillez saisir votre ancien Code Postal svp.');
        cAncZipCode.focus();
        return false;
    }
    else if (cAncZipCode.value.length != '5')
    {
        alert('Veuillez saisir votre ancien Code Postal correctement : 5 caractères attendus.');
        cAncZipCode.focus();
        return false;
    }
    else if (trim(cAncCity.value) == '')
    {
        alert('Veuillez saisir votre ancienne Ville svp');
        cAncCity.focus();
        return false;
    }
    else if (trim(cLastName.value) == '')
    {
        alert('Veuillez saisir votre Nom svp.');
        cLastName.focus();
        return false;
    }
    else if (trim(cFirstName.value) == '')
    {
        alert('Veuillez saisir votre Prénom svp.');
        cFirstName.focus();
        return false;
    }
/*
    else if (trim(cAdresse1.value) == '' && trim(cAdresse2.value) == '' && trim(cAdresse3.value) == '')
    {
        alert('Merci de renseigner un des 3 champs suivants :\n\n "APP,BAT,ETAG,RESID"\n\n "Numéro de voie et voie"\n\n ou "Lieu dit, localité supplémentaire, cedex"');
        cAdresse1.focus();
        return false;
    }
*/
    else if (trim(cZipCode.value) == '')
    {
        alert('Veuillez saisir votre Code Postal svp.');
        cZipCode.focus();
        return false;
    }
    else if (cZipCode.value.length != '5')
    {
        alert('Veuillez saisir votre Code Postal correctement : 5 caractères attendus.');
        cZipCode.focus();
        return false;
    }
    else if (trim(cCity.value) == '')
    {
        alert('Veuillez saisir votre Ville svp');
        cCity.focus();
        return false;
    }
    else if (trim(cEMail.value) == '')
    {
        alert('Veuillez saisir votre Adresse Email svp.');
        cEMail.focus();
        return false;
    }
    else if (!isEmail(trim(cEMail.value)))
    {
        alert('Veuillez saisir votre Adresse Email correctement svp.');
        cEMail.focus();
        return false;
    }

/*  else if (cTelFixe.value == '' && cTelMobile.value == '')
    {
        alert('Veuillez saisir votre numéro de téléphone fixe ou mobile afin de pouvoir être recontacté.');
        cTelFixe.focus();
        return false;
    }
*/
    else if (cTelFixe.value != '')
    {
        if (cTelFixe.value.length != '10' && cTelFixe.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone fixe correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0123456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330123456789)');
        cTelFixe.focus();
        return false;}
    }
    else if (cTelMobile.value != '')
    {
        if (cTelMobile.value.length != '10' && cTelMobile.value.length != '12'){
        alert('Veuillez saisir votre n° de téléphone mobile correctement :\n\n pour un numéro en France, 10 caractères attendus (ex : 0623456789)\n\n pour un numéro international, 12 caractères attendus (ex: 330623456789)');
        cTelMobile.focus();
        return false;}
    }
    else if (trim(cBirthDay_date.value) != '' || trim(cBirthDay_month.value) != '' || trim(cBirthDay_year.value) != '')
    {
        var strSeperator = "/";
        var thisyear = new Date().getFullYear();
        cBirthDay = trim(cBirthDay_month.value)+strSeperator+trim(cBirthDay_date.value)+strSeperator+trim(cBirthDay_year.value);
        chkBirthDay=dateValid(cBirthDay);

        if (trim(cBirthDay_year.value) < '1880'){
           alert('La date de naissance indiquée est incorrecte Veuillez corriger votre année de naissance');
           cBirthDay_year.focus();
           return false;
        }
        else if (trim(cBirthDay_year.value) > thisyear){
           alert('La date de naissance indiquée est incorrecte Veuillez corriger votre année de naissance');
           cBirthDay_year.focus();
           return false;
        }
        else if (trim(cBirthDay_month.value) > '12'){
           alert('La date de naissance indiquée est incorrecte Veuillez corriger votre mois de naissance');
           cBirthDay_month.focus();
           return false;
        }
        else if (!chkBirthDay){
           alert('La date de naissance indiquée est incorrecte.');
           cBirthDay_date.focus();
           return false;
        }
    }
    else
    {
        cLastName.Value   = trim(cLastName.value.toUpperCase());
        cAdresse1         = trim(cAdresse1.value);
        cAdresse2         = trim(cAdresse2.value);
        cAdresse3         = trim(cAdresse3.value);
        cZipCode.value    = trim(cZipCode.value);
        cCity.value       = trim(cCity.value);
        cEMail.value      = trim(cEMail.value);
        cTelFixe          = trim(cTelFixe.value);
        cTelMobile        = trim(cTelMobile.value);
        cAncLastName      = trim(cAncLastName.value);
        cAncFirstName     = trim(cAncFirstName.value);
        cAncAdresse1      = trim(cAncAdresse1.value);
        cAncAdresse2      = trim(cAncAdresse2.value);
        cAncAdresse3      = trim(cAncAdresse3.value);
        cAncZipCode       = trim(cAncZipCode.value);
        cAncCity          = trim(cAncCity.value);
        if (trim(cBirthDay_date.value) != '' || trim(cBirthDay_month.value) != '' || trim(cBirthDay_year.value) != ''){
        cBirthDay_date    = trim(BirthDay_date.value);
        cBirthDay_month   = trim(BirthDay_month.value);
        cBirthDay_year    = trim(BirthDay_year.value);}
        return true;
    }
}

/* CHECK FORM ETAPE 2 */

var maximum = 255;

function fUpdCompteur() {
    var longueur = maximum - parseInt(document.msgform0.Commentaire.value.length);
    if (longueur <= 0){
        document.msgform0.compteur.value = 0;
        document.msgform0.Commentaire.value = document.msgform0.Commentaire.value.substring (0,maximum);
}
 else
        document.msgform0.compteur.value = longueur;
}

/* CHECK FORM PARTIE GLOBALE */

/*
Full Strip whitespace !
Input : a string  */

   function trim(str)
   {
     s = str.replace(/^(\s)*/, '');
     s = s.replace(/(\s)*$/, '');
     return s;
   }

/*
function trim(str) {
    return str.replace(/(^\s+)([^\s]*)(\s+$)/, '$2');
}
*/

/*
Strip whitespace from the beginning and end of a string
Input : a string

function trim(str)
{
    return str.replace(/^\s+|\s+$/g,'');
}
*/

/*
Check if a string is in valid email format. 
Returns true if valid, false otherwise.
*/
function isEmail(str)
{
    var regex = /^[+-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
    return regex.test(str);
}

/* Fonction pour affichage correct du prénom : 1ère lettre en MAJ et le reste en MIN*/
function capitalizeMe(obj) {
        val = trim(obj.value);
        newVal = '';
        newVal = val.substring(0,1).toUpperCase() + val.substring(1,val.length).toLowerCase();
        obj.value = newVal;
}

/*--------------------------------------- 
--== Fonction de validation de date ==-- 
-----------------------------------------*/ 
  
function dateValid(objName) {
var strDate; 
var strDateArray; 
var strDay; 
var strMonth; 
var strYear; 
var intday; 
var intMonth; 
var intYear; 
var booFound = false; 
var datefield = objName; 
var strSeparatorArray = new Array("-"," ","/","."); 
var intElementNr; 
var err = 0;
var strMonthArray = new Array(12); 
strMonthArray[0] = "Jan"; 
strMonthArray[1] = "Feb"; 
strMonthArray[2] = "Mar"; 
strMonthArray[3] = "Apr"; 
strMonthArray[4] = "May"; 
strMonthArray[5] = "Jun"; 
strMonthArray[6] = "Jul"; 
strMonthArray[7] = "Aug"; 
strMonthArray[8] = "Sep"; 
strMonthArray[9] = "Oct"; 
strMonthArray[10] = "Nov"; 
strMonthArray[11] = "Dec"; 
//strDate = datefield.value; 
strDate = objName; 
if (strDate.length < 1) { 
return true; 
} 
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) { 
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) { 
strDateArray = strDate.split(strSeparatorArray[intElementNr]); 
if (strDateArray.length != 3) { 
err = 1; 
return false; 
} 
else { 
strDay = strDateArray[0]; 
strMonth = strDateArray[1]; 
strYear = strDateArray[2]; 
} 
booFound = true; 
   } 
} 
if (booFound == false) { 
if (strDate.length>5) { 
strDay = strDate.substr(0, 2); 
strMonth = strDate.substr(2, 2); 
strYear = strDate.substr(4); 
   } 
} 
/* Adjustment for short years entered
if (strYear.length == 2) { 
strYear = '20' + strYear; 
} */
strTemp = strDay; 
strDay = strMonth; 
strMonth = strTemp; 
intday = parseInt(strDay, 10); 
if (isNaN(intday)) { 
err = 2; 
return false; 
} 
intMonth = parseInt(strMonth, 10); 
if (isNaN(intMonth)) { 
for (i = 0;i<12;i++) { 
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) { 
intMonth = i+1; 
strMonth = strMonthArray[i]; 
i = 12; 
   } 
} 
if (isNaN(intMonth)) { 
err = 3; 
return false; 
   } 
} 
intYear = parseInt(strYear, 10); 
if (isNaN(intYear)) { 
err = 4; 
return false; 
} 
if (intMonth>12 || intMonth<1) { 
err = 5; 
return false; 
} 
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) { 
err = 6; 
return false; 
} 
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) { 
err = 7; 
return false; 
} 
if (intMonth == 2) { 
if (intday < 1) { 
err = 8; 
return false; 
} 
if (LeapYear(intYear) == true) { 
if (intday > 29) { 
err = 9; 
return false; 
   } 
} 
else { 
if (intday > 28) { 
err = 10; 
return false; 
      } 
   } 
} 
return true; 
} 
function LeapYear(intYear) { 
if (intYear % 100 == 0) { 
if (intYear % 400 == 0) { return true; } 
} 
else { 
if ((intYear % 4) == 0) { return true; } 
} 
return false; 
} 
/*--== End Fonction de validation de date ==--*/ 


