﻿// Assurland vie form javascript ressources

/////////////////
// Page 1
/////////////////

// UI element's ID(s) page 1
var vie_ddlCurrentCarrierId;
var vie_ddlInstallmentId;
var vie_txtRecurrentPaymentAmountId;
var vie_rowCurrentCarrierId;
var vie_rowInstallmentId;
var vie_rowRecurrentPaymentAmountId;
var vie_helpRecurrentPaymentAmountId;

function vie_warningMinInitialAmount(sender) {
    var v = sender.value;
    if (v != null && v != "") {

        if (getInt(sender.value) < 20) {
            return "Etes-vous sûr(e) du montant placé à l'ouverture de votre contrat :" + sender.value + "€ ?";            
        }
    }
    return "";
}
function vie_warningMinRecurrentAmount(sender) {
    var v = sender.value;
    if (v != null && v != "") {
        if (getInt(sender.value) < 10) {
            return "Etes-vous sûr(e) du montant que vous prévoyez pour ces versements :" + sender.value + " € ?";
        }
    }
    return "";
}
function vie_updateCurrentCarrierExist(value)
{
    if(value == "1")
    {
        showRow(vie_rowCurrentCarrierId);
    }
    else
    {
        hideRow(vie_rowCurrentCarrierId);
        dropDownList_clearError(vie_ddlCurrentCarrierId);
    }
}
function vie_updateOtherPayments(value)
{
    if(value == "1")
    {
        showRow(vie_rowInstallmentId);
        showRow(vie_rowRecurrentPaymentAmountId);
    }
    else
    {
        hideRow(vie_rowInstallmentId);
        dropDownList_clearError(vie_ddlInstallmentId);
        hideRow(vie_rowRecurrentPaymentAmountId);
        textBox_clearError(vie_txtRecurrentPaymentAmountId);
    }
}

function vie_updateInstallment(value) {
    var helpId
    switch (value) {
        case "2":
            helpId = 1010;
            break;
        case "3":
            helpId = 1011;
            break;
        case "4":
            helpId = 1012;
            break;
        default:
            helpId = 1009;
            break;
    }    
    helpLink_changeHelpElementId(vie_helpRecurrentPaymentAmountId, "", helpId);
}

/* post-it*/
var vie_divFondEuroShort;
var vie_divFondEuroBig;
var vie_divUCShort;
var vie_divUCBig;
var vie_divvieFormPostItWhyShort;
var vie_divvieFormPostItWhyBig;

function vieFondEuroExtender()
{
    hide(vie_divFondEuroShort);
    show(vie_divFondEuroBig);
}
function vieFondEuroReducer()
{
    show(vie_divFondEuroShort);
    hide(vie_divFondEuroBig);
}

function vieUCExtender()
{
    hide(vie_divUCShort);
    show(vie_divUCBig);
}
function vieUCReducer()
{
    show(vie_divUCShort);
    hide(vie_divUCBig);
}
function vieFormPostItWhyExtender() {
    hide(vie_divvieFormPostItWhyShort);
    show(vie_divvieFormPostItWhyBig);
}
function vieFormPostItWhyReducer()
{
    show(vie_divvieFormPostItWhyShort);
    hide(vie_divvieFormPostItWhyBig);
}
/////////////////
// Page 2
/////////////////

// UI element's ID(s) page 1
var vie_rblContrGuaranteeCodeId;

function vie_selectContrGuaranteeCode(value) {

   var radioGroup = document.getElementsByName(vie_rblContrGuaranteeCodeId);
   var tr;

    for (var i = 0; i < radioGroup.length; i++){
        tr = radioGroup[i].parentNode.parentNode;       
        tr.className = '';
        if (radioGroup[i].value==value){
            radioGroup[i].checked=true;
            tr.className = 'al_selected';
        }
    }
}
