﻿// Assurland car form javascript ressources

// UI element's ID(s) page 1
var car_rowInsuranceNeedDetailId;
var car_rowAddCarAgeId;
var car_rblAddCarAgeId;
var car_rblInsuranceNeedId;
var car_rblInsuranceNeedDetailId;

// UI element's ID(s) page 2
var car_rowChildBirthDateYear1Id;
var car_rowChildBirthDateYear2Id;
var car_rowChildBirthDateYear3Id;
var car_rowHaveChildId;
var car_rblHaveChild;
var car_rowChildBirthDateYearSepId;
var car_rowIsPreLicenseExperId;
var car_rowDrivLicenseCancelCauseId;
var car_rowDrivLicenseSuspDurationId;
var car_rblIsPreLicenseExper1Id;
var car_rblIsPreLicenseExper2Id;
var car_ddlDrivLicenseSuspDuration1Id;
var car_ddlDrivLicenseSuspDuration2Id;
var car_ddlDrivLicenseCancelCause1Id;
var car_ddlDrivLicenseCancelCause2Id;
var car_ddlDrivLicenseDate1Id;
var car_ddlDrivLicenseDate2Id;
var car_ddlMaritalStatus2Id;
var car_ddlOccupationCode2Id;
var car_rowCnsBirthDateId;
var car_rowCnsHasDrivLicenseId;
var car_rowCnsDrivLicenseDateId;
var car_rowCnsIsFirstDrivOtherCarId;
var car_rblCnsIsFirstDrivOtherCarId;
var car_rblCnsHasDrivLicenseId;
var car_ddlCnsDrivLicenseDateId;
var car_ddlCnsDrivLicenseDateYearId;  
var car_dtbCNSBirthDateId;
var car_rblCnsHasDrivLicenseId;
var car_dtbBirthDate1Id;
var car_ddlDrivLicenseDateYear1Id;
var car_dtbBirthDate2Id;
var car_ddlDrivLicenseDateYear2Id;

var car_applicantCount;
var car_otherDriverType;
var car_drivLicenseSusp1;
var car_drivLicenseSusp2;

// UI element's ID(s) page 3
var car_rowJobCityId;
var car_ddlJobCityId;
var car_txtJobCityId;
var car_firstCarDrivingDateId;
var car_ddlFirstCarDrivingDateYearId;
var car_purchaseDateId;
var car_ddlPurchaseDateYearId;

var car_occupationCode;

// UI element's ID(s) page 4
var car_ddlInsuranceYearnb1Id;
var car_lblInsuranceYearnb1Id;
var car_ddlContrCancelL1Id;
var car_rblIsFirstDrivOtherCar1Id;
var car_ddlDisasterLast3Year1Id;
var car_ddlBonusCoeff1Id;
var car_ddlLastFaultDate1DropDownListMonthId;
var car_ddlLastFaultDate1DropDownListYearId;
var car_ddlMeasuringApparatus1Id;
var car_ddlAlcoholBloodRate1Id;
var car_rblLastFaultCirconstance1Id;
var car_ddlFaultNb1Id;
var car_rblIsNotContrStillRunning1Id;
var car_ddlIsRunningAway1Id;
var car_rblIsDrugsPositive1Id;
var car_ddlDUI1Id;
var car_ddlPrimaryDisasterType1Id;
var car_dtbPrimaryDisasterDate1Id;
var car_lblPrimaryDisasterDate1Id;
var car_ddlPrimaryListDrive1Id;
var car_ddlPrimaryDisasterType2Id;
var car_dtbPrimaryDisasterDate2Id;
var car_lblPrimaryDisasterDate2Id;
var car_ddlPrimaryListDrive2Id;
var car_ddlPrimaryDisasterType3Id;
var car_dtbPrimaryDisasterDate3Id;
var car_lblPrimaryDisasterDate3Id;
var car_ddlPrimaryListDrive3Id;
var car_ddlPrimaryDisasterType4Id;
var car_dtbPrimaryDisasterDate4Id;
var car_lblPrimaryDisasterDate4Id;
var car_ddlPrimaryListDrive4Id;
var car_ddlPrimaryDisasterType5Id;
var car_dtbPrimaryDisasterDate5Id;
var car_lblPrimaryDisasterDate5Id;
var car_ddlPrimaryListDrive5Id;
var car_rblLastCorpDisasterCirconstance1Id;
var car_ddlLastCorpDisasterPursuite1Id;
var car_rblLastCorpDisasterPrisonCondemnation1Id;
var car_rblCurrentGuaranteeCodeId;
var car_ddlCurrentCarrierId;
var car_ddlContractAnniverMthId;
var car_ddlContrNotRunningSinceId;
var car_ddlHomeAddressTypeId;
var car_ddlLastFaultDate1Id;
var car_ddlLastFaultDate2Id;
var car_ddlInsuranceYearnb2Id;
var car_lblInsuranceYearnb2Id;
var car_ddlContrCancelL2Id;
var car_rblIsFirstDrivOtherCar2Id;
var car_ddlDisasterLast3Year2Id;
var car_ddlBonusCoeff2Id;
var car_ddlLastFaultDate2DropDownListMonthId;
var car_ddlLastFaultDate2DropDownListYearId;
var car_ddlMeasuringApparatus2Id;
var car_ddlAlcoholBloodRate2Id;
var car_rblLastFaultCirconstance2Id;
var car_ddlFaultNb2Id;
var car_rblIsNotContrStillRunning2Id;
var car_ddlIsRunningAway2Id;
var car_rblIsDrugsPositive2Id;
var car_ddlDUI2Id;
var car_ddlSecondaryDisasterType1Id;
var car_dtbSecondaryDisasterDate1Id;
var car_lblSecondaryDisasterDate1Id;
var car_ddlSecondaryListDrive1Id;
var car_ddlSecondaryDisasterType2Id;
var car_dtbSecondaryDisasterDate2Id;
var car_lblSecondaryDisasterDate2Id;
var car_ddlSecondaryListDrive2Id;
var car_ddlSecondaryDisasterType3Id;
var car_dtbSecondaryDisasterDate3Id;
var car_lblSecondaryDisasterDate3Id;
var car_ddlSecondaryListDrive3Id;
var car_ddlSecondaryDisasterType4Id;
var car_dtbSecondaryDisasterDate4Id;
var car_lblSecondaryDisasterDate4Id;
var car_ddlSecondaryListDrive4Id;
var car_ddlSecondaryDisasterType5Id;
var car_dtbSecondaryDisasterDate5Id;
var car_lblSecondaryDisasterDate5Id;
var car_ddlSecondaryListDrive5Id;
var car_rblLastCorpDisasterCirconstance2Id;
var car_ddlLastCorpDisasterPursuite2Id;
var car_rblLastCorpDisasterPrisonCondemnation2Id;
var car_dtbQuotationEffectiveDateId;

var car_rowInsuranceYearnbId;
var car_rowContrCancelLId;
var car_rowIsFirstDrivOtherCarId;
var car_rowDisasterLast3YearId;
var car_rowBonusCoeffId;
var car_rowCarOwningTimeId;
var car_rowQuotationEffectiveDateId;
var car_rowCarTypeValueId;
var car_rowCurrentGuaranteeCodeId;
var car_rowCurrentCarrierId;
var car_rowContractAnniverMthId;
var car_rowContrNotRunningSinceId;
var car_rowAlcoholRegionId;
var car_rowHomeAddressTypeId;
var car_rowLastFaultDateId;
var car_rowMeasuringApparatusId;
var car_rowAlcoholBloodRateId;
var car_rowLastFaultCirconstanceId;
var car_rowFaultNbId;
var car_rowIsContrStillRunningId;
var car_rowIsRunningAwayId;
var car_rowIsDrugsPositiveId;
var car_rowDUIId;
var car_rowDisasterType1Id;
var car_rowDisasterDate1Id;
var car_rowListDrive1Id;
var car_rowDisasterType2Id;
var car_rowDisasterDate2Id;
var car_rowListDrive2Id;
var car_rowDisasterType3Id;
var car_rowDisasterDate3Id;
var car_rowListDrive3Id;
var car_rowDisasterType4Id;
var car_rowDisasterDate4Id;
var car_rowListDrive4Id;
var car_rowDisasterType5Id;
var car_rowDisasterDate5Id;
var car_rowListDrive5Id;
var car_rowLastCorpDisasterPursuiteId;
var car_rowLastCorpDisasterCirconstanceId;
var car_rowLastCorpDisasterPrisonCondemnationId;
var car_rowLastCorpDisasterTitleId;
var car_rowDisasterTitleId;
var car_rowInsuranceYearnbHelpId;
var car_row3YearsSepId;
var car_rowAlcoholRegionSepId;
var car_rowDisasterTitleSepId;
var car_rowLastCorpDisasterSepId;
var car_rowPreviousInsuranceDetailSepId;
var car_rowInsuranceSepId;
var car_row3YearsTitleId;

var car_primaryApplicantDrivLicenseSusp = "";
var car_secondaryApplicantDrivLicenseSusp;
var car_insuranceNeed;
var car_hasBeenInsured1;
var car_hasBeenInsured2;
var car_lblContractAnniverMthId;

/////////////////
// Page 1
/////////////////

function car_updateInsuranceNeed(value)
{
    if (value == 1) 
    {
        setRowVisibility(car_rowAddCarAgeId, false);   
        radioButtonList_clearError(car_rblInsuranceNeedId);         
        setRowVisibility(car_rowInsuranceNeedDetailId, false);        
        dropDownList_clearError(car_rblInsuranceNeedDetailId);   
    }
    else{
        setRowVisibility(car_rowAddCarAgeId, true);
        setRowVisibility(car_rowInsuranceNeedDetailId, true);
    }
}

/////////////////
// Page 2
/////////////////
//DEFAULT VALUE LICENSE DATE
function car_vdDrivLicenseDate1()
{
    var dLicenseDate = dateDropDownList_getDate(car_ddlDrivLicenseDate1Id);
    if (dLicenseDate==null)
    {
        var dBirthDate = getDateByFormat($get(car_dtbBirthDate1Id).value, 'dd/MM/yyyy');
        if (isValidDate(dBirthDate)) {                
            var dBirthDateMonth = dBirthDate.getMonth();
            var dBirthDateYear = dBirthDate.getFullYear() + 18;
            dBirthDate = new Date(dBirthDateYear, dBirthDateMonth, 1);
            dateDropDownList_setDate(car_ddlDrivLicenseDate1Id,dBirthDate);
        }
    }
}
function car_vdDrivLicenseDate2()
{
    var dLicenseDate = dateDropDownList_getDate(car_ddlDrivLicenseDate2Id);
    if (dLicenseDate==null)
    {
        var dBirthDate = getDateByFormat($get(car_dtbBirthDate2Id).value, 'dd/MM/yyyy');
        if (isValidDate(dBirthDate)) {                
            var dBirthDateMonth = dBirthDate.getMonth();
            var dBirthDateYear = dBirthDate.getFullYear() + 18;
            dBirthDate = new Date(dBirthDateYear, dBirthDateMonth, 1);
            dateDropDownList_setDate(car_ddlDrivLicenseDate2Id,dBirthDate);
        }
    }
}
//error value page 2
//license date
function car_errorDrivLicenseDate1(sender) {
    var dLicenseDate = dateDropDownList_getDate(car_ddlDrivLicenseDate1Id);
    var dNow = new Date();
    if (isValidDate(dLicenseDate)) {       
        if (dLicenseDate > dNow) {
            return "Veuillez saisir une date de permis de conduire antérieure à la date du jour.";
        }
        else {            
            var dBirthDate = getDateByFormat($get(car_dtbBirthDate1Id).value, 'dd/MM/yyyy');
            if (isValidDate(dBirthDate)) {                
                var dBirthDateMonth = dBirthDate.getMonth();
                var dBirthDateYear = dBirthDate.getFullYear() + 18;                
                
                dBirthDate = new Date(dBirthDateYear, dBirthDateMonth, 1);
               if (dLicenseDate < dBirthDate) {
                    return "Le permis de conduire ne peut pas être obtenu avant l'âge de 18 ans.<br />Etes-vous certain de ne pas vous être trompé dans la saisie de la date de naissance ou de la date d'obtention du permis de conduire ?";
                }
             }
        }
    }
    return "";
}

function car_errorDrivLicenseDate2(sender) {
    var dLicenseDate = dateDropDownList_getDate(car_ddlDrivLicenseDate2Id);
    var dNow = new Date();
    if (dLicenseDate != "NaN" && dLicenseDate != "Invalid Date") {
        if (dLicenseDate > dNow) {
            return "Veuillez saisir une date de permis de conduire antérieure à la date du jour.";
        }
        else {
            var dBirthDate = getDateByFormat($get(car_dtbBirthDate2Id).value, 'dd/MM/yyyy');
            if (isValidDate(dBirthDate)) {
                var dBirthDateMonth = dBirthDate.getMonth() - 1;
                var dBirthDateYear = dBirthDate.getFullYear() + 18;
                if (dBirthDateMonth < 0) {
                    dBirthDateMonth = 11;
                    dBirthDateYear -= 1;
                }
                dBirthDate = new Date(dBirthDateYear, dBirthDateMonth, 1);
                if (dLicenseDate < dBirthDate) {
                    return "Le permis de conduire ne peut pas être obtenu avant l'âge de 18 ans.<br />Etes-vous certain de ne pas vous être trompé dans la saisie de la date de naissance ou de la date d'obtention du permis de conduire ?";
                }
            }
        }
    }
    return "";
}
function car_errorDrivLicenseDateCNS(sender) {
    var dLicenseDate = dateDropDownList_getDate(car_ddlCnsDrivLicenseDateId);
    var dNow = new Date();
    if (isValidDate(dLicenseDate)) {
        if (dLicenseDate > dNow) {
            return "Veuillez saisir une date de permis de conduire antérieure à la date du jour.";
        }
        else {
            var dBirthDate = getDateByFormat($get(car_dtbCNSBirthDateId).value, 'dd/MM/yyyy');
            if (isValidDate(dBirthDate)) {
                var dBirthDateMonth = dBirthDate.getMonth() - 1;
                var dBirthDateYear = dBirthDate.getFullYear() + 18;
                if (dBirthDateMonth < 0) {
                    dBirthDateMonth = 11;
                    dBirthDateYear -= 1;
                }
                dBirthDate = new Date(dBirthDateYear, dBirthDateMonth, 1);
                if (dLicenseDate < dBirthDate) {
                    return "Le permis de conduire ne peut pas être obtenu avant l'âge de 18 ans.<br />Etes-vous certain de ne pas vous être trompé dans la saisie de la date de naissance ou de la date d'obtention du permis de conduire ?";
                }
            }
        }
    }
    return "";
}
//default value page 2
//marié fonctionnaire
function car_dvMaritalStatus1(value)
{
    if (car_otherDriverType == 1 )
    {
        if (value=="F")
        {
            if ($get(car_ddlMaritalStatus2Id).value =="")
                $get(car_ddlMaritalStatus2Id).value="N";
            if ($get(car_ddlOccupationCode2Id).value =="")    
                $get(car_ddlOccupationCode2Id).value="01";
        }
        else
        {
            if ($get(car_ddlMaritalStatus2Id).value =="")
                $get(car_ddlMaritalStatus2Id).value=value;
        }

    }
}
//rules page 2
function car_childrenQuestion(value)
{
    var dTmp=getDateByFormat(value,'dd/MM/yyyy');
    
    if (isValidDate(dTmp))
        if (calcul_age(dTmp) > 35) {
            setRowVisibility(car_rowHaveChildId, true);
            setRowVisibility(car_rowChildBirthDateYearSepId, true);
            car_updateHaveChild(car_rblHaveChild);
    }
    else {
        setRowVisibility(car_rowHaveChildId, false);
        setRowVisibility(car_rowChildBirthDateYear1Id, false);
        setRowVisibility(car_rowChildBirthDateYear2Id, false);
        setRowVisibility(car_rowChildBirthDateYear3Id, false);
        setRowVisibility(car_rowChildBirthDateYearSepId, false);
    }
}

function car_updateHaveChild(value)
{
    car_rblHaveChild=value;
    if (value==1)
    {
        setRowVisibility(car_rowChildBirthDateYear1Id, true);
        setRowVisibility(car_rowChildBirthDateYear2Id, true);
        setRowVisibility(car_rowChildBirthDateYear3Id, true);
    }
    else
    {
        setRowVisibility(car_rowChildBirthDateYear1Id, false);
        setRowVisibility(car_rowChildBirthDateYear2Id, false);
        setRowVisibility(car_rowChildBirthDateYear3Id, false);
    }
}

function car_AACQuestion()
  { 
    var ACCreateDate = new Date(1990,11,1);    
    var DrivLicenseDate1=dateDropDownList_getDate(car_ddlDrivLicenseDate1Id);
    var DrivLicenseDate2=dateDropDownList_getDate(car_ddlDrivLicenseDate2Id);;
    if (DrivLicenseDate1>ACCreateDate || (car_applicantCount == 2 && DrivLicenseDate2>ACCreateDate))
    {       setRowVisibility(car_rowIsPreLicenseExperId, true);
            if (DrivLicenseDate1>ACCreateDate)
            {   //hide question for applicant 1
                radioButtonList_show(car_rblIsPreLicenseExper1Id);
            }
            else
            {
                radioButtonList_hide(car_rblIsPreLicenseExper1Id);                
                radioButtonList_clearError(car_rblIsPreLicenseExper1Id); 
            }
            if (car_applicantCount == 2 && DrivLicenseDate2>ACCreateDate)
            {   //hide question for applicant 2
                 radioButtonList_show(car_rblIsPreLicenseExper2Id);
            }
            else
                if (car_applicantCount == 2)
                {    radioButtonList_hide(car_rblIsPreLicenseExper2Id);
                     radioButtonList_clearError(car_rblIsPreLicenseExper2Id);    
                }
     }
     else
            setRowVisibility(car_rowIsPreLicenseExperId, false);
            radioButtonList_clearError(car_rblIsPreLicenseExper1Id); 
            radioButtonList_clearError(car_rblIsPreLicenseExper2Id);          
      
  }
function car_updateDrivLicenseSusp1(value)
{
    car_drivLicenseSusp1=value;
    car_drivLicenseSusp();
}
function car_updateDrivLicenseSusp2(value)
{
    car_drivLicenseSusp2=value;
    car_drivLicenseSusp();
}
function car_drivLicenseSusp()
{
    if (car_drivLicenseSusp1 == "3" ||  (car_applicantCount == 2 && car_drivLicenseSusp2 == "3"))
    { 
        setRowVisibility(car_rowDrivLicenseCancelCauseId,true);       
        if (car_drivLicenseSusp1 == "3")
            dropDownList_show(car_ddlDrivLicenseCancelCause1Id);
        else
        {
            dropDownList_hide(car_ddlDrivLicenseCancelCause1Id);
            dropDownList_clearError(car_ddlDrivLicenseCancelCause1Id);   
        }
        if (car_applicantCount == 2)
            if (car_drivLicenseSusp2 == "3")
                dropDownList_show(car_ddlDrivLicenseCancelCause2Id);
            else
            {    dropDownList_hide(car_ddlDrivLicenseCancelCause2Id);
                dropDownList_clearError(car_ddlDrivLicenseCancelCause2Id);
            }
    }
    else
    {
        setRowVisibility(car_rowDrivLicenseCancelCauseId,false);
        dropDownList_clearError(car_ddlDrivLicenseCancelCause1Id);
        dropDownList_clearError(car_ddlDrivLicenseCancelCause2Id);
        setRowVisibility(car_rowDrivLicenseSuspDurationId, false);
        dropDownList_clearError(car_ddlDrivLicenseSuspDuration1Id);
        dropDownList_clearError(car_ddlDrivLicenseSuspDuration2Id);
    }   
    
    if (car_drivLicenseSusp1 == "1" || car_drivLicenseSusp1 == "4" ||
               (car_applicantCount == 2 && (car_drivLicenseSusp2 == "1" || car_drivLicenseSusp2 == "4")))
    {       setRowVisibility(car_rowDrivLicenseSuspDurationId,true );
        if (car_drivLicenseSusp1 == "1" || car_drivLicenseSusp1 == "4") {
            dropDownList_show(car_ddlDrivLicenseSuspDuration1Id);
        }
        else {
            dropDownList_hide(car_ddlDrivLicenseSuspDuration1Id);
            dropDownList_clearError(car_ddlDrivLicenseSuspDuration1Id);
        }
           if (car_applicantCount == 2)
            if (car_drivLicenseSusp2 == "1" || car_drivLicenseSusp2 == "4")
               { dropDownList_show(car_ddlDrivLicenseSuspDuration2Id);
                 }
            else 
            {                
                dropDownList_hide(car_ddlDrivLicenseSuspDuration2Id);
                dropDownList_clearError(car_ddlDrivLicenseSuspDuration2Id);
            }  
     }           
    else
    {
      setRowVisibility(car_rowDrivLicenseSuspDurationId, false);
      dropDownList_clearError(car_ddlDrivLicenseSuspDuration1Id);
      dropDownList_clearError(car_ddlDrivLicenseSuspDuration2Id);
    }
}

function car_cnsQuestion(value)
{
    if (car_applicantCount == 1 && (value == "N" || value == "F"  || value == "B"  || value == "P"))
    {
        setRowVisibility(car_rowCnsBirthDateId, true);
        setRowVisibility(car_rowCnsHasDrivLicenseId, true);  
        
        if (radioButtonList_getSelectedValue(car_rblCnsHasDrivLicenseId)=="1")
        {
            setRowVisibility(car_rowCnsDrivLicenseDateId, true);
            
            setRowVisibility(car_rowCnsIsFirstDrivOtherCarId, true);  
        }
        else
        {   setRowVisibility(car_rowCnsDrivLicenseDateId, false);
            dateDropDownList_clearError(car_ddlCnsDrivLicenseDateId);  
            setRowVisibility(car_rowCnsIsFirstDrivOtherCarId, false); 
            radioButtonList_clearError(car_rblCnsIsFirstDrivOtherCarId); 
        }
    }
    else
    {
        setRowVisibility(car_rowCnsDrivLicenseDateId, false);
        dateDropDownList_clearError(car_ddlCnsDrivLicenseDateId);
        setRowVisibility(car_rowCnsBirthDateId, false);
        textBox_clearError(car_dtbCNSBirthDateId);
        setRowVisibility(car_rowCnsHasDrivLicenseId, false);
        radioButtonList_clearError(car_rblCnsHasDrivLicenseId);
        setRowVisibility(car_rowCnsIsFirstDrivOtherCarId, false); 
        dateDropDownList_clearError(car_rblCnsIsFirstDrivOtherCarId);      
    }
}

function car_cnsDrivLicenseDate(value)
{
    if (value=="1")
    {
        setRowVisibility(car_rowCnsDrivLicenseDateId, true);
        setRowVisibility(car_rowCnsIsFirstDrivOtherCarId, true);  
    }
    else
    {
         setRowVisibility(car_rowCnsDrivLicenseDateId, false);
         dateDropDownList_clearError(car_ddlCnsDrivLicenseDateId);
         setRowVisibility(car_rowCnsIsFirstDrivOtherCarId, false); 
         dateDropDownList_clearError(car_rblCnsIsFirstDrivOtherCarId);     
    }

}

/////////////////
// Page 3
/////////////////

function car_usageCode(value) {
    if (value > 1) {
        setRowVisibility(car_rowJobCityId, true);
    }
    else {
        dropDownList_clearError(car_ddlJobCityId);
        textBox_clearError(car_txtJobCityId);
        setRowVisibility(car_rowJobCityId, false);
    }
}
function car_warningPurchaseDatePrev(sender) {
    var v = getDateByFormat(sender.value, 'dd/MM/yyyy');   
    if (v != null && v != "") {        
        if ((new Date) >= v) {
            return "Cette date ne semble pas correcte. Vous avez déclaré sur la 1ère page que vous étiez en train d'acheter une voiture.   Merci de la corriger.";            
        }
    }
    return "";
}

function car_warningPurchaseDate(sender) {
    var v = dateDropDownList_getDate(car_purchaseDateId);   
    if (v != null && v != "") {        
        if (v >= (new Date)) {
            return "Cette date ne semble pas correcte. Vous avez déclaré sur la 1ère page que vous possédiez la voiture. Merci de la corriger.";            
        }
    }
    return "";
}

function car_warningOccupationCode(sender) {
    
    if (sender.value != "1") {
        if (car_occupationCode == "08") {
            if (sender.value == "4")
                return "Etes-vous certain de ne pas vous être trompé dans la saisie de l'usage du véhicule ou de la catégorie professionnelle ? <br />Si le conducteur est bien ETUDIANT, cette profession est incompatible avec un usage TOURNEES REGULIERES.";
            else
                if (sender.value == "3")
                return "Etes-vous certain de ne pas vous être trompé dans la saisie de l'usage du véhicule ou de la catégorie professionnelle ? <br />Si le conducteur est bien ETUDIANT, cette profession est incompatible avec un usage PRIVE ET PROFESSIONNEL.";
        }
        else {
            if (car_occupationCode == "09") {                
                return "Etes-vous certain de ne pas vous être trompé dans la saisie de l'usage du véhicule ou de la catégorie professionnelle ? <br />Si le conducteur est bien RETRAITE, cette profession est incompatible avec un autre usage que Privé.";
            }
            else
                if (car_occupationCode == "20")
                return "Etes-vous certain de ne pas vous être trompé dans la saisie de l'usage du véhicule ou de la catégorie professionnelle ? <br />Si le conducteur est à la recherche d'un emploi, cette profession est incompatible avec un autre usage que Privé.";
            else
                if (car_occupationCode == "12")
                return "Etes-vous certain de ne pas vous être trompé dans la saisie de l'usage du véhicule ou de la catégorie professionnelle ? <br />Si le conducteur est bien SANS PROFESSION, cette profession est incompatible avec un autre usage que Privé.";
        }
    }
    else {
        if (car_occupationCode == "08")
            return "Vous avez déclaré être ETUDIANT et utiliser votre véhicule en usage PRIVE. <br />Si vous utilisez votre véhicule pour vous rendre sur votre lieu d'étude ou sur un lieu professionnel, <br />vous devez répondre que l'usage de votre véhicule est PRIVE ET TRAJET TRAVAIL.";

    }
    return "";
}

function car_errorFirstCarDrivingDate1(sender) {
    var purchaseDate = dateDropDownList_getDate(car_purchaseDateId);
    var firstCarDrivingDate = dateDropDownList_getDate(car_firstCarDrivingDateId);
    if (firstCarDrivingDate > purchaseDate) {
        return "La date de 1ère mise en circulation ne peut être posterieure à la date d'achat du véhicule.";
    }
    return "";
}

function car_errorFirstCarDrivingDate2(sender) {
    var firstCarDrivingDate = dateDropDownList_getDate(car_firstCarDrivingDateId);
    if (firstCarDrivingDate > getTodayDate()) {
        return "La date de 1ère mise en circulation ne peut être posterieure à la date du jour.";
    }
    return "";
}

/////////////////
// Page 4
/////////////////
   
function car_updateHasBeenInsured1(value)
{
    car_hasBeenInsured1 = value;
    // Reset warning
    textBox_onUpdate($get(car_dtbQuotationEffectiveDateId));
    car_hasBeenInsured();
}

function car_updateHasBeenInsured2(value)
{
    car_hasBeenInsured2=value;
    car_hasBeenInsured();
}

function car_hasBeenInsured()
{
 if (car_hasBeenInsured1 != "N" || (car_applicantCount == 2 && car_hasBeenInsured2 != "N"))
 {          
    setRowVisibility(car_rowInsuranceYearnbId, true);
    setRowVisibility(car_rowContrCancelLId, true);
    setRowVisibility(car_rowIsFirstDrivOtherCarId, true);
    setRowVisibility(car_rowDisasterLast3YearId, true);
    setRowVisibility(car_row3YearsTitleId, true);
    setRowVisibility(car_row3YearsSepId, true);
    setRowVisibility(car_rowBonusCoeffId, true);
    if (car_hasBeenInsured1 == "N") {
       dropDownList_hide(car_ddlInsuranceYearnb1Id);
       dropDownList_hide(car_ddlContrCancelL1Id);
       hide(car_lblInsuranceYearnb1Id);
       radioButtonList_hide(car_rblIsFirstDrivOtherCar1Id);
       dropDownList_hide(car_ddlDisasterLast3Year1Id);
       dropDownList_hide(car_ddlBonusCoeff1Id);
       setRowVisibility(car_rowCurrentGuaranteeCodeId, false);
       dropDownList_clearError(car_rblCurrentGuaranteeCodeId);
       setRowVisibility(car_rowCurrentCarrierId, false);
       dropDownList_clearError(car_ddlCurrentCarrierId);
       setRowVisibility(car_rowContractAnniverMthId, false);
       dropDownList_clearError(car_ddlContractAnniverMthId); 
       setRowVisibility(car_rowContrNotRunningSinceId, false);
       dropDownList_clearError(car_ddlContrNotRunningSinceId); 
       setInnerHtml(car_lblContractAnniverMthId,"Quel est le mois d'échéance de votre contrat actuel ?");
    }
    else {
        dropDownList_show(car_ddlInsuranceYearnb1Id);
        dropDownList_show(car_ddlContrCancelL1Id);
        show(car_lblInsuranceYearnb1Id);
        radioButtonList_show(car_rblIsFirstDrivOtherCar1Id);
        dropDownList_show(car_ddlDisasterLast3Year1Id);
        dropDownList_show(car_ddlBonusCoeff1Id);
        if (car_insuranceNeed == 1)
            setRowVisibility(car_rowCurrentGuaranteeCodeId, true);
        else
        {
            setRowVisibility(car_rowCurrentGuaranteeCodeId, false);
            dropDownList_clearError(car_rblCurrentGuaranteeCodeId);
        }
        setRowVisibility(car_rowCurrentCarrierId, true);
        setRowVisibility(car_rowContractAnniverMthId, true);
    }
    if (car_applicantCount == 2){
        if (car_hasBeenInsured2 == "N")
        {
            dropDownList_hide(car_ddlInsuranceYearnb2Id);
            hide(car_lblInsuranceYearnb2Id);
            dropDownList_hide(car_ddlContrCancelL2Id);
            radioButtonList_hide(car_rblIsFirstDrivOtherCar2Id);
            dropDownList_hide(car_ddlDisasterLast3Year2Id);
            dropDownList_hide(car_ddlBonusCoeff2Id);
        }
        else
        {
            dropDownList_show(car_ddlInsuranceYearnb2Id);
            show(car_lblInsuranceYearnb2Id);
            dropDownList_show(car_ddlContrCancelL2Id);
            radioButtonList_show(car_rblIsFirstDrivOtherCar2Id);
            dropDownList_show(car_ddlDisasterLast3Year2Id);
            dropDownList_show(car_ddlBonusCoeff2Id);               
        }
    }
 }
 else
 {
    setRowVisibility(car_rowInsuranceYearnbId, false);
    dropDownList_clearError(car_ddlInsuranceYearnb1Id);
    dropDownList_clearError(car_ddlInsuranceYearnb2Id);
    hide(car_lblInsuranceYearnb1Id);
    hide(car_lblInsuranceYearnb2Id);
    setRowVisibility(car_rowContrCancelLId, false);
    dropDownList_clearError(car_ddlContrCancelL1Id);
    dropDownList_clearError(car_ddlContrCancelL2Id);
    setRowVisibility(car_rowIsFirstDrivOtherCarId, false);
    radioButtonList_clearError(car_rblIsFirstDrivOtherCar1Id);
    radioButtonList_clearError(car_rblIsFirstDrivOtherCar2Id);
    setRowVisibility(car_row3YearsTitleId, false);
    setRowVisibility(car_row3YearsSepId, false);
    setRowVisibility(car_rowDisasterLast3YearId, false);
    dropDownList_clearError(car_ddlDisasterLast3Year1Id);
    dropDownList_clearError(car_ddlDisasterLast3Year2Id);
    setRowVisibility(car_rowBonusCoeffId, false);
    dropDownList_clearError(car_ddlBonusCoeff1Id);
    dropDownList_clearError(car_ddlBonusCoeff2Id);
    setRowVisibility(car_rowCurrentGuaranteeCodeId, false);
    dropDownList_clearError(car_rblCurrentGuaranteeCodeId);
    setRowVisibility(car_rowCurrentCarrierId, false);
    dropDownList_clearError(car_ddlCurrentCarrierId);
    setRowVisibility(car_rowContractAnniverMthId, false);
    dropDownList_clearError(car_ddlContractAnniverMthId);
    car_insuranceYearNbHelp();
 }
 car_disasterControlVisibility();

 if (isRowVisible(car_rowCarOwningTimeId) || isRowVisible(car_rowCurrentGuaranteeCodeId) || isRowVisible(car_rowCurrentCarrierId)
    || isRowVisible(car_rowContractAnniverMthId) || isRowVisible(car_rowQuotationEffectiveDateId) || isRowVisible(car_rowCarTypeValueId)) {
     setRowVisibility(car_rowInsuranceSepId, true);  
    }
    else {
     setRowVisibility(car_rowInsuranceSepId, false);  
    }
}

function car_disasterControlVisibility() {
    if ((car_hasBeenInsured1 != "N" && ($get(car_ddlContrCancelL1Id).value != "N" || car_primaryApplicantDrivLicenseSusp == "1" || car_primaryApplicantDrivLicenseSusp == "3" || car_primaryApplicantDrivLicenseSusp == "4" || getBonusFromForm($get(car_ddlBonusCoeff1Id).value * 1.0) > 1.18 || car_hasSeriousSinistre(1)))
     || (car_applicantCount == 2 && car_hasBeenInsured2 != "N" && ($get(car_ddlContrCancelL2Id).value != "N" || car_secondaryApplicantDrivLicenseSusp == "1" || car_secondaryApplicantDrivLicenseSusp == "3" || car_secondaryApplicantDrivLicenseSusp == "4" || getBonusFromForm($get(car_ddlBonusCoeff2Id).value * 1.0) > 1.18 || car_hasSeriousSinistre(2))))
    {//les lignes sont affichés
        setRowVisibility(car_rowPreviousInsuranceDetailSepId, true);
        setRowVisibility(car_rowIsContrStillRunningId, true);
        setRowVisibility(car_rowIsRunningAwayId, true);
        setRowVisibility(car_rowIsDrugsPositiveId, true);
        setRowVisibility(car_rowDUIId, true);
        //applicant 1
        if (car_hasBeenInsured1 != "N" && ($get(car_ddlContrCancelL1Id).value != "N" || car_primaryApplicantDrivLicenseSusp == "1" || car_primaryApplicantDrivLicenseSusp == "3" || car_primaryApplicantDrivLicenseSusp == "4" || getBonusFromForm($get(car_ddlBonusCoeff1Id).value * 1.0) > 1.18 || car_hasSeriousSinistre(1)))      
        {
            setRowVisibility(car_rowHomeAddressTypeId, true);         
            radioButtonList_show(car_rblIsNotContrStillRunning1Id);                
            dropDownList_show(car_ddlIsRunningAway1Id);           
            radioButtonList_show(car_rblIsDrugsPositive1Id);
            dropDownList_show(car_ddlDUI1Id);
            
            if (radioButtonList_getSelectedValue(car_rblIsNotContrStillRunning1Id) == "1" && car_insuranceNeed != 4)
            {
                setRowVisibility(car_rowContrNotRunningSinceId, true);
                //change le libellé
                setInnerHtml(car_lblContractAnniverMthId,"Quel est le mois d'échéance de votre ancien contrat ?");
            }
            else
            {
                setRowVisibility(car_rowContrNotRunningSinceId, false);
                dropDownList_clearError(car_ddlContrNotRunningSinceId);
                setInnerHtml(car_lblContractAnniverMthId,"Quel est le mois d'échéance de votre contrat actuel ?");
            }
        }
        else
        {
            setRowVisibility(car_rowHomeAddressTypeId, false);
            dropDownList_clearError(car_ddlHomeAddressTypeId);          
            radioButtonList_hide(car_rblIsNotContrStillRunning1Id);                
            dropDownList_hide(car_ddlIsRunningAway1Id);           
            radioButtonList_hide(car_rblIsDrugsPositive1Id);            
            dropDownList_hide(car_ddlDUI1Id); 
            setRowVisibility(car_rowContrNotRunningSinceId, false);
            dropDownList_clearError(car_ddlContrNotRunningSinceId);
            setInnerHtml(car_lblContractAnniverMthId,"Quel est le mois d'échéance de votre contrat actuel ?");
        }
        //applicant2
        if (car_applicantCount == 2)
            if (car_hasBeenInsured2 != "N" && ($get(car_ddlContrCancelL2Id).value != "N" || car_secondaryApplicantDrivLicenseSusp == "1" || car_secondaryApplicantDrivLicenseSusp == "3" || car_secondaryApplicantDrivLicenseSusp == "4" || getBonusFromForm($get(car_ddlBonusCoeff2Id).value * 1.0) > 1.18 || car_hasSeriousSinistre(2)))
        {
            radioButtonList_show(car_rblIsNotContrStillRunning2Id);                
            dropDownList_show(car_ddlIsRunningAway2Id);           
            radioButtonList_show(car_rblIsDrugsPositive2Id);            
            dropDownList_show(car_ddlDUI2Id);         
        }
        else
        {
            radioButtonList_hide(car_rblIsNotContrStillRunning2Id);                
            dropDownList_hide(car_ddlIsRunningAway2Id);           
            radioButtonList_hide(car_rblIsDrugsPositive2Id);            
            dropDownList_hide(car_ddlDUI2Id); 
        }  
    }
    else {
        setRowVisibility(car_rowPreviousInsuranceDetailSepId, false);
        setRowVisibility(car_rowHomeAddressTypeId, false);
        dropDownList_clearError(car_ddlHomeAddressTypeId);
        setRowVisibility(car_rowIsContrStillRunningId, false);
        dropDownList_clearError(car_rblIsNotContrStillRunning1Id);
        dropDownList_clearError(car_rblIsNotContrStillRunning2Id);
        setRowVisibility(car_rowIsRunningAwayId, false);
        dropDownList_clearError(car_ddlIsRunningAway1Id);
        dropDownList_clearError(car_ddlIsRunningAway2Id);
        setRowVisibility(car_rowIsDrugsPositiveId, false);
        radioButtonList_clearError(car_rblIsDrugsPositive1Id);
        radioButtonList_clearError(car_rblIsDrugsPositive2Id);
        setRowVisibility(car_rowDUIId, false);
        dropDownList_clearError(car_ddlDUI1Id);
        dropDownList_clearError(car_ddlDUI2Id);
        setRowVisibility(car_rowContrNotRunningSinceId, false); 
        dropDownList_clearError(car_ddlContrNotRunningSinceId);
        setInnerHtml(car_lblContractAnniverMthId,"Quel est le mois d'échéance de votre contrat actuel ?");
    }
 car_alcoolPositifControlVisibility();
 car_disasterDetailsControlVisibility();        
        
}

function car_alcoolPositifControlVisibility()
{
    
   if ((car_hasBeenInsured1 != "N" && ($get(car_ddlContrCancelL1Id).value != "N" || car_primaryApplicantDrivLicenseSusp == "1" || car_primaryApplicantDrivLicenseSusp == "3" || car_primaryApplicantDrivLicenseSusp == "4" || getBonusFromForm($get(car_ddlBonusCoeff1Id).value * 1.0) > 1.18 || car_hasSeriousSinistre(1))&& $get(car_ddlDUI1Id).value == "1")
     || (car_applicantCount == 2 && car_hasBeenInsured2 != "N" && ($get(car_ddlContrCancelL2Id).value != "N" || car_secondaryApplicantDrivLicenseSusp == "1" || car_secondaryApplicantDrivLicenseSusp == "3" || car_secondaryApplicantDrivLicenseSusp == "4" || getBonusFromForm($get(car_ddlBonusCoeff2Id).value * 1.0) > 1.18 || car_hasSeriousSinistre(2))&& $get(car_ddlDUI2Id).value == "1"))       
    {//display lines
        setRowVisibility(car_rowAlcoholRegionId, true);
        setRowVisibility(car_rowAlcoholRegionSepId, true);
        setRowVisibility(car_rowLastFaultDateId, true);
        setRowVisibility(car_rowMeasuringApparatusId, true);
        setRowVisibility(car_rowAlcoholBloodRateId, true);
        setRowVisibility(car_rowLastFaultCirconstanceId, true);     
        setRowVisibility(car_rowFaultNbId, true);
        
        if((car_hasBeenInsured1 != "N" && ($get(car_ddlContrCancelL1Id).value != "N" || car_primaryApplicantDrivLicenseSusp == "1" || car_primaryApplicantDrivLicenseSusp == "3" || car_primaryApplicantDrivLicenseSusp == "4" || getBonusFromForm($get(car_ddlBonusCoeff1Id).value * 1.0) > 1.18 || car_hasSeriousSinistre(1))&& $get(car_ddlDUI1Id).value == "1"))
        {
            dropDownList_show(car_ddlLastFaultDate1DropDownListMonthId);
            dropDownList_show(car_ddlLastFaultDate1DropDownListYearId);
            dropDownList_show(car_ddlMeasuringApparatus1Id);
            dropDownList_show(car_ddlAlcoholBloodRate1Id);
            radioButtonList_show(car_rblLastFaultCirconstance1Id);
            dropDownList_show(car_ddlFaultNb1Id);
        }
        else
        {
            dropDownList_hide(car_ddlLastFaultDate1DropDownListMonthId);
            dropDownList_hide(car_ddlLastFaultDate1DropDownListYearId);
            dropDownList_hide(car_ddlMeasuringApparatus1Id);
            dropDownList_hide(car_ddlAlcoholBloodRate1Id);
            radioButtonList_hide(car_rblLastFaultCirconstance1Id);
            dropDownList_hide(car_ddlFaultNb1Id);
        }
        //applicant 2
        if (car_applicantCount == 2)
            if (car_applicantCount == 2 && car_hasBeenInsured2 != "N" && ($get(car_ddlContrCancelL2Id).value != "N" || car_secondaryApplicantDrivLicenseSusp == "1" || car_secondaryApplicantDrivLicenseSusp == "3" || car_secondaryApplicantDrivLicenseSusp == "4" || getBonusFromForm($get(car_ddlBonusCoeff2Id).value * 1.0) > 1.18 || car_hasSeriousSinistre(2))&& $get(car_ddlDUI2Id).value == "1")
            {
                dropDownList_show(car_ddlLastFaultDate2DropDownListMonthId);
                dropDownList_show(car_ddlLastFaultDate2DropDownListYearId);
                dropDownList_show(car_ddlMeasuringApparatus2Id);
                dropDownList_show(car_ddlAlcoholBloodRate2Id);
                radioButtonList_show(car_rblLastFaultCirconstance2Id);
                dropDownList_show(car_ddlFaultNb2Id);
            }
            else
            {
                dropDownList_hide(car_ddlLastFaultDate2DropDownListMonthId);
                dropDownList_hide(car_ddlLastFaultDate2DropDownListYearId);
                dropDownList_hide(car_ddlMeasuringApparatus2Id);
                dropDownList_hide(car_ddlAlcoholBloodRate2Id);
                radioButtonList_hide(car_rblLastFaultCirconstance2Id);
                dropDownList_hide(car_ddlFaultNb2Id);
            }
    }    
    else
    {//hide lines
        setRowVisibility(car_rowAlcoholRegionId, false);
        setRowVisibility(car_rowAlcoholRegionSepId, false);        
        setRowVisibility(car_rowLastFaultDateId, false);
        dateDropDownList_clearError(car_ddlLastFaultDate1Id);
        dateDropDownList_clearError(car_ddlLastFaultDate2Id);
        setRowVisibility(car_rowMeasuringApparatusId, false);
        dropDownList_clearError(car_ddlMeasuringApparatus1Id);
        dropDownList_clearError(car_ddlMeasuringApparatus2Id);
        setRowVisibility(car_rowAlcoholBloodRateId, false);
        dropDownList_clearError(car_ddlAlcoholBloodRate1Id);
        dropDownList_clearError(car_ddlAlcoholBloodRate2Id);
        setRowVisibility(car_rowLastFaultCirconstanceId, false); 
        radioButtonList_clearError(car_rblLastFaultCirconstance1Id);
        radioButtonList_clearError(car_rblLastFaultCirconstance2Id);    
        setRowVisibility(car_rowFaultNbId, false);
        dropDownList_clearError(car_ddlFaultNb1Id);
        dropDownList_clearError(car_ddlFaultNb2Id);
    
    }
}

function car_disasterDetailsControlVisibility()
{
    var nbCorpResp1=0;
    var nbCorpResp2=0;
    var bPrimaryCond=(car_hasBeenInsured1!= "N" );
    var bSecondaryCond =(car_applicantCount == 2 && car_hasBeenInsured2!= "N" );
    var nbPrimaryDisasterLast3=$get(car_ddlDisasterLast3Year1Id).value;
    var nbSecondaryDisasterLast3;
    if (bSecondaryCond)
        nbSecondaryDisasterLast3=$get(car_ddlDisasterLast3Year2Id).value;
    else
        nbSecondaryDisasterLast3=0;
    if (( bPrimaryCond && nbPrimaryDisasterLast3 > 0) 
       || ( bSecondaryCond && nbSecondaryDisasterLast3 > 0) )   
    {//display lines 1
        setRowVisibility(car_rowDisasterTitleId, true);
        setRowVisibility(car_rowDisasterTitleSepId, true);
        setRowVisibility(car_rowDisasterType1Id, true);           
        setRowVisibility(car_rowDisasterDate1Id, true);
        setRowVisibility(car_rowListDrive1Id, true);
       
        nbCorpResp1 +=car_hideDisater(0,bPrimaryCond,nbPrimaryDisasterLast3,car_ddlPrimaryDisasterType1Id,car_dtbPrimaryDisasterDate1Id,car_ddlPrimaryListDrive1Id,car_lblPrimaryDisasterDate1Id);
        nbCorpResp2 +=car_hideDisater(0,bSecondaryCond,nbSecondaryDisasterLast3,car_ddlSecondaryDisasterType1Id,car_dtbSecondaryDisasterDate1Id,car_ddlSecondaryListDrive1Id,car_lblSecondaryDisasterDate1Id);
        //Disaster 2
        if (( bPrimaryCond && nbPrimaryDisasterLast3 > 1) 
           || ( bSecondaryCond && nbSecondaryDisasterLast3 > 1) )
        {
            setRowVisibility(car_rowDisasterType2Id, true);           
            setRowVisibility(car_rowDisasterDate2Id, true);
            setRowVisibility(car_rowListDrive2Id, true);
            
            nbCorpResp1 +=car_hideDisater(1,bPrimaryCond,nbPrimaryDisasterLast3,car_ddlPrimaryDisasterType2Id,car_dtbPrimaryDisasterDate2Id,car_ddlPrimaryListDrive2Id,car_lblPrimaryDisasterDate2Id);
            nbCorpResp2 +=car_hideDisater(1,bSecondaryCond,nbSecondaryDisasterLast3,car_ddlSecondaryDisasterType2Id,car_dtbSecondaryDisasterDate2Id,car_ddlSecondaryListDrive2Id,car_lblSecondaryDisasterDate2Id);       
            //Disaster 3
            if (( bPrimaryCond && nbPrimaryDisasterLast3 > 2) 
               || ( bSecondaryCond && nbSecondaryDisasterLast3 > 2) )
            {
                setRowVisibility(car_rowDisasterType3Id, true);           
                setRowVisibility(car_rowDisasterDate3Id, true);
                setRowVisibility(car_rowListDrive3Id, true);
                
                nbCorpResp1 +=car_hideDisater(2,bPrimaryCond,nbPrimaryDisasterLast3,car_ddlPrimaryDisasterType3Id,car_dtbPrimaryDisasterDate3Id,car_ddlPrimaryListDrive3Id,car_lblPrimaryDisasterDate3Id);
                nbCorpResp2 +=car_hideDisater(2,bSecondaryCond,nbSecondaryDisasterLast3,car_ddlSecondaryDisasterType3Id,car_dtbSecondaryDisasterDate3Id,car_ddlSecondaryListDrive3Id,car_lblSecondaryDisasterDate3Id);       
                //Disaster 4
                if (( bPrimaryCond && nbPrimaryDisasterLast3 > 3) 
                   || ( bSecondaryCond && nbSecondaryDisasterLast3 > 3) )
                {
                    setRowVisibility(car_rowDisasterType4Id, true);           
                    setRowVisibility(car_rowDisasterDate4Id, true);
                    setRowVisibility(car_rowListDrive4Id, true);
                    
                    nbCorpResp1 +=car_hideDisater(3,bPrimaryCond,nbPrimaryDisasterLast3,car_ddlPrimaryDisasterType4Id,car_dtbPrimaryDisasterDate4Id,car_ddlPrimaryListDrive4Id,car_lblPrimaryDisasterDate4Id);
                    nbCorpResp2 +=car_hideDisater(3,bSecondaryCond,nbSecondaryDisasterLast3,car_ddlSecondaryDisasterType4Id,car_dtbSecondaryDisasterDate4Id,car_ddlSecondaryListDrive4Id,car_lblSecondaryDisasterDate4Id);
                     //Disaster 5
                    if (( bPrimaryCond && nbPrimaryDisasterLast3 > 4) 
                       || ( bSecondaryCond && nbSecondaryDisasterLast3 > 4) )
                    {
                        setRowVisibility(car_rowDisasterType5Id, true);           
                        setRowVisibility(car_rowDisasterDate5Id, true);
                        setRowVisibility(car_rowListDrive5Id, true);
                        
                        nbCorpResp1 +=car_hideDisater(4,bPrimaryCond,nbPrimaryDisasterLast3,car_ddlPrimaryDisasterType5Id,car_dtbPrimaryDisasterDate5Id,car_ddlPrimaryListDrive5Id,car_lblPrimaryDisasterDate5Id);
                        nbCorpResp2 +=car_hideDisater(4,bSecondaryCond,nbSecondaryDisasterLast3,car_ddlSecondaryDisasterType5Id,car_dtbSecondaryDisasterDate5Id,car_ddlSecondaryListDrive5Id,car_lblSecondaryDisasterDate5Id);
                    }
                    else
                    {
                        setRowVisibility(car_rowDisasterType5Id, false);                                 
                        setRowVisibility(car_rowDisasterDate5Id, false);                        
                        setRowVisibility(car_rowListDrive5Id, false);
                        dropDownList_clearError(car_ddlPrimaryDisasterType5Id);      
                        dropDownList_clearError(car_ddlSecondaryDisasterType5Id);  
                        dateDropDownList_clearError(car_dtbPrimaryDisasterDate5Id);                         
                        dateDropDownList_clearError(car_dtbSecondaryDisasterDate5Id);
                        dropDownList_clearError(car_ddlPrimaryListDrive5Id);      
                        dropDownList_clearError(car_ddlSecondaryListDrive5Id);
                    }
                }
                else
                {
                    setRowVisibility(car_rowDisasterType4Id, false);           
                    setRowVisibility(car_rowDisasterDate4Id, false);
                    setRowVisibility(car_rowListDrive4Id, false);                    
                    setRowVisibility(car_rowDisasterType5Id, false);           
                    setRowVisibility(car_rowDisasterDate5Id, false);
                    setRowVisibility(car_rowListDrive5Id, false);
                    dropDownList_clearError(car_ddlPrimaryDisasterType4Id);      
                    dropDownList_clearError(car_ddlSecondaryDisasterType4Id);  
                    dateDropDownList_clearError(car_dtbPrimaryDisasterDate4Id);      
                    dateDropDownList_clearError(car_dtbSecondaryDisasterDate4Id);
                    dropDownList_clearError(car_ddlPrimaryListDrive4Id);      
                    dropDownList_clearError(car_ddlSecondaryListDrive4Id);
                    dropDownList_clearError(car_ddlPrimaryDisasterType5Id);      
                    dropDownList_clearError(car_ddlSecondaryDisasterType5Id);  
                    dateDropDownList_clearError(car_dtbPrimaryDisasterDate5Id);      
                    dateDropDownList_clearError(car_dtbSecondaryDisasterDate5Id);
                    dropDownList_clearError(car_ddlPrimaryListDrive5Id);      
                    dropDownList_clearError(car_ddlSecondaryListDrive5Id);
                }
            }
            else
            {
                setRowVisibility(car_rowDisasterType3Id, false);           
                setRowVisibility(car_rowDisasterDate3Id, false);
                setRowVisibility(car_rowListDrive3Id, false);
                setRowVisibility(car_rowDisasterType4Id, false);           
                setRowVisibility(car_rowDisasterDate4Id, false);
                setRowVisibility(car_rowListDrive4Id, false);
                setRowVisibility(car_rowDisasterType5Id, false);           
                setRowVisibility(car_rowDisasterDate5Id, false);
                setRowVisibility(car_rowListDrive5Id, false);
                dropDownList_clearError(car_ddlPrimaryDisasterType3Id);      
                dropDownList_clearError(car_ddlSecondaryDisasterType3Id);  
                dateDropDownList_clearError(car_dtbPrimaryDisasterDate3Id);      
                dateDropDownList_clearError(car_dtbSecondaryDisasterDate3Id);
                dropDownList_clearError(car_ddlPrimaryListDrive3Id);      
                dropDownList_clearError(car_ddlSecondaryListDrive3Id);
                dropDownList_clearError(car_ddlPrimaryDisasterType4Id);      
                dropDownList_clearError(car_ddlSecondaryDisasterType4Id);  
                dateDropDownList_clearError(car_dtbPrimaryDisasterDate4Id);      
                dateDropDownList_clearError(car_dtbSecondaryDisasterDate4Id);
                dropDownList_clearError(car_ddlPrimaryListDrive4Id);      
                dropDownList_clearError(car_ddlSecondaryListDrive4Id);
                dropDownList_clearError(car_ddlPrimaryDisasterType5Id);      
                dropDownList_clearError(car_ddlSecondaryDisasterType5Id);  
                dateDropDownList_clearError(car_dtbPrimaryDisasterDate5Id);      
                dateDropDownList_clearError(car_dtbSecondaryDisasterDate5Id);
                dropDownList_clearError(car_ddlPrimaryListDrive5Id);      
                dropDownList_clearError(car_ddlSecondaryListDrive5Id);
            }
        }
        else
        {
            setRowVisibility(car_rowDisasterType2Id, false);           
            setRowVisibility(car_rowDisasterDate2Id, false);
            setRowVisibility(car_rowListDrive2Id, false);
            setRowVisibility(car_rowDisasterType3Id, false);           
            setRowVisibility(car_rowDisasterDate3Id, false);
            setRowVisibility(car_rowListDrive3Id, false);
            setRowVisibility(car_rowDisasterType4Id, false);           
            setRowVisibility(car_rowDisasterDate4Id, false);
            setRowVisibility(car_rowListDrive4Id, false);
            setRowVisibility(car_rowDisasterType5Id, false);           
            setRowVisibility(car_rowDisasterDate5Id, false);
            setRowVisibility(car_rowListDrive5Id, false);
            dropDownList_clearError(car_ddlPrimaryDisasterType2Id);      
            dropDownList_clearError(car_ddlSecondaryDisasterType2Id);  
            dateDropDownList_clearError(car_dtbPrimaryDisasterDate2Id);      
            dateDropDownList_clearError(car_dtbSecondaryDisasterDate2Id);
            dropDownList_clearError(car_ddlPrimaryListDrive2Id);      
            dropDownList_clearError(car_ddlSecondaryListDrive2Id)
            dropDownList_clearError(car_ddlPrimaryDisasterType3Id);      
            dropDownList_clearError(car_ddlSecondaryDisasterType3Id);  
            dateDropDownList_clearError(car_dtbPrimaryDisasterDate3Id);      
            dateDropDownList_clearError(car_dtbSecondaryDisasterDate3Id);
            dropDownList_clearError(car_ddlPrimaryListDrive3Id);      
            dropDownList_clearError(car_ddlSecondaryListDrive3Id);
            dropDownList_clearError(car_ddlPrimaryDisasterType4Id);      
            dropDownList_clearError(car_ddlSecondaryDisasterType4Id);  
            dateDropDownList_clearError(car_dtbPrimaryDisasterDate4Id);      
            dateDropDownList_clearError(car_dtbSecondaryDisasterDate4Id);
            dropDownList_clearError(car_ddlPrimaryListDrive4Id);      
            dropDownList_clearError(car_ddlSecondaryListDrive4Id);
            dropDownList_clearError(car_ddlPrimaryDisasterType5Id);      
            dropDownList_clearError(car_ddlSecondaryDisasterType5Id);  
            dateDropDownList_clearError(car_dtbPrimaryDisasterDate5Id);      
            dateDropDownList_clearError(car_dtbSecondaryDisasterDate5Id);
            dropDownList_clearError(car_ddlPrimaryListDrive5Id);      
            dropDownList_clearError(car_ddlSecondaryListDrive5Id);
        }        
     }
     else
     {//hide all disasters row
        setRowVisibility(car_rowDisasterTitleId, false);
        setRowVisibility(car_rowDisasterTitleSepId, false);
        setRowVisibility(car_rowDisasterType1Id, false);           
        setRowVisibility(car_rowDisasterDate1Id, false);
        setRowVisibility(car_rowListDrive1Id, false);
        setRowVisibility(car_rowDisasterType2Id, false);           
        setRowVisibility(car_rowDisasterDate2Id, false);
        setRowVisibility(car_rowListDrive2Id, false);
        setRowVisibility(car_rowDisasterType3Id, false);           
        setRowVisibility(car_rowDisasterDate3Id, false);
        setRowVisibility(car_rowListDrive3Id, false);
        setRowVisibility(car_rowDisasterType4Id, false);           
        setRowVisibility(car_rowDisasterDate4Id, false);
        setRowVisibility(car_rowListDrive4Id, false);
        setRowVisibility(car_rowDisasterType5Id, false);           
        setRowVisibility(car_rowDisasterDate5Id, false);
        setRowVisibility(car_rowListDrive5Id, false);
        dropDownList_clearError(car_ddlPrimaryDisasterType1Id);      
        dropDownList_clearError(car_ddlSecondaryDisasterType1Id);  
        dateDropDownList_clearError(car_dtbPrimaryDisasterDate1Id);      
        dateDropDownList_clearError(car_dtbSecondaryDisasterDate1Id);
        dropDownList_clearError(car_ddlPrimaryListDrive1Id);      
        dropDownList_clearError(car_ddlSecondaryListDrive1Id);
        dropDownList_clearError(car_ddlPrimaryDisasterType2Id);      
        dropDownList_clearError(car_ddlSecondaryDisasterType2Id);  
        dateDropDownList_clearError(car_dtbPrimaryDisasterDate2Id);      
        dateDropDownList_clearError(car_dtbSecondaryDisasterDate2Id);
        dropDownList_clearError(car_ddlPrimaryListDrive2Id);      
        dropDownList_clearError(car_ddlSecondaryListDrive2Id)
        dropDownList_clearError(car_ddlPrimaryDisasterType3Id);      
        dropDownList_clearError(car_ddlSecondaryDisasterType3Id);  
        dateDropDownList_clearError(car_dtbPrimaryDisasterDate3Id);      
        dateDropDownList_clearError(car_dtbSecondaryDisasterDate3Id);
        dropDownList_clearError(car_ddlPrimaryListDrive3Id);      
        dropDownList_clearError(car_ddlSecondaryListDrive3Id);
        dropDownList_clearError(car_ddlPrimaryDisasterType4Id);      
        dropDownList_clearError(car_ddlSecondaryDisasterType4Id);  
        dateDropDownList_clearError(car_dtbPrimaryDisasterDate4Id);      
        dateDropDownList_clearError(car_dtbSecondaryDisasterDate4Id);
        dropDownList_clearError(car_ddlPrimaryListDrive4Id);      
        dropDownList_clearError(car_ddlSecondaryListDrive4Id);
        dropDownList_clearError(car_ddlPrimaryDisasterType5Id);      
        dropDownList_clearError(car_ddlSecondaryDisasterType5Id);  
        dateDropDownList_clearError(car_dtbPrimaryDisasterDate5Id);      
        dateDropDownList_clearError(car_dtbSecondaryDisasterDate5Id);
        dropDownList_clearError(car_ddlPrimaryListDrive5Id);      
        dropDownList_clearError(car_ddlSecondaryListDrive5Id);
     }
      
    if (nbCorpResp1 > 0 || (bSecondaryCond && nbCorpResp2 > 0 )) {
        setRowVisibility(car_rowLastCorpDisasterSepId, true);
        setRowVisibility(car_rowLastCorpDisasterPursuiteId, true);
        setRowVisibility(car_rowLastCorpDisasterCirconstanceId, true);
        setRowVisibility(car_rowLastCorpDisasterTitleId, true);
          
         if (nbCorpResp1 > 0)
         {
            radioButtonList_show(car_rblLastCorpDisasterCirconstance1Id);            
            dropDownList_show(car_ddlLastCorpDisasterPursuite1Id);
         }
         else
         {
            radioButtonList_hide(car_rblLastCorpDisasterCirconstance1Id);            
            dropDownList_hide(car_ddlLastCorpDisasterPursuite1Id);
         }
         
         if (bSecondaryCond && nbCorpResp2 > 0 )
         {
            radioButtonList_show(car_rblLastCorpDisasterCirconstance2Id);            
            dropDownList_show(car_ddlLastCorpDisasterPursuite2Id);
         }
         else
         {
            radioButtonList_hide(car_rblLastCorpDisasterCirconstance2Id);            
            dropDownList_hide(car_ddlLastCorpDisasterPursuite2Id);
         }
            
        if((nbCorpResp1 > 0 && $get(car_ddlLastCorpDisasterPursuite1Id).value > 0 )
         ||  (bSecondaryCond && nbCorpResp2 > 0 && $get(car_ddlLastCorpDisasterPursuite2Id).value > 0))
        {
            setRowVisibility(car_rowLastCorpDisasterPrisonCondemnationId, true);
            if (nbCorpResp1 > 0 && $get(car_ddlLastCorpDisasterPursuite1Id).value > 0 )                           
                radioButtonList_show(car_rblLastCorpDisasterPrisonCondemnation1Id)
            else
                radioButtonList_hide(car_rblLastCorpDisasterPrisonCondemnation1Id)  
            
            if (bSecondaryCond && nbCorpResp2 > 0 && $get(car_ddlLastCorpDisasterPursuite2Id).value > 0)                           
                radioButtonList_show(car_rblLastCorpDisasterPrisonCondemnation2Id)
            else
                radioButtonList_hide(car_rblLastCorpDisasterPrisonCondemnation2Id)       
        }
        else
        {
            setRowVisibility(car_rowLastCorpDisasterPrisonCondemnationId, false);
            radioButtonList_clearError(car_rblLastCorpDisasterPrisonCondemnation1Id)
            radioButtonList_clearError(car_rblLastCorpDisasterPrisonCondemnation2Id)    
        }
    }
    else
    {
        setRowVisibility(car_rowLastCorpDisasterSepId, false);
        setRowVisibility(car_rowLastCorpDisasterTitleId, false);
        setRowVisibility(car_rowLastCorpDisasterPursuiteId, false);
        dropDownList_clearError(car_ddlLastCorpDisasterPursuite1Id)
        dropDownList_clearError(car_ddlLastCorpDisasterPursuite2Id)
        setRowVisibility(car_rowLastCorpDisasterCirconstanceId, false);
        radioButtonList_clearError(car_rblLastCorpDisasterCirconstance1Id)
        radioButtonList_clearError(car_rblLastCorpDisasterCirconstance2Id) 
        setRowVisibility(car_rowLastCorpDisasterPrisonCondemnationId, false);
        radioButtonList_clearError(car_rblLastCorpDisasterPrisonCondemnation1Id)
        radioButtonList_clearError(car_rblLastCorpDisasterPrisonCondemnation2Id) 
    }
}

function car_hideDisater(iDisaster,bCond,nbDisasterLast3,car_ddlDisasterTypeId,car_dtbDisasterDateId,car_ddlListDriveId,car_lblDisasterDateId)
{
    var disasterTypeTmp;
    if (bCond && nbDisasterLast3 > iDisaster)
    {
        dropDownList_show(car_ddlDisasterTypeId);
        dropDownList_show(car_dtbDisasterDateId); 
        show(car_lblDisasterDateId);
        dropDownList_show(car_ddlListDriveId);

        disasterTypeTmp=$get(car_ddlDisasterTypeId).value;
        if(disasterTypeTmp == "1")
           return 1;
     }
     else
     {
       dropDownList_hide(car_ddlDisasterTypeId);
       dropDownList_hide(car_dtbDisasterDateId);
       hide(car_lblDisasterDateId);     
       dropDownList_hide(car_ddlListDriveId);
       return 0;
     } 
     return 0;
}
//Chargement de liste
function car_measuringApparatusChange1(value)
{
    var listId = 304;
    if (value==2)
    {
        //load list 
        listId =305;
    }
    dropDownList_fill(car_ddlAlcoholBloodRate1Id, listId,"",$get(car_ddlAlcoholBloodRate1Id).value);     
}
function car_measuringApparatusChange2(value)
{
    var listId = 304;
    if (value==2)
    {
        //load list 
        listId =305;
    }
    dropDownList_fill(car_ddlAlcoholBloodRate2Id, listId,"",$get(car_ddlAlcoholBloodRate2Id).value);
}

function car_insuranceYearNbHelp() {
    if ($get(car_rowInsuranceYearnbHelpId))
        setRowVisibility(car_rowInsuranceYearnbHelpId, false);
}
//simpleFunction
function car_hasSeriousSinistre(iApplicant){
    //s'il y a au moins un sinistre corporelle on renvoi vrai
    //s'il y a au moins 2 sinistres materiel (responsable ou partiellement responsable) on renvoi vrai
    var nbSinistreMat = 0;
    
    if (iApplicant == 1){
        var nbPrimaryDisasterLast3=$get(car_ddlDisasterLast3Year1Id).value;
        if (nbPrimaryDisasterLast3 > 0) {
            nbSinistreMat += car_isSeriousSinistre(car_ddlPrimaryDisasterType1Id)
            if (nbPrimaryDisasterLast3 > 1) {
                nbSinistreMat += car_isSeriousSinistre(car_ddlPrimaryDisasterType2Id)
                if (nbPrimaryDisasterLast3 > 2) {
                    nbSinistreMat += car_isSeriousSinistre(car_ddlPrimaryDisasterType3Id)
                    if (nbPrimaryDisasterLast3 > 3) {
                        nbSinistreMat += car_isSeriousSinistre(car_ddlPrimaryDisasterType4Id)
                        if (nbPrimaryDisasterLast3 > 4) {
                            nbSinistreMat += car_isSeriousSinistre(car_ddlPrimaryDisasterType5Id)
                        }
                    }
                }
            }
            if (nbSinistreMat > 1) 
                return true;
        }
    }
    else{
        var nbPrimaryDisasterLast3=$get(car_ddlDisasterLast3Year2Id).value;
        if (nbPrimaryDisasterLast3 > 0) {
            nbSinistreMat += car_isSeriousSinistre(car_ddlSecondaryDisasterType1Id)
            if (nbPrimaryDisasterLast3 > 1) {
                nbSinistreMat += car_isSeriousSinistre(car_ddlSecondaryDisasterType2Id)
                if (nbPrimaryDisasterLast3 > 2) {
                    nbSinistreMat += car_isSeriousSinistre(car_ddlSecondaryDisasterType3Id)
                    if (nbPrimaryDisasterLast3 > 3) {
                        nbSinistreMat += car_isSeriousSinistre(car_ddlSecondaryDisasterType4Id)
                        if (nbPrimaryDisasterLast3 > 4) {
                            nbSinistreMat += car_isSeriousSinistre(car_ddlSecondaryDisasterType5Id)
                        }
                    }
                }
            }
            if (nbSinistreMat > 1) 
                return true ;           
        }
    }
    return false;
}

function car_isSeriousSinistre(ctrlType){
    var Disastertype = $get(ctrlType).value;
    if (Disastertype == "1"){
        return 2;
    }
    else {
        if ( Disastertype == "3" || Disastertype == "4")
        return 1;
    }
    return 0;
}

function getCarMaturity(month){
    if(month != "")
    {
        var maturityCtrl= $get(car_dtbQuotationEffectiveDateId);
        if (maturityCtrl && car_insuranceNeed == 1){
            var prop = form_eltPropertiesObjArray[maturityCtrl.id];  
            if (prop.currentValueIsDefaultText){
                prop.defaultText=getMaturity(month);
                maturityCtrl.value= prop.defaultText;
            }
        }
    }
}

//warning page 4
function car_warningEffectiveDate(sender) {

    if (car_hasBeenInsured1 == "N")
        return "";
    if (car_insuranceNeed > 1)
        return "";
        
    var prop = form_eltPropertiesObjArray[sender.id];
    if (!prop.currentValueIsDefaultText){
        var effecDate = getDateByFormat(sender.value, 'dd/MM/yyyy');
        var bWarn = false;

        if($get(car_ddlContractAnniverMthId).value != "")
        {
            if ($get(car_ddlContractAnniverMthId).value == 12) {
                if (effecDate.getMonth() < 10 && effecDate.getMonth() > 0)
                    bWarn = true;
            }
            else {
                if ($get(car_ddlContractAnniverMthId).value == 1) {
                    if (effecDate.getMonth() > 1 && effecDate.getMonth() < 10)
                        bWarn = true;
                }
                else {
                    if ($get(car_ddlContractAnniverMthId).value > (effecDate.getMonth() + 2) || $get(car_ddlContractAnniverMthId).value < (effecDate.getMonth()))
                        bWarn = true;
                }
            }
            if (bWarn)
                return "Vous avez précédemment déclaré que le mois d'échéance de votre police actuelle est en " + GetMonthText($get(car_ddlContractAnniverMthId).value) + ". La date d'effet que vous venez de renseigner n'est donc pas cohérente. Merci de corriger si c'est une erreur. Sinon continuer.";
        }
    }
    return '';
}

function car_warningCarBonus1(sender) {
    if (sender.value != ""){
        var bonus = getBonusFromForm(sender.value * 1.0);

        if (isValidBonus(bonus,$get(car_ddlInsuranceYearnb1Id).value) == false) {
            return "La date de permis que vous avez renseignée ne semble pas permettre d'avoir un bonus de ce niveau.";
        }
    }
    return "";
}
function car_warningCarBonus2(sender) {
    if (sender.value != ""){
        var bonus = getBonusFromForm(sender.value * 1.0);
        if (isValidBonus(bonus, $get(car_ddlInsuranceYearnb2Id).value) == false) {
            return "La date de permis que vous avez renseignée ne semble pas permettre d'avoir un bonus de ce niveau.";
        }
    }
    return "";
}

function car_warningAlcoolCancel(sender) { 
    if (sender.value!="1")
        return "Etes-vous certain de ne pas vous être trompé dans la saisie à propos du contrôle d'alcoolémie?";
    return "";
}

function car_warningIsRunningAway(sender) { 
 if (sender.value!="1")
        return "Etes-vous certain de ne pas vous être trompé dans la saisie à propos du délit de fuite ?";
    return "";
}

////////////////////////////////////////
// Car vehicule selection
////////////////////////////////////////

var car_ddlCarAlimID;
var car_ddlCarBodyTypeID;
var car_ddlCarPowerID;
var car_ddlCarTypeID;

var car_addCarAge;
var car_dtbPurchaseDatePrevID;

var car_ddlCarMakeID;
var car_hfCarGTAID;

var car_panelVehiculeSearchResultID;
var car_btnSearchVehiculeID;
var car_lblSelectedVehiculeID;

var car_divSelectedVehiculeID;
var car_rowCarCodeMakeID;
var car_rowCarTypeID;
var car_rowCarAlimID;
var car_rowCarBodyTypeID;
var car_rowCarPowerID;
var car_rowBtnSearchVehiculeID;
var car_rowCarValeurID;
var car_txtCarValeurID;
var car_ddlPurchaseModeId;
var car_rowCarSelectionTitleId;
var car_popupExtenderId;
//var car_cellSubmitId;
var car_hfSearchTypeId;

var vehiculeTableID = "vehiculeTable";
var vehiculeValidateBtnID = "vehiculeValidateBtnId";
var vehiculeTableHeaderCssClass = "al_header";
var vehiculeTableHeaderOtherCssClass = "al_header2";
var vehiculeTableRow1CssClass = "al_row2";
var vehiculeTableRow2CssClass = "al_row1";
var vehiculeTableRowSelectedCssClass = "al_rowSelected";
var vehiculeButtonSearchOnCssClass ="al_formVehiculeBtnSearchOn";
var vehiculeButtonSearchOffCssClass ="al_formVehiculeBtnSearchOff";
var IntNull=-42;
var car_dateRef;
        
//Load Car Mark List
//Save value
var saveCarMake;
var saveCarType;
var saveCarAlim;
var saveCarBodyType;
var saveCarPower;

function car_saveCarCaract()
{
 saveCarMake = $get(car_ddlCarMakeID).value;
 saveCarType= $get(car_ddlCarTypeID).value;
 saveCarAlim= $get(car_ddlCarAlimID).value;
 saveCarBodyType= $get(car_ddlCarBodyTypeID).value;
 saveCarPower= $get(car_ddlCarPowerID).value;
 
 $get(car_hfCarGTAID).value = '';
 hide(car_divSelectedVehiculeID);
 showRow(car_rowBtnSearchVehiculeID);
}

function car_getDateRef() {
    if (car_addCarAge == "1") {
        return getDateByFormat($get(car_dtbPurchaseDatePrevID).value,"dd/MM/yyyy");
    }
    else {
        return dateDropDownList_getDate(car_firstCarDrivingDateId);
    }
}

function car_vehiculeFirstDrivingDate()
{

    var FirstDrivingDate = car_getDateRef();
    if(isValidDate(FirstDrivingDate)){
        if( car_dateRef != FirstDrivingDate.getFullYear()){
            car_dateRef=FirstDrivingDate.getFullYear();
            // Clear sub info
            car_saveCarCaract();
            dropDownList_clear(car_ddlCarTypeID);
            dropDownList_clear(car_ddlCarAlimID);
            dropDownList_clear(car_ddlCarBodyTypeID);
            dropDownList_clear(car_ddlCarPowerID);

            dropDownList_clear(car_ddlCarMakeID);
            $get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOffCssClass;    
            if (isValidDate(FirstDrivingDate)) {
                dropDownList_show(car_ddlCarMakeID); 
                var car_ddlCarCodeMakeUpdate_Callback = function(result, eventArgs) {
                    dropDownList_bind(car_ddlCarMakeID, -1, result, saveCarMake, "", (result.length > 1 ? true : false));
                    if ($get(car_ddlCarMakeID).value != "") {
                        car_vehiculeCodeMake(saveCarMake, false);
                    }
                    else 
                    {
                        dropDownList_hide(car_ddlCarTypeID); 
                        dropDownList_hide(car_ddlCarAlimID);
                        dropDownList_hide(car_ddlCarBodyTypeID);
                        dropDownList_hide(car_ddlCarPowerID);            
                    }
                }
                // Call WS
                AssurlandWeb.CarVehiculeSearch.GetCarMakeListByFirstDrivingDate(FirstDrivingDate, car_ddlCarCodeMakeUpdate_Callback, car_ddlCarCodeMakeUpdate_FailedCallback);
                
            }
            else
            {
                dropDownList_hide(car_ddlCarTypeID); 
                dropDownList_hide(car_ddlCarAlimID);
                dropDownList_hide(car_ddlCarBodyTypeID);
                dropDownList_hide(car_ddlCarPowerID);            
            }
        }
    }
}


// This is the callback function invoked if the Web service failed.
function car_ddlCarCodeMakeUpdate_FailedCallback(error)
{
    displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.GetCarMakeListByFirstDrivingDate failed",error);
}

//Load Car Type List
function car_vehiculeCodeMake(CodeMake,IsEvent)
{
    var FirstDrivingDate = car_getDateRef();
     
    // Clear sub info
     if (IsEvent)
        car_saveCarCaract();
    dropDownList_clear(car_ddlCarAlimID);    
    dropDownList_clear(car_ddlCarBodyTypeID);
    dropDownList_clear(car_ddlCarPowerID);    
    dropDownList_clear(car_ddlCarTypeID);
    $get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOffCssClass;
    
    car_ddlCarTypeUpdate_Callback = function (result, eventArgs)
    {
        var oArray = new Array();
        for(var i=0; i<result.length; i++)
        {
            oArray[i] = new ListItem(result[i],result[i]);
        }
        dropDownList_bind(car_ddlCarTypeID, -1, oArray, saveCarType, "", (oArray.length > 1 ? true : false));
        if ($get(car_ddlCarTypeID).value != "")
        {
            car_vehiculeCodeType($get(car_ddlCarTypeID).value, false);
        }
        else 
        {
            dropDownList_hide(car_ddlCarAlimID);
            dropDownList_hide(car_ddlCarBodyTypeID);
            dropDownList_hide(car_ddlCarPowerID);            
        }   
    }
    
    // This is the callback function invoked if the Web service failed.
    
    car_ddlCarTypeUpdate_FailedCallback=function (error)
    {
        displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.GetCarAlimListByCarType failed",error);
    }

    // Call WS
    if (CodeMake != "")
    {
        dropDownList_show(car_ddlCarTypeID);
        AssurlandWeb.CarVehiculeSearch.GetCarTypeListByCodeMake(CodeMake,FirstDrivingDate, car_ddlCarTypeUpdate_Callback, car_ddlCarTypeUpdate_FailedCallback);
    
    }
    else 
        {
            dropDownList_hide(car_ddlCarTypeID);
            dropDownList_hide(car_ddlCarAlimID);
            dropDownList_hide(car_ddlCarBodyTypeID);
            dropDownList_hide(car_ddlCarPowerID);            
        }
}
//Load Car Alim List
function car_vehiculeCodeType(CarType,IsEvent)
{
    //take car values
    var FirstDrivingDate = car_getDateRef();
    var CodeMake=$get(car_ddlCarMakeID).value;
   
    if (IsEvent)
        car_saveCarCaract();
    // Clear sub info
    dropDownList_clear(car_ddlCarBodyTypeID);
    dropDownList_clear(car_ddlCarPowerID);    
    dropDownList_clear(car_ddlCarAlimID);
    $get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOffCssClass;

    car_ddlCarAlimUpdate_Callback = function(result, eventArgs) {
        dropDownList_bind(car_ddlCarAlimID, -1, result, saveCarAlim, "", (result.length > 1 ? true : false));
      
        if ($get(car_ddlCarAlimID).value != "") {         
            car_vehiculeCarAlim($get(car_ddlCarAlimID).value, false,true);
        }
        else 
        {  
            dropDownList_hide(car_ddlCarBodyTypeID);
            dropDownList_hide(car_ddlCarPowerID); 
            car_vehiculeCount(FirstDrivingDate, CodeMake, CarType, "", "", IntNull);           
        }  
        
    }
    
    // This is the callback function invoked if the Web service failed.
    
    car_ddlCarAlimUpdate_FailedCallback = function (error)
    {
        displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.GetCarAlimListByCarType failed",error);
    }

    // Call WS
    if (CarType != ""){
        dropDownList_show(car_ddlCarAlimID); 
        AssurlandWeb.CarVehiculeSearch.GetCarAlimListByCarType(CarType,CodeMake,FirstDrivingDate, car_ddlCarAlimUpdate_Callback, car_ddlCarAlimUpdate_FailedCallback);
    }
    else 
    {
        dropDownList_hide(car_ddlCarAlimID); 
        dropDownList_hide(car_ddlCarBodyTypeID);
        dropDownList_hide(car_ddlCarPowerID); 
    }
}

//Load Car Body Type List
function car_vehiculeCarAlim(CarAlim,IsEvent,CanLaunchSearch)
{
    //take car values
    var FirstDrivingDate = car_getDateRef();
    var CodeMake=$get(car_ddlCarMakeID).value;
    var CarType=$get(car_ddlCarTypeID).value;
    $get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOffCssClass;
    if (IsEvent)
        car_saveCarCaract();   
    // Clear sub info
    dropDownList_clear(car_ddlCarPowerID);
    
    dropDownList_clear(car_ddlCarBodyTypeID);
    
    car_ddlBodyTypeUpdate_Callback = function (result, eventArgs)
    {
        dropDownList_bind(car_ddlCarBodyTypeID, -1, result, saveCarBodyType, "", (result.length > 1 ? true : false));
       if ($get(car_ddlCarBodyTypeID).value != "")
        {
            car_vehiculeCarBodyType($get(car_ddlCarBodyTypeID).value, false,CanLaunchSearch);
        }
        else 
        {  
            dropDownList_hide(car_ddlCarPowerID);
            if (CanLaunchSearch)
             car_vehiculeCount(FirstDrivingDate,CodeMake,CarType,CarAlim,"",IntNull);            
        } 
       
    }
    
    // This is the callback function invoked if the Web service failed.
    
    car_ddlBodyTypeUpdate_FailedCallback = function (error)
    {
        displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.GetCarBodyTypeListByCarAlim failed",error);
    }

    // Call WS
    if (CarAlim != ""){
        dropDownList_show(car_ddlCarBodyTypeID); 
        AssurlandWeb.CarVehiculeSearch.GetCarBodyTypeListByCarAlim(CarAlim,CarType,CodeMake,FirstDrivingDate, car_ddlBodyTypeUpdate_Callback, car_ddlBodyTypeUpdate_FailedCallback);
    }
    else{ 
        dropDownList_hide(car_ddlCarBodyTypeID); 
        dropDownList_hide(car_ddlCarPowerID);        
    }
}


//Load Body Type List
function car_vehiculeCarBodyType(CarBodyType,IsEvent,CanLaunchSearch)
{
    //take car values
    var FirstDrivingDate = car_getDateRef();
    var CodeMake=$get(car_ddlCarMakeID).value;
    var CarType=$get(car_ddlCarTypeID).value;
    var CarAlim=$get(car_ddlCarAlimID).value;
    
    if (IsEvent)
        car_saveCarCaract();
    dropDownList_clear(car_ddlCarPowerID);
    if ( CarBodyType == "")
        $get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOffCssClass;
    else
        $get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOnCssClass;
        
    car_ddlCarPowerUpdate_Callback = function (result, eventArgs)
    {
        var oArray = new Array();
        for(var i=0; i<result.length; i++)
        {
            oArray[i] = new ListItem(result[i],result[i]);
        }
        dropDownList_bind(car_ddlCarPowerID, -1, oArray, saveCarPower, "", (oArray.length > 1 ? true : false));
        if ($get(car_ddlCarPowerID).value != "")
        {
            car_vehiculeCarPower($get(car_ddlCarPowerID).value,false,CanLaunchSearch);
        } 
        else{ 
            if (CanLaunchSearch)
                car_vehiculeCount(FirstDrivingDate,CodeMake,CarType,CarAlim,CarBodyType,IntNull);
        }
    }
    
    // This is the callback function invoked if the Web service failed.
    
    car_ddlCarPowerUpdate_FailedCallback=function (error)
    {
        displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.GetCarPowerListByBodyType failed",error);
    }

    // Call WS
    if ( CarBodyType != ""){
        dropDownList_show(car_ddlCarPowerID);
        AssurlandWeb.CarVehiculeSearch.GetCarPowerListByBodyType(CarBodyType,CarAlim,CarType,CodeMake,FirstDrivingDate,car_ddlCarPowerUpdate_Callback, car_ddlCarPowerUpdate_FailedCallback);
        }
    else
    {
        dropDownList_hide(car_ddlCarPowerID);
    }
}
//Load Car Type List
function car_vehiculeCarPower(CarPower,IsEvent,CanLaunchSearch)
{
    //take car values
    var FirstDrivingDate = car_getDateRef();
    var CodeMake=$get(car_ddlCarMakeID).value;
    var CarType=$get(car_ddlCarTypeID).value;
    var CarAlim=$get(car_ddlCarAlimID).value;
    var CarBodyType = $get(car_ddlCarBodyTypeID).value;
    if (IsEvent)
        car_saveCarCaract();
    $get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOnCssClass;
    if (CarPower!="" )
         if (CanLaunchSearch)
            car_vehiculeSearchBtnClick();     
    
}

function car_vehiculeSearchBtnClick()
{

    //take car values
    var FirstDrivingDate = car_getDateRef();
    var CodeMake=$get(car_ddlCarMakeID).value;
    var CarType=$get(car_ddlCarTypeID).value;
    var CarAlim=$get(car_ddlCarAlimID).value;  
    var CarBodyType=$get(car_ddlCarBodyTypeID).value;
    var CarPower=$get(car_ddlCarPowerID).value;
    if (CarPower=="")
        CarPower=IntNull;
    if ($get(car_btnSearchVehiculeID).className == vehiculeButtonSearchOnCssClass) {
        car_vehiculeSearch(FirstDrivingDate, CodeMake, CarType, CarAlim, CarBodyType, CarPower,0,"Version_Asc");
        return false;
    }
    else {
        return true;
    }
}

function car_vehiculeCount(FirstDrivingDate,CodeMake,CarType,CarAlim,CarBodyType,CarPower)
{
    // Call WS
    car_vehiculeCount_Callback = function(result, eventArgs)
    {
       if (result < 11 )
        car_vehiculeSearch(FirstDrivingDate,CodeMake,CarType,CarAlim,CarBodyType,CarPower,1,"Version_Asc");       
       
    }
    car_vehiculeCount_FailedCallback = function (error)
    {
        displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.Count failed",error);
    }
    
    if($get(car_hfCarGTAID).value == "")
    AssurlandWeb.CarVehiculeSearch.Count(FirstDrivingDate,CodeMake,CarType,CarAlim,CarBodyType,CarPower, car_vehiculeCount_Callback, car_vehiculeCount_FailedCallback);
    
}

function hideVehicleSelectionPopUp()
{
    car_hideVehicleSelectionPopUp();
}

function car_hideVehicleSelectionPopUp()
{
    $find(car_popupExtenderId).hide();
}


function car_vehiculeSearch(FirstDrivingDate,CodeMake,CarType,CarAlim,CarBodyType,CarPower,searchType,sort)
{
    // Call WS
    car_vehiculeSearch_Callback = function(result, eventArgs)
    {
        car_vehiculeTableDisplay(result, searchType,sort);
    }
    car_vehiculeSearch_FailedCallback = function (error)
    {
        displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.CarList failed",error);
    }
    AssurlandWeb.CarVehiculeSearch.CarList(FirstDrivingDate,CodeMake,CarType,CarAlim,CarBodyType,CarPower,sort, car_vehiculeSearch_Callback, car_vehiculeSearch_FailedCallback);
    
}

function car_vehiculeTableDisplay(result, searchType,sort)
{
    var str = "";
    var className = "";
    var rbId;
    var strHeader = "";
    // Reset selected auto
    $get(car_hfCarGTAID).value = '';
    
    $get(car_hfSearchTypeId).value=searchType;
    // Show rows
    $get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOnCssClass;
    if(result.length > 0)
    {    
        // Header text        
        strHeader = "Nous&nbsp;avons&nbsp;";
        if (searchType)
            if (searchType == 1)
                strHeader += "déjà&nbsp;";
        
        strHeader += "trouvé&nbsp;" + result.length + "&nbsp;véhicule";
        if (result.length>1)
            strHeader +="s";
        strHeader +="&nbsp;correspondant&nbsp;à&nbsp;vos&nbsp;critères,&nbsp;sélectionnez&nbsp;le&nbsp;vôtre&nbsp;:&nbsp;"        
        str += '<table cellpadding="0" cellspacing="0" class="al_formVehiculeHeader">'
        str += '<tr>'
        str += '<td class="al_left"></td>'
        str += '<td class="al_center">' + strHeader + '</td>'
        str += '<td class="al_right"></td>'
        str += '</tr>'
        str += '</table>'
        // Vehicule list
        str += '<table cellpadding="0" cellspacing="0" class="al_formVehiculeTable">';
        str += '<tr>';
        str += '<td class="' + vehiculeTableHeaderCssClass + '" width="65" align="center">Cochez une case</td>';
        str += '<td class="' + vehiculeTableHeaderOtherCssClass + '" width="230" align="center"';
         if (sort=="Version_Asc")
           str +='onclick="car_vehiculeSearchSort(\'Version_Desc\');">Version <img class="al_sortAsc" src="/Images2/px.gif" /></td>';
        else {
            if (sort=="Version_Desc")
                str +='onclick="car_vehiculeSearchSort(\'Version_Asc\');">Version <img class="al_sortDesc" src="/Images2/px.gif" /></td>';
            else
                str +='onclick="car_vehiculeSearchSort(\'Version_Asc\');">Version</td>'; 
        }    
        str += '<td class="' + vehiculeTableHeaderOtherCssClass + '" width="60" align="center" ';
         if (sort=="Alim_Asc")
           str +='onclick="car_vehiculeSearchSort(\'Alim_Desc\');">Alim.<img class="al_sortAsc" src="/Images2/px.gif" /></td>';
        else {
            if (sort=="Alim_Desc")
                str +='onclick="car_vehiculeSearchSort(\'Alim_Asc\');">Alim. <img class="al_sortDesc" src="/Images2/px.gif" /></td>';
            else
                str +='onclick="car_vehiculeSearchSort(\'Alim_Asc\');">Alim.</td>'; 
        }    
        str += '<td class="' + vehiculeTableHeaderOtherCssClass + '" width="35" align="center" ';
         if (sort=="CV_Asc")
           str +='onclick="car_vehiculeSearchSort(\'CV_Desc\');">CV <img class="al_sortAsc" src="/Images2/px.gif" /></td>';
        else {
            if (sort=="CV_Desc")
                str +='onclick="car_vehiculeSearchSort(\'CV_Asc\');">CV <img class="al_sortDesc" src="/Images2/px.gif" /></td>';
            else
                str +='onclick="car_vehiculeSearchSort(\'CV_Asc\');">CV</td>'; 
        }    
        str += '<td class="' + vehiculeTableHeaderOtherCssClass + '" width="70" align="center" ';
         if (sort=="Porte_Asc")
           str +='onclick="car_vehiculeSearchSort(\'Porte_Desc\');">Nombre de<br />portes <img class="al_sortAsc" src="/Images2/px.gif" /></td>';
        else {
            if (sort=="Porte_Desc")
                str +='onclick="car_vehiculeSearchSort(\'Porte_Asc\');">Nombre de<br />portes <img class="al_sortDesc" src="/Images2/px.gif" /></td>';
            else
                str +='onclick="car_vehiculeSearchSort(\'Porte_Asc\');">Nombre de<br />portes</td>'; 
        }    
        str += '<td class="' + vehiculeTableHeaderOtherCssClass + '" width="70" align="center" ';
         if (sort=="Vitesse_Asc")
           str +='onclick="car_vehiculeSearchSort(\'Vitesse_Desc\');">Boîte de <br />vitesse <img class="al_sortAsc" src="/Images2/px.gif" /></td>';
        else {
            if (sort=="Vitesse_Desc")
                str +='onclick="car_vehiculeSearchSort(\'Vitesse_Asc\');">Boîte de <br />vitesse <img class="al_sortDesc" src="/Images2/px.gif" /></td>';
            else
                str +='onclick="car_vehiculeSearchSort(\'Vitesse_Asc\');">Boîte de <br />vitesse</td>'; 
        }    
        str += '<td class="' + vehiculeTableHeaderOtherCssClass + '" align="center" ';
         if (sort=="Annee_Asc")
           str +='onclick="car_vehiculeSearchSort(\'Annee_Desc\');">Année de<br />fabrication<img class="al_sortAsc" src="/Images2/px.gif" /></td>';
        else {
            if (sort=="Annee_Desc")
                str +='onclick="car_vehiculeSearchSort(\'Annee_Asc\');">Année de<br />fabrication<img class="al_sortDesc" src="/Images2/px.gif" /></td>';
            else
                str +='onclick="car_vehiculeSearchSort(\'Annee_Asc\');">Année de<br />fabrication</td>'; 
        }    
        str += '</tr>';
        str += '</table>';
        str += '<div class="al_formVehiculeTableWrapper"'
        if(result.length > 10)
        {
            str += ' style="height:310px;overflow:hidden;overflow-y:auto;display:block;"';
        }
        str += '>';
        str += '<table id="' + vehiculeTableID + '" cellpadding="0" cellspacing="0" class="al_formVehiculeTable" width="640px" >';
        for(var i=0; i<result.length; i++)
        {
            rbId = "vehiculeRb" + i;
            if(i%2 == 0)
                className = vehiculeTableRow2CssClass
            else
                className = vehiculeTableRow1CssClass
            str += '<tr class="' + className + '" onmouseover="car_vehiculeTableRowMouseOver(this);" onmouseout="car_vehiculeTableRowMouseOut(this,' + i + ',\'' + rbId + '\');" onclick="car_vehiculeTableRowClick(this,' + i + ',\'' + rbId + '\');" onDblclick="car_vehiculeTableRowClick(this,' + i + ',\'' + rbId + '\');car_vehiculeValidateBtnClick();">';
            str += '<td width="65" align="center"><input type="radio" id="' + rbId + '" name="vehiculeRb" value="' + result[i].GtaCode + '" /></td>';
            str += '<td width="230" align="left">' + result[i].CarModelLabel + '</td>';
            str += '<td width="60" align="left">' + result[i].CarAlimLabel + '</td>';
            str += '<td width="35" align="left">' + result[i].CarCvNumber + ' cv </td>';
            str += '<td width="70" align="left">' + result[i].DoorsNumber + '</td>';
            str += '<td width="70" align="left">' + result[i].GearBoxLabel + '</td>';
            str += '<td align="left">' + result[i].MadeYearsLabel + '</td>';           
            str += '</tr>';
        }
        str += '</table>'
        str += '</div>'
        // Aide
        str += '<div class="al_formVehiculeHelp">'
        str += '<a href="#" onclick="showHide(\'formVehiculeHelp\');return false;" title="Voir l\'aide">Aide</a>'
        str += '<div id="formVehiculeHelp" style="display:none;">Si vous ne retrouvez pas le modèle exact de votre véhicule, sélectionnez <b>celui qui semble le plus proche</b> afin d\'avoir les résultats les plus fiables possibles. Vous pourrez ensuite le modifier directement avec l\'assureur sélectionné.</div>';
        str += '</div>'
         //cancel link
        str += '<table width="100%" class="al_formNavigation"><tr><td class="al_back"><a title="Modifier" href="javascript:car_hideVehicleSelectionPopUp();"> << MODIFIER </a></td>'
        
        str += '<td><input type="image" id="' + vehiculeValidateBtnID + '" title="Valider votre véhicule" class="al_formVehiculeBtnValidateOff" src="/Images2/px.gif" onclick="car_vehiculeValidateBtnClick();  return false;" /></td></tr></table>'
    }
    else
    {
    
        str = "Aucun résultat";
    }
    setInnerHtml(car_panelVehiculeSearchResultID, str);
    
    $find(car_popupExtenderId).show();

}

function car_vehiculeTableRowMouseOver(row)
{
    row.className = vehiculeTableRowSelectedCssClass;
}

function car_vehiculeTableRowMouseOut(row, index, rblId)
{
    if(! $get(rblId).checked )
    {
        if(index%2 == 0)
            row.className = vehiculeTableRow2CssClass
        else
            row.className = vehiculeTableRow1CssClass
    }
}

function car_vehiculeTableRowClick(row, index, rblId)
{
    // Reset all other selected row
    var elt = $get(vehiculeTableID);
    if(elt != null)
    {
        var obj = elt.getElementsByTagName("tr");
        if(obj && obj.length)
        {
            for(var i=0; i < obj.length; i++)
            {
                if(i%2 == 0)
                    obj[i].className = vehiculeTableRow2CssClass
                else
                    obj[i].className = vehiculeTableRow1CssClass
            }
        }
    }
    // Set selected row
    $get(rblId).checked=true;
    row.className = vehiculeTableRowSelectedCssClass;
    // Update car ID
    $get(car_hfCarGTAID).value = $get(rblId).value;
    // Active button
    $get(vehiculeValidateBtnID).className = 'al_formVehiculeBtnValidateOn';
}

function car_vehiculeValidateBtnClick()
{
    
    // Check selection
    if($get(car_hfCarGTAID).value == '')
    {
        car_errorSelectedCarShow();
        return false;
    }
    
    var car_CodeGTA = $get(car_hfCarGTAID).value;
    var car_vehiculeValidate_Callback = function(result, eventArgs)
    {
        setInnerHtml(car_lblSelectedVehiculeID, result);
        setInnerHtml(car_panelVehiculeSearchResultID, "");
        show(car_divSelectedVehiculeID);
        /*hideRow(car_rowCarCodeMakeID);
        hideRow(car_rowCarTypeID);
        hideRow(car_rowCarAlimID);
        hideRow(car_rowCarBodyTypeID);
        hideRow(car_rowCarPowerID);
        hideRow(car_rowCarSelectionTitleId);
        */
        //show(car_cellSubmitId);
        car_DiplayRowCarValeurAndCompleteForm(car_CodeGTA);
        
        hideRow(car_rowBtnSearchVehiculeID);
        car_hideVehicleSelectionPopUp();
        
        setRowVisibility(car_rowCarValeurID, false);
        textBox_clearError(car_txtCarValeurID);
    }
    
    car_vehiculeValidate_FailedCallback= function (error)
    {
        displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.GetCarVehiculeToString failed",error);
    }
    
    AssurlandWeb.CarVehiculeSearch.GetCarVehiculeToString(car_CodeGTA, car_vehiculeValidate_Callback, car_vehiculeValidate_FailedCallback);  
}

function  car_DiplayRowCarValeurAndCompleteForm(car_CodeGTA) {
    car_DiplayRowCarValeur_Callback = function(result, eventArgs) {        
        if (result) {
            if ((result.CarGroup > 29
                && result.CarMarketValue >= 44000
                && (result.CarClass == "R" || result.CarClass == "S" || result.CarClass == "T" || result.CarClass == "U" || result.CarClass == "V" || result.CarClass == "W" || result.CarClass == "X"|| result.CarClass == "Y" || result.CarClass == "Z" ))
                || result.CarClass=="HC")
             {
                setRowVisibility(car_rowCarValeurID, true);
                $get(car_txtCarValeurID).focus();                
            }
            else {
                setRowVisibility(car_rowCarValeurID, false);
                $get(car_ddlPurchaseModeId).focus();
                textBox_clearError(car_txtCarValeurID);
            }
          //complete form
           if ($get(car_ddlCarAlimID).value ==""){           
                if ($get(car_ddlCarBodyTypeID).value ==""){
                    saveCarBodyType=result.CarBodySimple;
                    if ($get(car_ddlCarPowerID).value =="")
                        saveCarPower=result.CarCvNumber; 
                 }
                $get(car_ddlCarAlimID).value=result.CarAlim;
                car_vehiculeCarAlim(result.CarAlim,false,false)  
            }
           
            if ($get(car_ddlCarBodyTypeID).value ==""){
                if ($get(car_ddlCarPowerID).value =="")
                    saveCarPower=result.CarCvNumber;   
                $get(car_ddlCarBodyTypeID).value=result.CarBodySimple;
                car_vehiculeCarBodyType(result.CarBodySimple,false,false)
            }
           if ($get(car_ddlCarPowerID).value ==""){
                 saveCarPower=result.CarCvNumber;   
                $get(car_ddlCarPowerID).value=result.CarCvNumber;                
            }
         }
        else {
            setRowVisibility(car_rowCarValeurID, false);
            $get(car_ddlPurchaseModeId).focus();
            textBox_clearError(car_txtCarValeurID);
        }
    }
    
    car_DiplayRowCarValeur_FailedCallback= function (error)
    {
        displayAspNetFrameworkError("AssurlandWeb.CarVehiculeSearch.GetCarVehicule failed",error);
    }
    
    AssurlandWeb.CarVehiculeSearch.GetCarVehicule(car_CodeGTA, car_DiplayRowCarValeur_Callback, car_DiplayRowCarValeur_FailedCallback);  
}

function car_p3_checkBeforePost() { 
    if($get(car_hfCarGTAID).value == '' && $get(car_ddlCarBodyTypeID).value != '')
    {
        //car_errorSelectedCarShow();
        // Vehicule search field are filled but vehicule is not selected
        // Force vehicule window search to opend
        car_vehiculeSearchBtnClick();
        return false;
    }
    return true;
}

function car_vehiculeModifySelectedVehiculeClick() {
    $get(car_hfCarGTAID).value = "";
    hide(car_divSelectedVehiculeID);
    showRow(car_rowBtnSearchVehiculeID);
    setRowVisibility(car_rowCarValeurID, false);
    textBox_clearError(car_txtCarValeurID);
    /*
    showRow(car_rowCarCodeMakeID);
    showRow(car_rowCarTypeID);
    showRow(car_rowCarAlimID);
    showRow(car_rowCarBodyTypeID);
    showRow(car_rowCarPowerID);
    showRow(car_rowCarSelectionTitleId);
    */
    //hide(car_cellSubmitId);
    //$get(car_btnSearchVehiculeID).className = vehiculeButtonSearchOnCssClass;
    car_vehiculeSearchBtnClick();
}

function car_errorSelectedCarShow() {
    alert("Veuillez sélectionner un véhicule");  
}

function car_vehiculeSearchSort(sort)
{
    var FirstDrivingDate = car_getDateRef();
    var CodeMake=$get(car_ddlCarMakeID).value;
    var CarType=$get(car_ddlCarTypeID).value;
    var CarAlim=$get(car_ddlCarAlimID).value;  
    var CarBodyType=$get(car_ddlCarBodyTypeID).value;
    var CarPower=$get(car_ddlCarPowerID).value;
    if (CarPower=="")
        CarPower=IntNull;
    var searchType = $get(car_hfSearchTypeId).value;        
    car_vehiculeSearch(FirstDrivingDate, CodeMake, CarType, CarAlim, CarBodyType, CarPower,searchType,sort);
    return false;
}

function car_ddlCarCodeMakeClick()
{
    if ($get(car_ddlCarMakeID).length <2)
        dropDownList_onUpdate($get(car_ddlCarMakeID));
}
function car_ddlCarCodeMakeWarning()
{
    if ($get(car_ddlCarMakeID).length <2){
       if (car_addCarAge == "1") {
            return "Veuillez indiquez plus haut l'année de date d'achat prévue du véhicule";
        }
        else {
             return "Veuillez indiquez plus haut l'année de date de mise en circulation du véhicule";
        }
    }
    return "";
}
function car_rblCurrentGuaranteeCodeClick()
{
    if ((radioButtonList_getSelectedValue(car_rblCurrentGuaranteeCodeId) == "N") || (radioButtonList_getSelectedValue(car_rblIsNotContrStillRunning1Id) == "1" && car_insuranceNeed != 4))
        setInnerHtml(car_lblContractAnniverMthId, "Quel est le mois d'échéance de votre ancien contrat ?");
    else
        setInnerHtml(car_lblContractAnniverMthId, "Quel est le mois d'échéance de votre contrat actuel ?");
}
