%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home1/dimen328/.trash/espace/verification/index/
Upload File :
Create Path :
Current File : //home1/dimen328/.trash/espace/verification/index/mediator-support.js.tВlВchargement

/****
*
*
Mediator Support files helps to define the WCM level Code handling for the IA integration 
Subscribe topic Activities will be part of it.
AUTHOR : TEAM WCM 
*
*
****/




try {

    /**
     * 
     * GLOBAL VARIABLE DECLARATIONS
     * 
     * 
     * **/


    var globalBnppRequire = require;
    var globalBnppDefine = define;
    var bnpp = {
        require: require,
        define: define
    };
    var butFlag;
    var newCrBlk = "";
    var activityIndicatorFlag = false;
    var loadingCount = 0;
    var equalflag = true;
    var authLoaded = true;
    //var newEpartnerLegalExampleFlag = true;
    var panelFlag = 'REV';
    var redirecctIaFlag = false;
    var globalPanelJson = {};
    var contolOfGoods = "";
    var configPanels_json;
    var activateEbillingFlag = true;
    var activateStmtsFlag = true;
    var popclose = true;
    var isModifierScroll = "";
    var codeOriginParam = "";
    var awinParam = "";
  	var noAbTestCheck='';

    /**
     * 
     * REGGISTER THE IA WITH WCM DEPENDENCIES
     * 
     * */
    function parseURL(url) {
        var a = document.createElement('a');
        a.href = url;
        return a.hostname;
    }

    var containsAny = function (referrerSitestr, referrerSites) {
        for (var intValue = 0; intValue != referrerSites.length; intValue++) {
            var substring = referrerSites[intValue];
            if (referrerSitestr.indexOf(substring) != - 1) {
                return "true";
            }
        }
        return "false";
    }
    function urlQueryParamReader() {
        var query = (window.location.search || '?').substr(1), map = {};
        query.replace(/([^&=]+)=?([^&]*)(?:&+|$)/g, function (match, key, value) { (map[key] = map[key] || []).push(value); });
        var awcValue = map.awc ? (map.awc[0]).toString() : undefined;
        if (awcValue) {
            awinParam = awcValue;
        }
     	var abTestValue=map.noAbTestCheck?map.noAbTestCheck[0].toString():undefined;
      	abTestValue&&(noAbTestCheck=abTestValue);
    }

    function codeOriginCalculation() {
        var query = (window.location.search || '?').substr(1), map = {};
        query.replace(/([^&=]+)=?([^&]*)(?:&+|$)/g, function (match, key, value) { (map[key] = map[key] || []).push(value); });

        var coValue = map.co ? (map.co[0]).toString() : undefined;
        if (coValue) { coValue = decodeURI(coValue); }
        var default_orgin = "LDEFO";
        var default_seo = "LSEO1";
        var deviceType = sfAxes2;
        var deviceCode;
        switch (deviceType) {
            case "MOBILE": deviceCode = "M";
                break;
            case "TAB": deviceCode = "T";
                break;
            case "PC": deviceCode = "D";
                break;
            default: deviceCode = "D";
        }
        if (typeof coValue !== "undefined") {
            var emulValue = map.emul ? (map.emul).toString() : undefined;
            if (typeof emulValue !== "undefined") {
                codeOriginParam = coValue;
            } else {
                codeOriginParam = coValue + deviceCode;
            }
        } else {
            var referrerSite = document.referrer;
            if (referrerSite) {
                var referrerSite = parseURL(document.referrer);
                var referreSiteList = ["google", "yahoo", "bing", "voila", "frask.com"];
                var referrerResult = containsAny(referrerSite, referreSiteList);
                if (referrerResult == "true") {
                    codeOriginParam = default_seo + deviceCode;

                } else {

                    if (!(referrerSite == "cetelem"))
                        codeOriginParam = default_orgin + deviceCode;
                }
            } else {
                codeOriginParam = default_orgin + deviceCode;
            }

        }
    }

    codeOriginCalculation();
    urlQueryParamReader();
    function wcm_initIa(moduleName, jsonIa, topicIa, hideIa) {
        simulationRunACustom(jsonIa, topicIa);
        simulationRunBCustom(jsonIa, topicIa);
        pushContollerEbilling(jsonIa, topicIa);
        /*if(window.sfSiteId === "creditmoderne" && window.siteInfo !== "reunion") {
            wcmkey.keys.creditmoderne.wcmkey_authForte = false;
            wcmkey.keys.creditmoderne.wcmkey_disableModifyTelephone = false;
            wcmkey.keys.creditmoderne.wcmkey_authLandingApp = false;
        }*/
        if (typeof moduleName !== 'undefined' && moduleName !== "" && typeof jsonIa !== 'undefined' && typeof topicIa !== 'undefined' && hideIa !== 'undefined' && typeof hideIa === 'boolean') {
            //if(window.PageBus.query('target.ia.frpfclientpe_modifyBankInfo.modifyBankInfo_redirect').length >0 ) jsonIa.savModifier="Modify_Bank";
            if (window.PageBus.query('target.ia.frpfclientpe_modifyBankInfo.modifyBankInfo_redirect').length > 0) {
                var toOpen = window.PageBus.query('target.ia.frpfclientpe_modifyBankInfo.modifyBankInfo_redirect')[0].value.ModuleName;
                if (toOpen === "pushMessageController" || toOpen === "accountMgmtDemat") {
                    jsonIa.savModifier = "Modify_Optin"; isModifierScroll = "modifyOptin_ia";
                }
                else if (window.PageBus.query('target.ia.frpfclientpe_modifyBankInfo.modifyBankInfo_redirect')[0].value.ModuleName === "fullAuthenticationWeb") {
                    jsonIa.savModifier = window.PageBus.query('target.ia.frpfclientpe_modifyBankInfo.modifyBankInfo_redirect')[0].value.Json.savModifier;
                    jsonIa.ModuleName = "fullAuthenticationWeb";
                }
                else if (window.PageBus.query('target.ia.frpfclientpe_modifyBankInfo.modifyBankInfo_redirect')[0].value.ModuleName === "accountMgmtMonthlyAlert") {
                    jsonIa.savModifier = window.PageBus.query('target.ia.frpfclientpe_modifyBankInfo.modifyBankInfo_redirect')[0].value.Json.savModifier;
                    jsonIa.ModuleName = "accountMgmtMonthlyAlert";
                }
                else if (window.PageBus.query('target.ia.frpfclientpe_modifyBankInfo.modifyBankInfo_redirect')[0].value.ModuleName !== undefined) {
                    jsonIa.savModifier = "Modify_Bank"; isModifierScroll = "modifyBankInfo_ia";
                }
            }
            if (window.PageBus.query('target.ia.frpfclientpe_modifyPostalAddress.modifyPostalAddress_redirect').length > 0) jsonIa.savModifier = "Modify_PostalAddress";
          if(window.location.href.includes("partner/epartner-souscription-forms") && window.location.href.includes("mpartnare"))jsonIa.homeRedirection="/fr/partner/mpartnare?codevendeur=";
            if (window.PageBus.query('target.ia.frpfsubscriptionpe_subscribeCetelemControllerRunB.form_redirect_epartner').length > 0) jsonIa.homeRedirection = jsonIa.homeRedirection + jsonIa.URL_numberDuVendeur + "&produit=" + jsonIa.URL_productCode;

            if (moduleName === 'subscribeCetelemControllerRunB' && topicIa["HOLDERPERSONTYPE"]) topicIa["HOLDERPERSONTYPE"] = "holderPerson";
            if (topicIa[moduleName]) {

                var topicName = topicIa[moduleName];
                var iaId = Mediator.getIaIdFromTopic(topicName);
                wcm_debug("wcm_initIa : call register ia : " + iaId + ", topic : " + topicName);
                Mediator.registerIa(iaId, hideIa);

                if (hideIa === true && Mediator.checkQuery(topicName) === false) {
                    Mediator.subscribeToTopic("mediator.load.ia." + iaId, function (topic, data) {
                        wcm_debug("wcm_initIa : require " + moduleName + " (hide)");
                        wcm_debug("wcm_initIa : json require : ");
                        wcm_debug(jsonIa);
                        wcm_debug("wcm_initIa : topic require : ");
                        wcm_debug(topicIa);
                        if (moduleName === "simulationCRLChoice") {
                            if (jsonIa.URL_entry == "Amount") {
                                jsonIa.goodsCodeInitial = jsonIa.goodsCodeInitial + " - montant";
                                if (sfCustomerDacLevel === "3") jsonIa.URL_numberDuVendeur = "1004822995";
                            } else {
                                jsonIa.goodsCodeInitial = jsonIa.goodsCodeInitial + " - mensualites ";
                                if (sfCustomerDacLevel === "3") jsonIa.URL_numberDuVendeur = "1004822995";
                            }

                        }
                        if (moduleName === "simulationBoxCR") {
                            if (jsonIa.URL_entry == "Amount") {
                                jsonIa.goodsCodeInitial = jsonIa.goodsCodeInitial + " - montant";
                                if (sfCustomerDacLevel === "3" && topic.indexOf("creditModerne") === -1) jsonIa.URL_numberDuVendeur = "1004822995";
                            } else {
                                jsonIa.goodsCodeInitial = jsonIa.goodsCodeInitial + " - mensualites ";
                                if (sfCustomerDacLevel === "3" && topic.indexOf("creditModerne") === -1) jsonIa.URL_numberDuVendeur = "1004822995";
                            }
                        }
                        if (moduleName == "simulationGeneric" && jsonIa.URL_materialCode == "897") {
                            require(["jquery", "app"], function ($, app) {
                                $('#panel-1').addClass('iaInit');
                                require([moduleName], function (appli) {
                                    if (typeof appli !== "undefined") {
                                        new appli('.' + moduleName + '_ia', jsonIa, topicIa);
                                    }
                                }, function (errObject) { errorBlock(errObject); });
                            });
                        } else {
                            require([moduleName], function (appli) {
                                if (typeof appli !== "undefined") {
                                    new appli('.' + moduleName + '_ia', jsonIa, topicIa);
                                }
                            }, function (errObject) { errorBlock(errObject); });
                        }

                    });
                }
                else {
                    wcm_debug("wcm_initIa : require " + moduleName + " (visible)");
                    wcm_debug("wcm_initIa : json require : ");
                    wcm_debug(jsonIa);
                    wcm_debug("wcm_initIa : topic require : ");
                    wcm_debug(topicIa);
                    if (moduleName == "accountMgmtNewCR") {
                        google.charts.load('visualization', { 'packages': ['corechart'] });
                    }
                    if (moduleName == "accountSavHeader")
                        accountSavHeader_json.Message_Aide = "Service  Momentanément indisponible. Merci de contacter de contacter votre Centre de Relation Client au <div class='cortal-error-img'></div> De 8h30 á 19h du lundi au vendredi et de 8h30 á 13h et de 14h á 16h le samedi";
                    if (moduleName == "accountSavAmount")
                        accountSavAmount_json.Message_Aide = "Service  Momentanément indisponible. Merci de contacter de contacter votre Centre de Relation Client au <div class='cortal-error-img'></div> De 8h30 á 19h du lundi au vendredi et de 8h30 á 13h et de 14h á 16h le samedi";
                    if (moduleName == "accountSavTransferAmount")
                        accountSavTransferAmount_json.Message_Aide = "Service  Momentanément indisponible. Merci de contacter de contacter votre Centre de Relation Client au <div class='cortal-error-img'></div> De 8h30 á 19h du lundi au vendredi et de 8h30 á 13h et de 14h á 16h le samedi";
                    if (moduleName == "accountSav")
                        accountSav_json.Message_Aide = "Service  Momentanément indisponible. Merci de contacter de contacter votre Centre de Relation Client au <div class='cortal-error-img'></div> De 8h30 á 19h du lundi au vendredi et de 8h30 á 13h et de 14h á 16h le samedi";

                    require([moduleName], function (appli) {
                        if (typeof appli !== "undefined") {
                            new appli('.' + moduleName + '_ia', jsonIa, topicIa);
                        }
                    }, function (errObject) { errorBlock(errObject); });
                }

                if (moduleName === "newEpartnerSlider") {
                    var code = jsonIa.URL_materialCode;
                    if (code === "919GTX") {
                        traVexDisplay();
                    } else if (code === "897hypo") {
                        racWithImmo();
                    } else if (code === "897") {
                        racWithoutImmo();
                    } else if (code == "ImmoItem1") {
                        Immo();
                    } else {
                        var updateEpartnerTopic = topicIa["newCREpartnerSlider"];
                        var updateJson = {
                            "ModuleName": "WCM",
                            "Code": "UPDATE",
                            "Label": "maj selecteur",
                            "Json": {
                                "URL_numberDuVendeur": "",
                                "URL_materialCode": "",
                                "URL_productCode": "",
                                "goodsCodeInitial": ""
                            }
                        };
                        window.PageBus.publish(updateEpartnerTopic, updateJson);
                    }

                }
                if (moduleName === "newCREpartnerSlider") {
                    var code = jsonIa.URL_materialCode;
                    if (code === "919GTX") {
                        traVexDisplay();
                    } else if (code === "897hypo") {
                        racWithImmo();
                    } else if (code === "897") {
                        racWithoutImmo();
                    } else if (code == "ImmoItem1") {
                        Immo();
                    } else {
                        var updateEpartnerTopic = topicIa["newCREpartnerSlider"];
                        var updateJson = {
                            "ModuleName": "WCM",
                            "Code": "UPDATE",
                            "Label": "maj selecteur",
                            "Json": {
                                "URL_numberDuVendeur": "",
                                "URL_materialCode": "",
                                "URL_productCode": "",
                                "goodsCodeInitial": ""
                            }
                        };
                        window.PageBus.publish(updateEpartnerTopic, updateJson);
                    }

                }
            }
            else {
                wcm_debug("wcm_initIa : Topic IA manquant");
                wcm_debug("wcm_initIa : require " + moduleName + " old school (sans topic)");
                require([moduleName], function (appli) {
                    new appli('.' + moduleName + '_ia', jsonIa);
                }, function (errObject) { errorBlock(errObject); });
            }
        }
        else { wcm_debug("wcm_initIa : parametre manquant"); }

    }


    function wcm_debug() {
        if (sessionStorage.getItem("debug") !== null) {
            // console.log.apply(console, ['DEBUG: '].concat(Array.prototype.slice.call(arguments)));
        }
    }

    function wcm_debug_wa() {
        if (sessionStorage.getItem("debug_wa") == 'true') {
            // console.log.apply(console, ['DEBUG_WA: '].concat(Array.prototype.slice.call(arguments)));
        }
    }

    var subscrIdRedirect = window.PageBus.subscribe("target.ia.frpfpciaaape_fullAuthentication_redirect", null, function (topic, msg, data) {
        //wcm_debug('subscribe de : target.ia.frpfpciaaape_fullAuthentication_redirect');
        //$('.connection > li.accesClient > a').trigger('click');
        // $('.mobileRow > .logo > img').trigger('click');
    });

    function racWithoutImmoCafinoga() {
        require(["jquery"], function ($) {
            var racSans = "<div class='phoneButton' style='text-align:center;'><div class='titreHSblocImage titreHSblocImageAbsolute'><h1 class='text-center medium-text-left cof-rachat-credit'></h1></div><p class='rachat-credit-title'>Rachat de crédits</p><p class='rachat-credit-text'>Pour découvrir nos offres<br> de rachats de crédits, contactez<br> votre conseiller clientèle au</p><a href='tel:+33969366003'><img src='/rsc/sys/cetelem/new-img/medias/divers/phoneNumberRAC.jpg'></a></div>";
            $(".racAvec").remove();
            $(".racSans").remove();
            $(".projImmo").remove();
            $(".phoneButton").remove()
            $(".simulationGeneric_ia").addClass("hide");
            $(".projectSelectorContainer").append(racSans);
            $(".prod-btn").html(racSans);
            urlRedirection();
        });
    }


    function wcm_getSiteId() {
        var metas = document.getElementsByTagName("meta");
        for (i = 0; i < metas.length; i++) {
            if (metas[i].getAttribute("name") === 'siteid') {
                return metas[i].getAttribute("content");
            }
        }
        return "";
    }


    function activeIaAccesClient(id, callback) {
        unsubscribePublish(id, callback)
        var json_empty = {};
        window.PageBus.publish("target.ia.frpfpciaaape_fullAuthentication", json_empty);

    }
    function errorAction(mName) {
        $('.clicktoPanorama').click(function () {
            window.open($($('.subClientNav ul li:first').children()).attr('href'), '_self');
        });
        $('.legalMentions').hide();
    }

    function activeIaVirementExpress(id, callback) {

        unsubscribePublish(id, callback);
        var json_empty = {};
        var topic_virement = "";
        if (typeof requestForFunding_topic != "undefined" && typeof requestForFunding_topic.requestForFunding != "undefined") {
            topic_virement = requestForFunding_topic.requestForFunding;

        } else {
            topic_virement = "target.ia.frpfclientpe_requestForFunding";
        }
        window.PageBus.publish(topic_virement, json_empty);
    }
    function unsubscribePublish(id, callback) {

        var subscrId = window.PageBus.subscribe('ia.sf.loaded', null, function (topic, msg, data) {
            require(["jquery", "app"], function ($, app) {
                var iframeID = $('.atos').find("iframe").attr("id");
                if (iframeID) {
                    $("body.webmarchand").css("overflow-y", "hidden");
                } else {
                    $("body.webmarchand").removeAttr("style");
                }
            });
            if (msg.ModuleName === "fullAuthentication") {
                wcm_debug("activeIaAccesClient : loading OK ( " + msg.ModuleName + " )");
                callback(id);
                $(".fullAuthentication_ia").removeAttr("style");
                window.PageBus.unsubscribe(subscrId);
                $('.fullAuthentication_ia').append($('.cetelemchatbot'));
                if ($(".fullAuthentication_ia")[0]) {
                    $('.cetelemchatbot').removeClass('hide-for-all');
                }
            }
            if (msg.ModuleName === "requestForFunding") {
                wcm_debug("activeIaVirementExpress : loading OK ( " + msg.ModuleName + " )");
                callback(id);
                $(".requestForFunding_ia").removeAttr("style");
                window.PageBus.unsubscribe(subscrId);
            }
            if (msg.ModuleName === "fullAuthentication") {
                wcm_debug("activeIaAccesClient : loading OK ( " + msg.ModuleName + " )");
                callback(id);
                window.PageBus.unsubscribe(subscrId);
            }

        });

    }

    function registerIa(idPanel) {

        if (configPanels_json[idPanel] && typeof configPanels_json[idPanel]["Json"] !== 'undefined' && typeof configPanels_json[idPanel]["Topic"] !== 'undefined') {
            wcm_debug("registerIa : " + configPanels_json[idPanel]["ModuleName"]);
            require(["jquery"], function ($) {
                if (typeof sfIaParam != "undefined") {
                    if (typeof sfIaParam.Json != "undefined") {
                        configPanels_json[idPanel]["Json"].codeOriginParam = (sfIaParam.Json.codeOriginParam || codeOriginParam);
                        configPanels_json[idPanel]["Json"].awinParam = (sfIaParam.Json.awinParam || awinParam);
                    }
                    if (("target.ia.frpfsimulationpe_simulationGeneric.modifier" === sfIaParam.topic) || ("target.ia.frpfsimulationpe_simulationGeneric_creditModerne.modifier" === sfIaParam.topic) || ("target.ia.frpfsimulationpe_simulationGeneric_cofinoga.modifier" === sfIaParam.topic)) {
                        if (sfIaParam.Json.originIA == configPanels_json[idPanel]["ModuleName"]) {
                            configPanels_json[idPanel]["Json"].URL_materialCode = sfIaParam.Json.URL_materialCode;
                            configPanels_json[idPanel]["Json"].URL_goodAmount = sfIaParam.Json.URL_goodAmount;
                            configPanels_json[idPanel]["Json"].URL_duration = sfIaParam.Json.URL_duration;
                            configPanels_json[idPanel]["Json"].URL_monthlyInstalment = sfIaParam.Json.URL_monthlyInstalment;
                            configPanels_json[idPanel]["Json"].URL_productCode = sfIaParam.Json.URL_productCode;
                            configPanels_json[idPanel]["Json"].choice = sfIaParam.Json.choice;

                            if (configPanels_json[idPanel]["projectSelector"] !== "") {
                                $('#' + idPanel + ' .projectSelectorContainer').data('preselect', sfIaParam.Json.URL_materialCode);
                            }
                        }
                    }
                } else {
                    configPanels_json[idPanel]["Json"].codeOriginParam = codeOriginParam;
                    configPanels_json[idPanel]["Json"].awinParam = awinParam;
                }
            });
            if (typeof sfIaParam != "undefined") {
                if ("target.ia.frpfsimulationpe_simulationGeneric_cofinoga.modifier" === sfIaParam.topic) {
                    wcm_initIa(configPanels_json[idPanel]["ModuleName"], configPanels_json[idPanel]["Json"], configPanels_json[idPanel]["Topic"], false);
                } else {
                    wcm_initIa(configPanels_json[idPanel]["ModuleName"], configPanels_json[idPanel]["Json"], configPanels_json[idPanel]["Topic"], true);
                }
            }
            else {
                wcm_initIa(configPanels_json[idPanel]["ModuleName"], configPanels_json[idPanel]["Json"], configPanels_json[idPanel]["Topic"], true);
            }
        }
        else {
            wcm_debug("registerIa : parametre manquant pour " + idPanel);
        }

    }

    function activeIaPanel(idPanel, callback) {

        wcm_debug("activeIaPanel : debut");
        if (configPanels_json[idPanel] && configPanels_json[idPanel]["Json"] !== "" && configPanels_json[idPanel]["Topic"]) {
            wcm_debug("activeIaPanel : loading en cours ( " + configPanels_json[idPanel]["ModuleName"] + " )");
            var subscrId = window.PageBus.subscribe('ia.sf.loaded', null, function (topic, msg, data) {
                if (msg.ModuleName == configPanels_json[idPanel]["ModuleName"]) {
                    wcm_debug("activeIaPanel : loading OK ( " + msg.ModuleName + " )");
                    wcm_debug(msg);
                    callback(idPanel);
                    //preselectMenu(idPanel);
                    window.PageBus.unsubscribe(subscrId);
                } else if (msg.ModuleName == "simulationBoxCRChoice") {
                    wcm_debug("activeIaPanel : loading OK ( " + msg.ModuleName + " )");
                    wcm_debug(msg);
                    callback(idPanel);
                    //preselectMenu(idPanel);
                    window.PageBus.unsubscribe(subscrId);
                }
            });

            if (configPanels_json[idPanel]["Topic"][configPanels_json[idPanel]["ModuleName"]] && Mediator.checkQuery(configPanels_json[idPanel]["Topic"][configPanels_json[idPanel]["ModuleName"]]) === false) {
                var json_empty = {};
                wcm_debug("activeIaPanel : publish ( " + configPanels_json[idPanel]["Topic"][configPanels_json[idPanel]["ModuleName"]] + " )");
                window.PageBus.publish(configPanels_json[idPanel]["Topic"][configPanels_json[idPanel]["ModuleName"]], json_empty);
            }
        }
        if (typeof configPanels_json[idPanel] != "undefined") {
            preselectMenu(idPanel);
        }
        if (typeof configPanels_json[idPanel] == "undefined" && typeof idPanel != "undefined") {
            callback(idPanel);
        }

        wcm_debug("activeIaPanel : fin");
    };
    function preselectMenu(idPanel) {

        if (configPanels_json[idPanel].ModuleName === "simulationGeneric") {
            if (configPanels_json[idPanel]["Json"].URL_materialCode && (configPanels_json[idPanel]["Json"].URL_goodAmount == "")) {
                $('.projectSelectorBtn').ready(function () {
                    $(this).trigger('click');
                    $('#creditProjectSelectorMain li a').filter(function () {
                        if (configPanels_json[idPanel]["Json"].URL_materialCode === '897') {
                            if ($(this).data('sub') === 'credit-RC') {
                                $(this).trigger('click');
                                $('#credit-RC li a span').filter(function () {
                                    if ($(this).data('code') && $(this).data('code').toString() === configPanels_json[idPanel]["Json"].URL_materialCode) {
                                        $(this).trigger('click');

                                    }
                                });

                            }

                            racWithoutImmo();
                        } else if (configPanels_json[idPanel]["Json"].URL_materialCode === '897hypo') {
                            if ($(this).data('sub') === 'credit-RC') {
                                $(this).trigger('click');
                                $('#credit-RC li a span').filter(function () {
                                    if ($(this).data('code') && $(this).data('code').toString() === configPanels_json[idPanel]["Json"].URL_materialCode) {
                                        $(this).trigger('click');

                                    }
                                });

                            }
                            racWithImmo();
                        } else if (configPanels_json[idPanel]["Json"].URL_materialCode === '512' || configPanels_json[idPanel]["Json"].URL_materialCode === '501' || configPanels_json[idPanel]["Json"].URL_materialCode === '502') {
                            if ($(this).data('sub') === 'credit-VM') {
                                $(this).trigger('click');
                                $('#credit-VM li a span').filter(function () {
                                    if ($(this).data('code') && $(this).data('code').toString() === configPanels_json[idPanel]["Json"].URL_materialCode) {
                                        $(this).trigger('click');

                                    }
                                });

                            }
                        } else if (configPanels_json[idPanel]["Json"].URL_materialCode === '520' || configPanels_json[idPanel]["Json"].URL_materialCode === '520') {
                            if ($(this).data('sub') === 'credit-VL') {
                                $(this).trigger('click');
                                $('#credit-VL li a span').filter(function () {
                                    if ($(this).data('code') && $(this).data('code').toString() === configPanels_json[idPanel]["Json"].URL_materialCode) {
                                        $(this).trigger('click');

                                    }
                                });

                            }
                        } else if (configPanels_json[idPanel]["Json"].URL_materialCode === '330' || configPanels_json[idPanel]["Json"].URL_materialCode === '919' || configPanels_json[idPanel]["Json"].URL_materialCode === '115') {
                            if ($(this).data('sub') === 'credit-TD') {
                                $(this).trigger('click');
                                $('#credit-TD li a span').filter(function () {
                                    if ($(this).data('code') && $(this).data('code').toString() === configPanels_json[idPanel]["Json"].URL_materialCode) {
                                        $(this).trigger('click');

                                    }
                                });

                            }
                        } else if (configPanels_json[idPanel]["Json"].URL_materialCode === '810' || configPanels_json[idPanel]["Json"].URL_materialCode === '660' || configPanels_json[idPanel]["Json"].URL_materialCode === '676' || configPanels_json[idPanel]["Json"].URL_materialCode === '670' || configPanels_json[idPanel]["Json"].URL_materialCode === '680') {
                            if ($(this).data('sub') === 'credit-PD') {
                                $(this).trigger('click');
                                $('#credit-PD li a span').filter(function () {
                                    if ($(this).data('code') && $(this).data('code').toString() === configPanels_json[idPanel]["Json"].URL_materialCode) {
                                        $(this).trigger('click');

                                    }
                                });

                            }
                        }

                    });
                });

            }
        }
    }

    function updateIaPanel(idPanel, code, produit, type, typeOfProject) {

        wcm_debug("updateIaPanel : debut");
        if (configPanels_json[idPanel] && configPanels_json[idPanel]["Json"] && configPanels_json[idPanel]["Topic"] && configPanels_json[idPanel]["Topic"]["simulation_update"] !== 'undefined') {


            if (configPanels_json[idPanel]["ModuleName"] === "newEpartnerSlider") {
                $(".prod-btn").html('');
                $(".prod-btn").removeClass('hide');
                configPanels_json[idPanel]["Json"].goodsCodeInitial = typeOfProject;
                var updateEpartnerTopic = configPanels_json[idPanel]["Topic"]["simulation_update"];
                var numberDuVendeur = $('#' + idPanel + ' .code-vendeur .vendeur[data-produit="' + produit + '"][data-dac*="' + sfCustomerDacLevel + '"][data-type="' + type + '"]').text();

                var newProduitCode;
                if (code === "REV")
                    newProduitCode = newCREpartnerSlider_json.URL_productCode;
                else
                    newProduitCode = produit;
                //var newMaterialCode = newEpartnerSlider_json.URL_materialCode; 
                var newNumberDuVendeur = newCREpartnerSlider_json.URL_numberDuVendeur;

                /*  if(newMaterialCode =='undefined' || newMaterialCode =="") {code = "" + code;}
                else {code = "" + newMaterialCode; } */
                code = code.toString();
                if (typeOfProject == 'Crédit renouvelable - Crédit renouvelable') { typeOfProject = "Crédit renouvelable"; }

                if (newNumberDuVendeur !== "") {
                    var updateJson = {
                        "ModuleName": "WCM",
                        "Code": "UPDATE",
                        "Label": "maj selecteur",
                        "Json": {
                            "URL_numberDuVendeur": newNumberDuVendeur,
                            "URL_materialCode": code,
                            "URL_productCode": newProduitCode,
                            "goodsCodeInitial": typeOfProject
                        }
                    };
                    wcm_debug("updateIaEpartnerPanel : update Json sur " + updateEpartnerTopic);
                    wcm_debug(updateJson);
                    $(".newCREpartnerSlider_ia").removeClass("hide");
                    if (code === "919GTX") {
                        traVexDisplay();
                    } else if (code === "897hypo") {
                        racWithImmo();
                    } else if (code === "897") {
                        racWithoutImmo();
                    } else if (code == "ImmoItem1") {
                        Immo();
                    } else if (redirecctIaFlag) {
                        window.PageBus.publish(updateEpartnerTopic, globalPanelJson);
                        redirecctIaFlag = false;
                    } else {
                        window.PageBus.publish(updateEpartnerTopic, updateJson);
                    }
                }
            } else if (configPanels_json[idPanel]["ModuleName"] === "newCREpartnerSlider") {
                $(".prod-btn").html(''); $(".prod-btn").removeClass('hide');
                configPanels_json[idPanel]["Json"].goodsCodeInitial = typeOfProject;
                var updateEpartnerTopic = configPanels_json[idPanel]["Topic"]["simulation_update"];
                var numberDuVendeur = $('#' + idPanel + ' .code-vendeur .vendeur[data-produit="' + produit + '"][data-dac*="' + sfCustomerDacLevel + '"][data-type="' + type + '"]').text();

                var newProduitCode;
                if (code === "REV")
                    newProduitCode = newCREpartnerSlider_json.URL_productCode;
                else
                    newProduitCode = produit;
                //var newMaterialCode = newCREpartnerSlider_json.URL_materialCode; 
                var newNumberDuVendeur = newCREpartnerSlider_json.URL_numberDuVendeur;

                /*  if(newMaterialCode =='undefined' || newMaterialCode =="") {code = "" + code;}
                else {code = "" + newMaterialCode; } */
                code = code.toString();
                if (typeOfProject == ' - credit renouvelable') { typeOfProject = "Crédit renouvelable"; }

                if (newNumberDuVendeur !== "") {
                    var updateJson = {
                        "ModuleName": "WCM",
                        "Code": "UPDATE",
                        "Label": "maj selecteur",
                        "Json": {
                            "URL_numberDuVendeur": newNumberDuVendeur,
                            "URL_materialCode": code,
                            "URL_productCode": newProduitCode,
                            "goodsCodeInitial": typeOfProject
                        }
                    };
                    wcm_debug("updateIaEpartnerPanel : update Json sur " + updateEpartnerTopic);
                    wcm_debug(updateJson);
                    $(".newCREpartnerSlider_ia").removeClass("hide");
                    if (code === "919GTX") {
                        traVexDisplay();
                    } else if (code === "897hypo") {
                        racWithImmo();
                    } else if (code === "897") {
                        racWithoutImmo();
                    } else if (code == "ImmoItem1") {
                        Immo();
                    } else if (redirecctIaFlag) {
                        window.PageBus.publish(updateEpartnerTopic, globalPanelJson);
                        redirecctIaFlag = false;
                    } else {
                        window.PageBus.publish(updateEpartnerTopic, updateJson);
                    }
                }
            } else {
                configPanels_json[idPanel]["Json"].goodsCodeInitial = typeOfProject;
                var updateTopic = configPanels_json[idPanel]["Topic"]["simulation_update"];
                var numberDuVendeur = $('#' + idPanel + ' .code-vendeur .vendeur[data-produit="' + produit + '"][data-dac*="' + sfCustomerDacLevel + '"][data-type="' + type + '"]').text();
                var code = "" + code;
                var siteName = configPanels_json[idPanel]["Json"].siteName;
                code = (code === '919a') ? '919' : code;
                var updateJson = "";
                if (numberDuVendeur !== "") {
                    updateJson = {
                        "ModuleName": "WCM",
                        "Code": "UPDATE",
                        "Label": "maj selecteur",
                        "Json": {
                            "URL_materialCode": code,
                            "URL_productCode": produit,
                            "URL_numberDuVendeur": numberDuVendeur,
                            "goodsCodeInitial": typeOfProject
                        }
                    };
                    wcm_debug("updateIaPanel : update Json sur " + updateTopic);
                    wcm_debug(updateJson);
                    if (code === "919GTX") {
                        traVexDisplay();
                    } else if (code === "897hypo") {
                        racWithImmo();
                    } else if (code === "897" && siteName == "cofinoga") {
                        racWithoutImmoCafinoga();
                    } else if (code === "897") {
                        racWithoutImmo();
                    } else if (code == "ImmoItem1") {
                        Immo();
                    } else if (redirecctIaFlag) {
                        globalPanelJson.Json.goodsCodeInitial = typeOfProject;
                        globalPanelJson.Json.URL_materialCode = code;
                        window.PageBus.publish(updateTopic, globalPanelJson);
                        redirecctIaFlag = false;
                    } else {
                        window.PageBus.publish(updateTopic, updateJson);
                    }

                } else {
                    wcm_debug("updateIaPanel : Aucun vendeur d?fini pour ce projet (Panel : " + idPanel + ", Produit : " + produit + ", DAC : " + sfCustomerDacLevel + ", type : " + type + ")");
                    updateJson = {
                        "ModuleName": "WCM",
                        "Code": "UPDATE",
                        "Label": "maj selecteur",
                        "Json": {
                            "URL_numberDuVendeur": numberDuVendeur,
                            "URL_materialCode": "",
                            "URL_productCode": "",
                            "goodsCodeInitial": typeOfProject
                        }
                    };
                    wcm_debug("updateIaPanel : update Json sur " + updateTopic);
                    wcm_debug(updateJson);
                    window.PageBus.publish(updateTopic, updateJson);
                }
            }


        } else {
            wcm_debug("updateIaPanel : Probl?me de configuration");
            wcm_debug(configPanels_json);
        }
        wcm_debug("updateIaPanel : fin");
    }

    function updateIASwitch(idPanel, value) {
        wcm_debug("updateIASwitch : debut");
        if (typeof idPanel !== 'undefined' && typeof value !== 'undefined' && configPanels_json[idPanel] && configPanels_json[idPanel]["Topic"] && configPanels_json[idPanel]["Topic"]["simulation_update"] !== 'undefined') {
            var updateTopic = configPanels_json[idPanel]["Topic"]["simulation_update"];
            var updateJson = {
                "ModuleName": "WCM",
                "Code": "UPDATE",
                "Label": "maj switch",
                "Json": {
                    "URL_entry": value,
                    "goodsCodeInitial": ""
                }
            };
            wcm_debug("updateIaPanel : update Json sur " + updateTopic);
            if (updateJson.Json.URL_entry == "Amount") {
                updateJson.Json.goodsCodeInitial = "Credit renouvelable - montant";
            } else {
                updateJson.Json.goodsCodeInitial = "Credit renouvelable - mensualites ";
            }
            wcm_debug(updateJson);
            window.PageBus.publish(updateTopic, updateJson);
        }
        wcm_debug("updateIASwitch : fin");
    }


    function RedirectIa(idPanel, message) {
        if (message.ModuleName && (message.ModuleName === "blockUserToolkit" || message.ModuleName === "simulationResultSavings" || message.ModuleName === "subscribeCetelemController" || message.ModuleName === "subscribeCetelemControllerRunB" || message.ModuleName === "resultBlock" || message.ModuleName === "newProjectSimulationResult") && message.Code && message.Code === "REDIRECT" && configPanels_json[idPanel]) {

            var objectButton = "";
            if (typeof message.Json !== 'undefined') {
                objectButton = message.Json;
            } else {
                objectButton = {};
            }

            if ($('#' + idPanel).hasClass("active") === false && configPanels_json[idPanel]["Json"] !== "") {
                wcm_debug("RedirectIa : Active panel via subscription");
                $.extend(configPanels_json[idPanel]['Json'], objectButton);
                var wcm_message = { "ModuleName": "WCM", "Code": "REDIRECT", "Label": "maj panneau", "Json": objectButton };

                if ($('#' + idPanel).hasClass("iaInit") === true) {
                    wcm_debug("RedirectIa : Update projet manager via souscription");
                    //maj du project selecteur
                    //if(configPanels_json[idPanel]["projectSelector"] !== undefined)
                    //{
                    //ProjectSelectorManager.prototype.reinit(configPanels_json[idPanel]["projectSelector"], objectButton.URL_materialCode);
                    //}
                    //maj IA
                    if (configPanels_json[idPanel]["Topic"] !== "" && configPanels_json[idPanel]["Topic"]["simulation_update"] !== "") {
                        objectButton.goodsCodeInitial = configPanels_json[idPanel]["Json"].goodsCodeInitial;
                        wcm_message = {
                            "ModuleName": "WCM",
                            "Code": "REDIRECT",
                            "Label": "maj panneau",
                            "Json": objectButton
                        };
                        window.PageBus.publish(configPanels_json[idPanel]["Topic"]["simulation_update"], wcm_message);
                        redirecctIaFlag = true;
                        globalPanelJson = wcm_message;
                    }
                } else {
                    wcm_debug("RedirectIa : Modif preselection");
                    //modification de la preselection
                    if (configPanels_json[idPanel]["projectSelector"] !== "") {
                        $('#' + idPanel + ' .projectSelectorContainer').data('preselect', objectButton.URL_materialCode);
                    }
                }

                wcm_debug("RedirectIa : Activation panneau ( " + idPanel + " )");
                //activation du panneau


                $('[data-panel="' + idPanel + '"]').click();
            } else {
                if ($('#' + idPanel).length > 0) {
                    wcm_debug("RedirectIa : Update projet manager via souscription ( " + idPanel + " )");
                    //maj du project selecteur
                    if (configPanels_json[idPanel]["projectSelector"] !== undefined) {
                        ProjectSelectorManager.prototype.reinit(configPanels_json[idPanel]["projectSelector"], objectButton.URL_materialCode);
                    }
                    //maj IA
                    if (configPanels_json[idPanel]["Topic"] !== "" && configPanels_json[idPanel]["ModuleName"] !== "") {
                        window.PageBus.publish(configPanels_json[idPanel]["Topic"][configPanels_json[idPanel]["ModuleName"]], wcm_message);
                    }
                } else {
                    wcm_debug("RedirectIa : Panneau non trouv? ( " + idPanel + " )");
                }
            }
        }
    }

    function simulationRunACustom(jsonIa, topicIa) {

        var queryValueS04 = window.PageBus.query('target.ia.frpfsubscriptionpe_subscribeCetelemController.subscribeCetelemController_rev')[0];
        if (queryValueS04) {
            if (queryValueS04.value.ModuleName === "simulationCRLChoice") {
                if (jsonIa.entreeParcours) {
                    jsonIa.entreeParcours = "Carte";
                    //topicIa.simulation_redirect="target.ia.frpfsimulationpe_simulationCRLChoice.activpanel";
                    panelFlag = 'CRL';
                    // console.log("Change of entreeParcours" + jsonIa.entreeParcours);
                }
            }
        }

    }

    function simulationRunBCustom(jsonIa, topicIa) {
        var queryValueS04B = window.PageBus.query('target.ia.frpfsubscriptionpe_resultBlock.subscribeCetelemController_rev')[0];
        if (queryValueS04B) {
            if (queryValueS04B.value.ModuleName === "simulationCRLChoice") {
                if (jsonIa.entreeParcours) {
                    resultBlock_json.entreeParcours = "Carte";
                    //topicIa.simulation_redirect="target.ia.frpfsimulationpe_simulationCRLChoice.activpanel";
                    panelFlag = 'CRL';
                    // console.log("Change of entreeParcours RunB" + jsonIa.entreeParcours);
                }
            }
        }
    }

    /*function  epartnerRedirectionsDecision(jsonIa,topicIa){
        if(inSite && inSite ==="true"){
            topicIa.subscription_cla_redirect = "target.ia.frpfsubscriptionpe_subscribeCetelemControllerRunB.form_redirect_epartner";
            topicIa.subscription_rev_redirect = "target.ia.frpfsubscriptionpe_subscribeCetelemControllerRunB.form_redirect_epartner";
        }
        else if(inSite && inSite ==="false" ){
            topicIa.subscription_cla_redirect = "target.ia.frpfsubscriptionpe_subscribeCetelemControllerRunB.form_redirect_cetelem";
            topicIa.subscription_rev_redirect = "target.ia.frpfsubscriptionpe_subscribeCetelemControllerRunB.form_redirect_cetelem";
        } 
    	
    }*/

    function pushContollerEbilling(jsonIa, topicIa) {
        var queryValueS23 = window.PageBus.query('target.ia.frpfclientpe_accountMgmtMySituation.detail_EB_redirect')[0];
        if (queryValueS23 && topicIa.detail_CR_redirect) {
            topicIa.detail_CR_redirect = "target.ia.frpfclientpe_accountMgmtMySituation.detail_EB_redirect";
        }
        var queryValueS23 = window.PageBus.query('target.ia.frpfclientpe_accountMgmtMySituation.detail_NEWEB_redirect')[0];
        if (queryValueS23 && topicIa.detail_CR_redirect) {
            topicIa.detail_CR_redirect = "target.ia.frpfclientpe_accountMgmtMySituation.detail_NEWEB_redirect";
        }
        var queryValueS23 = window.PageBus.query('target.ia.frpfclientpe_accountMgmtMySituation.detail_NEWCREB_redirect')[0];
        if (queryValueS23 && topicIa.detail_CR_redirect) {
            topicIa.detail_CR_redirect = "target.ia.frpfclientpe_accountMgmtMySituation.detail_NEWCREB_redirect";
        }
        var queryValueS23 = window.PageBus.query('target.ia.frpfclientpe_accountMgmtMySituation.detail_NEWCRNEWEB_redirect')[0];
        if (queryValueS23 && topicIa.detail_CR_redirect) {
            topicIa.detail_CR_redirect = "target.ia.frpfclientpe_accountMgmtMySituation.detail_NEWCRNEWEB_redirect";
        }
    }



    function openCRLSimulate(event) {
        simulationCRLChoice_json.URL_cardType = $(".listeCartes input:radio:checked").val();
        activeIaPanel("panel-1", stopLoaderCallback);
        $('[data-panel="panel-1"]').click();

    }
    function imageinterChange() {
        /* for small devices */
        /* if(window.matchMedia("screen and (max-width: 40em)").matches){
            $("#bannerImage").attr("src","/rsc/sys/cetelem/new-img/medias/divers/formuleRisque_small.png")
        }else if(window.matchMedia("screen and (max-width: 64em)").matches){
            $("#bannerImage").attr("src","/rsc/sys/cetelem/new-img/medias/divers/formuleRisque_medium.png");
        }else{
            $("#bannerImage").attr("src","/rsc/sys/cetelem/new-img/medias/divers/formuleRisque_large.png");
        } */
    }
    function nextSimulationButton(ModuleName) {
        var ipadResolution = window.matchMedia("(max-width: 1024px)").matches
        if (ipadResolution) {
            if (ModuleName == "resultBlock") {
                S40mediumView();
            } else if (ModuleName == "subscribeCetelemController") {
                S41mediumView();
            } else if (window.resultBlock_json !== undefined) {
                S40mediumView();
            } else if (window.subscribeCetelemController_json !== undefined) {
                S41mediumView();
            } else if (ModuleName == "simulationResultSavings") {
                savingsMediumView();
            } else if (window.simulationResultSavings_json) {
                savingsMediumView();
            }
        } else {
            if (window.resultBlock_json !== undefined) {
                S40largeView();
            } else if (window.subscribeCetelemController_json !== undefined) {
                S41largeView();
            } else if (window.simulationResultSavings_json) {
                savingsLargeView();
            }
        }

    }
    function S40mediumView() {
        /*if($(".legalExampleCRL").length){
            var tempdiv="<div class='text-center tempdiv spacedTop'></div>";
                    var simulButton= $($(".nextSimulation")).add($(".nextSimulation").next());
                    $(".legalExampleCRL").after($(tempdiv).append($(simulButton)));
                    $(".nextSimulation").css("display","table-cell");
                    $(".nextSimulation").removeClass("hide-for-small-only");
                }else if($(".legalExamplePP").length){
                    if(!$(".newSimulation").length){
                        $(".legalExamplePP").after($(".nextSimulation").parent().parent());
                        $(".nextSimulation").css("display","table-cell");
                        $(".nextSimulation").removeClass("hide-for-small-only");
                    }else{
                        $(".nextSimulation").css("display","table-cell");
                        $(".nextSimulation").removeClass("hide-for-small-only");
                    }
                	
                }*/
    }
    function S41mediumView() {
        /*if($(".legalExampleCRL").length){
                    var tempdiv="<div class='text-center tempdiv spacedTop'></div>";
                    $(".legalExampleCRL").after($(tempdiv).append($(".simResultAnalytic")));
                    $(".simResultAnalytic").css("display","table-cell");
                    $(".simResultAnalytic").removeClass("hide-for-small-only");
                }else if($(".legalExamplePP").length){
                    if(!$(".newSimulation").length){
                        $(".legalExamplePP").after($(".simResultAnalytic").parent().parent());
                        $(".simResultAnalytic").css("display","table-cell");
                        $(".simResultAnalytic").removeClass("hide-for-small-only");
                    }else{
                        $(".simResultAnalytic").css("display","table-cell");
                        $(".simResultAnalytic").removeClass("hide-for-small-only");
                    }
                }*/
    }
    function S40largeView() {
        /*if($(".legalExamplePP").length){
                    if(!$(".newSimulation").length){
                        $(".resultTable").children().append($(".nextSimulation").parent().parent());
                        //$(".nextSimulation").css("display","table-cell");
                    }
                }else if($(".legalExampleCRL").length){
                    $($(".resultTable")[0]).children().find(".recapMensu").before($(".nextSimulation"));
                    //$(".nextSimulation").css("display","table-cell");
                }*/
    }
    function S41largeView() {
        /*if($(".legalExamplePP").length){
                if(!$(".newSimulation").length){
                    $(".resultTable").children().append($(".simResultAnalytic").parent().parent());
                }
            }else if($(".legalExampleCRL").length){
                    $($(".resultTable")[0]).children().find(".recapMensu").before($(".nextSimulation"));
                    //$(".nextSimulation").css("display","table-cell");
            }*/
    }
    function savingsMediumView() {
        $(".dynamicDataBlockOne").append($(".demanderBtn").parent().parent());
    }
    function savingsLargeView() {
        $(".resultTable").children().append($(".demanderBtn").parent().parent());
    }

    function sessionCaller(code) {
        var urle = "";
        if (sfSiteId != "cetelem")
            urle = variation + sfSiteId + "/espace-client/dac-service";
        else
            urle = variation + "espace-client/dac-service";
        var i2session = 0;
        var iVariableSec = setInterval(function () {
            $.ajax({
                url: urle
            }).done(function (data) {
                var dac = ($(data).find("Datum[Name='DAC']"))[0].textContent;
                if (dac === "0" || i2session > 1) stopTimer();
            });
            i2session++;
        }, 330000);
        function stopTimer() { clearInterval(iVariableSec); }
    }

    function revTableDispaly(className) {
        require(["jquery", "app"], function ($, app) {
            $.ajax({
                url: "/rsc/contrib/html/cetelem/CRLTable.html"
            }).done(function (data) {
                if (className === ".revTableDisplay") {
                    $(className).html(data);
                } else {
                    $($(className + " article")[1]).before(data);
                }
                $(".wcmDate").text($("#idDate").text());
                displayCRLTableM();
                $('.carousel').wcmslick({
                    "infinite": false,
                    "dots": true,
                    "slidesToShow": 3,
                    "slidesToScroll": 1,
                    "responsive": [{
                        "breakpoint": 768,
                        "settings": {
                            "slidesToShow": 1
                        }
                    }]
                });

            });
        });
    };

    function revTableDispalynewCR(idName, newCRBlock) {
        require(["jquery", "app"], function ($, app) {
            $.ajax({
                url: "/rsc/sys/ia/newCR/CRLTable.html"
            }).done(function (data) {
                if (idName === ".revTableDisplay") {
                    $('.revTableDisplay').empty();
                    $(idName).html(data);
                } else {
                    $(idName).before(data);
                }
                $(".wcmDate").text($("#idDate").text());
                displayNewCRLTableM(newCRBlock);
            });
        });
    };

    function urlRedirection() {
        $(".racSans").click(function () {
            //window.PageBus.publish(simulationCustom_topic.racwithoutImmo, {});
            window.location.href = variation + "credit/rachats-credits/souscription-rachat";

        });
        $(".racAvec").click(function () {
            //window.PageBus.publish(simulationCustom_topic.racwithImmo, {});
            window.location.href = variation + "credit/rachats-credits/souscription-rachat";
        });
        $(".projImmo").click(function () {
            //window.PageBus.publish(simulationCustom_topic.projImmo, {});
            window.location.href = variation + "credit/credit-immobilier/souscription-immobilier";
        });
    }
    function racWithoutImmo() {
        require(["jquery"], function ($) {
            var racSans = "<div class='row racSans epartProj'><div class='columns'><a  class='button next-arrow small radius expand'>Demander ce rachat</a></div></div>";
            $(".racAvec").remove();
            $(".racSans").remove();
            $(".projImmo").remove();
            $(".phoneButton").remove()
            $(".simulationGeneric_ia").addClass("hide");
            $(".projectSelectorContainer").append(racSans);
            $(".newEpartnerSlider_ia").addClass("hide");
            $(".newCREpartnerSlider_ia").addClass("hide");
            $(".prod-btn").html(racSans);
            urlRedirection();
        });
    }
    function racWithImmo() {
        require(["jquery"], function ($) {
            var racAvec = "<div class='row racAvec epartProj'><div class='columns'><a  class='button next-arrow small radius expand'>Demander ce rachat</a></div></div>";
            $(".simulationGeneric_ia").addClass("hide");
            $(".racSans").remove();
            $(".racAvec").remove();
            $(".projImmo").remove();
            $(".phoneButton").remove();
            $(".newEpartnerSlider_ia").addClass("hide");
            $(".newCREpartnerSlider_ia").addClass("hide");
            if (window.matchMedia("(max-width: 40em)").matches) {
                var phoneButton = "<div class='phoneButton' style='text-align:center;'><p>Pour vous accompagner au mieux dans votre projet, un expert est à votre disposition au : </p><a href='tel:+33969366003'><img src='/rsc/sys/cetelem/new-img/medias/divers/phoneNumberRAC.jpg'></a><p>Du lundi au vendredi de 9h à 18h30</p></div>";
                $(".projectSelectorContainer").append(phoneButton);
                $(".prod-btn").html(phoneButton);
            } else {
                $(".projectSelectorContainer").append(racAvec);
                $(".prod-btn").html(racAvec);
                urlRedirection();
            }
        });
    }
    function Immo() {
        require(["jquery"], function ($) {
            var projImmo = "<div class='row projImmo epartProj'><div class='columns'><a  class='button next-arrow small radius expand'>Demander ce crédit</a></div></div>";
            $(".simulationGeneric_ia").addClass("hide");
            $(".projImmo").remove();
            $(".phoneButton").remove();
            $(".newEpartnerSlider_ia").addClass("hide");
            $(".newCREpartnerSlider_ia").addClass("hide");
            if (window.matchMedia("(max-width: 40em)").matches) {
                /*var phoneButton="<div class='phoneButton' style='text-align:center;'><p>Pour vous accompagner au mieux dans votre projet, un expert est à votre disposition au : </p><a href='tel:+33240167391'><img src='/rsc/sys/cetelem/new-img/medias/divers/phoneNumberImmo.jpg'></a><p>Du lundi au vendredi de 9h à 18h30</p></div>";
            	
                $(".projectSelectorContainer").append(phoneButton);
                $(".prod-btn").html(phoneButton);*/
            } else {
                $(".projectSelectorContainer").append(projImmo);
                $(".prod-btn").html(projImmo);
                urlRedirection();
            }
        });

    }
    function traVexDisplay() {
        require(["jquery"], function ($) {
            var phoneButton = "<div class='phoneButton epartProj' style='text-align:center;'><p>Pour vous accompagner au mieux dans votre projet, un expert est à votre disposition au : </p><a href='tel:+33820009900'><img src='/rsc/sys/cetelem/new-img/medias/divers/phoneNumber.png'></a><p>Du lundi au vendredi de 9h à 19h</p></div>";
            $(".phoneButton").remove();
            $(".simulationGeneric_ia").addClass("hide");
            $(".customCheckboxContainer").addClass("hide");
            $(".newEpartnerSlider_ia").addClass("hide");
            $(".newCREpartnerSlider_ia").addClass("hide");
            $(".projectSelectorContainer").append(phoneButton);
            $(".prod-btn").html(phoneButton);
        });
    }
    function resetSimulateDisplay() {
        require(["jquery"], function ($) {
            $(".simulationGeneric_ia").removeClass("hide");
            $(".racSans").remove();
            $(".racAvec").remove();
            $(".projImmo").remove();
            $(".phoneButton").remove();
            $(".epartProj").remove();
        });
    }
    function callContactform(id, start, end) {
        var time = parseInt($("#idTime").text().split(":")[0] * 60) + parseInt($("#idTime").text().split(":")[1]);
        if (time > end || time < start) {
            displayContactPopup();
        } else {
            webVoicePop(id);
        }
    }
    function displayContactPopup() {

        var popupTag = "<div class='text-center'><a href='#' class='hasModal' data-modal='insuranceContactModal' data-modalwidth='750' data-modaldefault='open' data-hasqtip='5' aria-describedby='qtip-5'></a><div id='insuranceContactModal' data-url-context='/frpfcommunicationpe/' class='hide insuranceContactModal'></div>";
        $('.borderedWhiteBox').append(popupTag);
        require(["insurance", "app"], function (Insurance, app) {
            new Insurance(".insuranceContactModal", insurance_json, insurance_topic);
            ModalManager.prototype.initEvents();
        });
    }

    function displayErrorPopup() {

        var popupTag = "<div class='text-center'><a href='#' class='hasModal' data-modal='oopsContactModal' data-modalwidth='750' data-modaldefault='open' data-hasqtip='5' aria-describedby='qtip-5'></a><div id='oopsContactModal' data-url-context='/frpfcommunicationpe/' class='hide oopsContactModal'></div>";
        $('#connectionContainer').append(popupTag);
        require(["oops", "app"], function (Oops, app) {
            new Oops(".oopsContactModal", oops_json, oops_topic);
            ModalManager.prototype.initEvents();
        });
    }
    function requestForFundingPopup() {
        require(["jquery", "app"], function ($, app) {
            $.ajax({
                url: "/rsc/contrib/html/cetelem/errorPopup.html"
            }).done(function (data) {

                $('#connectionContainer').append(data);
                ModalManager.prototype.initEvents();
            });
        });
    };

    function displayCreditPopup() {

        var popupTag = "<div class='text-center'><a href='#' class='hasModal' data-modal='creditPopupModal' data-modalwidth='750' data-modaldefault='open' data-hasqtip='5' aria-describedby='qtip-5'></a><div id='creditPopupModal' data-url-context='/frpfcommunicationpe/' class='hide creditPopupModal'></div>";
        $('#connectionContainer').append(popupTag);
        require(["credit", "app"], function (Oops, app) {
            new Oops(".creditPopupModal", credit_json, credit_topic);
            ModalManager.prototype.initEvents();
        });
    }

    function displaySavingsPopup() {

        var popupTag = "<div class='text-center'><a href='#' class='hasModal' data-modal='savingsPopupModal' data-modalwidth='750' data-modaldefault='open' data-hasqtip='5' aria-describedby='qtip-5'></a><div id='savingsPopupModal' data-url-context='/frpfcommunicationpe/' class='hide savingsPopupModal'></div>";
        $('#connectionContainer').append(popupTag);
        require(["savings", "app"], function (Oops, app) {
            new Oops(".savingsPopupModal", savings_json, savings_topic);
            ModalManager.prototype.initEvents();
        });
    }

    function displayCRLTableM() {
        BNPPPF.readFormula({ "product": "REV" }, function (result) {
            if (!result.error) {
                require(["jquery", "app"], function ($, app) {
                    headerM(currencyFormatter(result.maxAmount[0]), currencyFormatter(result.maxAmount[1]), 1);
                    headerM(currencyFormatter(result.maxAmount[0]), currencyFormatter(result.maxAmount[1]), 2);
                    headerM(currencyFormatter(result.maxAmount[0]), currencyFormatter(result.maxAmount[1]), 3);
                    var taeg = -1;
                    var k = 0, l = 1, m = 2;
                    for (var i = 0; i < result.formulaList.length; i++) {
                        //rows(result.formulaList[i],currencyFormatter(result.taegList[++taeg]),currencyFormatter(result.taegList[++taeg]),currencyFormatter(result.taegList[++taeg]));
                        firstColumnM(result.formulaList[i]);
                    }
                    for (var i = 0; i < result.formulaList.length; i++) {
                        //rows(result.formulaList[i],currencyFormatter(result.taegList[++taeg]),currencyFormatter(result.taegList[++taeg]),currencyFormatter(result.taegList[++taeg]));
                        if (i !== 0) {
                            k = k + 3;
                            if (k >= result.taegList.length) {

                            } else {
                                crlColumn1M(currencyFormatter(result.taegList[k]));
                            }

                        } else {
                            crlColumn1M(currencyFormatter(result.taegList[k]));
                        }

                    }
                    for (var i = 0; i < result.formulaList.length; i++) {

                        if (i !== 0) {
                            l = l + 3;
                            if (l >= result.taegList.length) {

                            } else {
                                crlColumn2M(currencyFormatter(result.taegList[l]));
                            }

                        } else {
                            crlColumn2M(currencyFormatter(result.taegList[l]));
                        }

                    }
                    for (var i = 0; i < result.formulaList.length; i++) {

                        if (i !== 0) {
                            m = m + 3;
                            if (m >= result.taegList.length) {

                            } else {
                                crlColumn3M(currencyFormatter(result.taegList[m]));
                            }

                        } else {
                            crlColumn3M(currencyFormatter(result.taegList[m]));
                        }

                    }
                    TableStaticHeadManager.prototype.initEvents();
                });
            }
        });
    }

    function displayNewCRLTableM(newCRBlock) {
        newCrBlk = newCRBlock;
        BNPPPF.readFormulaNewCR({ "product": "REV", "newCRBlock": newCRBlock }, function (result) {
            if (!result.error) {
                require(["jquery", "app"], function ($, app) {
                    var taeg = -1;
                    var k = 0, l = 1, m = 2;
                    var ncr_table = '<div class="tbl-row" id="ncr-rev-table"><div class="tbl-cell-view newcr-tc row1"></div><div class="tbl-cell-view newcr-tc row2"><p id="ncr-revTbl-title">Montant de l\'utilisation</p></div><div class="tbl-cell-view newcr-tc row3"></div></div><div class="tbl-row"><div class="tbl-cell-view newcr-tc">Dur&eacute;e</div><div class="tbl-cell-view newcr-tc"> De 0  à <br class="show-for-small-only"/> 3 000,00 &euro; </div><div class="tbl-cell-view newcr-tc"> De  3 000,01 à <br class="show-for-small-only"/> 4 000,00 &euro;</div></div>';
                    for (var i = 0; i < result.formulaList.length; i++) {
                        var durVal = result.formulaList[i];
                        var durValMin = 0;
                        if (i != 0) {
                            var durValMin = parseInt(result.formulaList[i - 1], 10) + 1;
                        }
                        var taegFirst = currencyFormatter(result.taegList[k]);
                        k += 1;
                        var taegSecond = currencyFormatter(result.taegList[k]);
                        k += 2;
                        var tempDiv = "";
                        if (newCrBlk == "DTS") {
                            tempDiv = '<div class="tbl-row"> <div class="tbl-cell-view newcr-tc">' + durVal + ' mois</div> <div class="tbl-cell-view newcr-tc"> ' + taegFirst + ' %</div> <div class="tbl-cell-view newcr-tc">' + taegSecond + ' %</div></div>';
                        } else {

                            tempDiv = '<div class="tbl-row"> <div class="tbl-cell-view newcr-tc"> De ' + durValMin + ' &agrave; ' + durVal + ' <br /><span>mois / max</span></div> <div class="tbl-cell-view newcr-tc"> ' + taegFirst + ' %</div> <div class="tbl-cell-view newcr-tc">' + taegSecond + ' %</div></div>';
                        }
                        ncr_table += tempDiv;
                    }
                    $("#rev-ncr-rst-tbl").html(ncr_table);
                    if (newCrBlk == "EMI") {
                        $("#ncr-revTbl-title").text("Somme restante dûe");
                        $("#rev-ncr-rst-tbl").addClass("ncr-emi-tbl");
                    }
                });
            }
        });

    }

    function currencyFormatter(value) {
        if (value) {
            if ((value !== 0.0) && (value != 0.00)) {
                if (value.toString().indexOf('.') !== -1) {
                    value = parseFloat(value).toFixed(2);
                    value = value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
                    value = value.replace(/\./g, ',');
                } else {
                    if (value.toString().indexOf(',') === -1) {
                        value = value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
                        value = value + ",00";
                    }
                }
                return (value);
            } else {
                var val = 0;
                return val;
            }
        } else {
            return "0,00";
        }
    }
    function headerM(minValue, maxValue, column) {
        var minValCol2 = currencyCalculM(minValue, 0.01);
        var minValCol3 = currencyCalculM(maxValue, 0.01);

        if (column === 1) {
            $(".crlheader1").append("<span><strong>Jusqu'&agrave; <br />" + minValue + "&euro;</strong></span>");
        } else if (column === 2) {
            $(".crlheader2").append("<span><strong>De " + minValCol2 + "&euro;<br />&agrave;&nbsp;" + maxValue + "&euro;</strong></span>");
        } else {
            $(".crlheader3").append("<span><strong>Au-del&agrave; de <br />" + minValCol3 + "&euro;</strong></span>");
        }

    }
    function currencyCalculM(value, increment) {
        var amount = value.replace(/\,/g, '.');
        amount = amount.replace(/ /g, '');
        amount = parseFloat(amount.replace(/,/g, '')) + increment;
        amount = currencyFormatter(amount);
        return amount;
    }
    function crlColumn3M(value) {

        $(".crlColumn3").append("<div><span>" + value + "%</span></div>");

    }
    function crlColumn2M(value) {

        $(".crlColumn2").append("<div><span>" + value + "%</span></div>");

    }
    function crlColumn1M(value) {

        $(".crlColumn1").append("<div><span>" + value + "%</span></div>");

    }
    function firstColumnM(value) {

        $(".firstColumn").append("<div><span><strong>" + value + "&nbsp;mois <br />maximum</strong></span>");

    }
    function webmarchandWCMWebAnalytics() {
        var jsonObj = { ModuleName: "wcm", event: "Retour Webdistrib" };
        window.PageBus.publish("ia.sf.webanalytics", jsonObj);
    }

    function revTableDispaly(className) {
        require(["jquery", "app"], function ($, app) {
            $.ajax({
                url: "/rsc/contrib/html/cetelem/CRLTable.html"
            }).done(function (data) {
                if (className === ".revTableDisplay") {
                    $(className).html(data);
                } else {
                    $($(className + " article")[1]).before(data);
                }
                $(".wcmDate").text($("#idDate").text());
                displayCRLTableM();
                $('.carousel').wcmslick({
                    "infinite": false,
                    "dots": true,
                    "slidesToShow": 3,
                    "slidesToScroll": 1,
                    "responsive": [{
                        "breakpoint": 768,
                        "settings": {
                            "slidesToShow": 1
                        }
                    }]
                });

            });
        });
    };

    function revTableDispalynewCR(idName, newCRBlock) {
        require(["jquery", "app"], function ($, app) {
            $.ajax({
                url: "/rsc/sys/ia/newCR/CRLTable.html"
            }).done(function (data) {
                if (idName === ".revTableDisplay") {
                    $('.revTableDisplay').empty();
                    $(idName).html(data);
                } else {
                    $(idName).before(data);
                }
                $(".wcmDate").text($("#idDate").text());
                displayNewCRLTableM(newCRBlock);
            });
        });
    };

    function urlRedirection() {
        $(".racSans").click(function () {
            //window.PageBus.publish(simulationCustom_topic.racwithoutImmo, {});
            if (awinParam != "") {
                window.location.href = variation + "credit/rachats-credits/souscription-rachat?awc=" + awinParam;
            }
            else {
                window.location.href = variation + "credit/rachats-credits/souscription-rachat";
            }

        });
        $(".racAvec").click(function () {
            //window.PageBus.publish(simulationCustom_topic.racwithImmo, {});
            window.location.href = variation + "credit/rachats-credits/souscription-rachat";
        });
        $(".projImmo").click(function () {
            //window.PageBus.publish(simulationCustom_topic.projImmo, {});
            window.location.href = variation + "credit/credit-immobilier/souscription-immobilier";
        });
    }
    function racWithoutImmo() {
        require(["jquery"], function ($) {
            var racSans = "<div class='row racSans epartProj'><div class='columns'><a  class='button next-arrow small radius expand'>Demander ce rachat</a></div></div>";
            $(".racAvec").remove();
            $(".racSans").remove();
            $(".projImmo").remove();
            $(".phoneButton").remove()
            $(".simulationGeneric_ia").addClass("hide");
            $(".projectSelectorContainer").append(racSans);
            $(".newEpartnerSlider_ia").addClass("hide");
            $(".newCREpartnerSlider_ia").addClass("hide");
            $(".prod-btn").html(racSans);
            urlRedirection();
        });
    }
    function racWithImmo() {
        require(["jquery"], function ($) {
            var racAvec = "<div class='row racAvec epartProj'><div class='columns'><a  class='button next-arrow small radius expand'>Demander ce rachat</a></div></div>";
            $(".simulationGeneric_ia").addClass("hide");
            $(".racSans").remove();
            $(".racAvec").remove();
            $(".projImmo").remove();
            $(".phoneButton").remove();
            $(".newEpartnerSlider_ia").addClass("hide");
            $(".newCREpartnerSlider_ia").addClass("hide");
            if (window.matchMedia("(max-width: 40em)").matches) {
                var phoneButton = "<div class='phoneButton' style='text-align:center;'><p>Pour vous accompagner au mieux dans votre projet, un expert est à votre disposition au : </p><a href='tel:+33969366003'><img src='/rsc/sys/cetelem/new-img/medias/divers/phoneNumberRAC.jpg'></a><p>Du lundi au vendredi de 9h à 18h30</p></div>";
                $(".projectSelectorContainer").append(phoneButton);
                $(".prod-btn").html(phoneButton);
            } else {
                $(".projectSelectorContainer").append(racAvec);
                $(".prod-btn").html(racAvec);
                urlRedirection();
            }
        });
    }
    function Immo() {
        require(["jquery"], function ($) {
            var projImmo = "<div class='row projImmo epartProj'><div class='columns'><a  class='button next-arrow small radius expand'>Demander ce crédit</a></div></div>";
            $(".simulationGeneric_ia").addClass("hide");
            $(".projImmo").remove();
            $(".phoneButton").remove();
            $(".newEpartnerSlider_ia").addClass("hide");
            $(".newCREpartnerSlider_ia").addClass("hide");
            if (window.matchMedia("(max-width: 40em)").matches) {
                /*var phoneButton="<div class='phoneButton' style='text-align:center;'><p>Pour vous accompagner au mieux dans votre projet, un expert est à votre disposition au : </p><a href='tel:+33240167391'><img src='/rsc/sys/cetelem/new-img/medias/divers/phoneNumberImmo.jpg'></a><p>Du lundi au vendredi de 9h à 18h30</p></div>";
          	
                $(".projectSelectorContainer").append(phoneButton);
                $(".prod-btn").html(phoneButton);*/
            } else {
                $(".projectSelectorContainer").append(projImmo);
                $(".prod-btn").html(projImmo);
                urlRedirection();
            }
        });

    }
    function traVexDisplay() {
        require(["jquery"], function ($) {
            var phoneButton = "<div class='phoneButton epartProj' style='text-align:center;'><p>Pour vous accompagner au mieux dans votre projet, un expert est à votre disposition au : </p><a href='tel:+33820009900'><img src='/rsc/sys/cetelem/new-img/medias/divers/phoneNumber.png'></a><p>Du lundi au vendredi de 9h à 19h</p></div>";
            $(".phoneButton").remove();
            $(".simulationGeneric_ia").addClass("hide");
            $(".customCheckboxContainer").addClass("hide");
            $(".newEpartnerSlider_ia").addClass("hide");
            $(".newCREpartnerSlider_ia").addClass("hide");
            $(".projectSelectorContainer").append(phoneButton);
            $(".prod-btn").html(phoneButton);
        });
    }
    function resetSimulateDisplay() {
        require(["jquery"], function ($) {
            $(".simulationGeneric_ia").removeClass("hide");
            $(".racSans").remove();
            $(".racAvec").remove();
            $(".projImmo").remove();
            $(".phoneButton").remove();
            $(".epartProj").remove();
        });
    }
    function callContactform(id, start, end) {
        var time = parseInt($("#idTime").text().split(":")[0] * 60) + parseInt($("#idTime").text().split(":")[1]);
        if (time > end || time < start) {
            displayContactPopup();
        } else {
            webVoicePop(id);
        }
    }
    function displayContactPopup() {

        var popupTag = "<div class='text-center'><a href='#' class='hasModal' data-modal='insuranceContactModal' data-modalwidth='750' data-modaldefault='open' data-hasqtip='5' aria-describedby='qtip-5'></a><div id='insuranceContactModal' data-url-context='/frpfcommunicationpe/' class='hide insuranceContactModal'></div>";
        $('.borderedWhiteBox').append(popupTag);
        require(["insurance", "app"], function (Insurance, app) {
            new Insurance(".insuranceContactModal", insurance_json, insurance_topic);
            ModalManager.prototype.initEvents();
        });
    }

    function displayErrorPopup() {

        var popupTag = "<div class='text-center'><a href='#' class='hasModal' data-modal='oopsContactModal' data-modalwidth='750' data-modaldefault='open' data-hasqtip='5' aria-describedby='qtip-5'></a><div id='oopsContactModal' data-url-context='/frpfcommunicationpe/' class='hide oopsContactModal'></div>";
        $('#connectionContainer').append(popupTag);
        require(["oops", "app"], function (Oops, app) {
            new Oops(".oopsContactModal", oops_json, oops_topic);
            ModalManager.prototype.initEvents();
        });
    }
    function requestForFundingPopup() {
        require(["jquery", "app"], function ($, app) {
            $.ajax({
                url: "/rsc/contrib/html/cetelem/errorPopup.html"
            }).done(function (data) {
                $('#connectionContainer').append(data);
                ModalManager.prototype.initEvents();
            });
        });
    };

    function displayCreditPopup() {
        var popupTag = "<div class='text-center'><a href='#' class='hasModal' data-modal='creditPopupModal' data-modalwidth='750' data-modaldefault='open' data-hasqtip='5' aria-describedby='qtip-5'></a><div id='creditPopupModal' data-url-context='/frpfcommunicationpe/' class='hide creditPopupModal'></div>";
        $('#connectionContainer').append(popupTag);
        require(["credit", "app"], function (Oops, app) {
            new Oops(".creditPopupModal", credit_json, credit_topic);
            ModalManager.prototype.initEvents();
        });
    }

    function displaySavingsPopup() {

        var popupTag = "<div class='text-center'><a href='#' class='hasModal' data-modal='savingsPopupModal' data-modalwidth='750' data-modaldefault='open' data-hasqtip='5' aria-describedby='qtip-5'></a><div id='savingsPopupModal' data-url-context='/frpfcommunicationpe/' class='hide savingsPopupModal'></div>";
        $('#connectionContainer').append(popupTag);
        require(["savings", "app"], function (Oops, app) {
            new Oops(".savingsPopupModal", savings_json, savings_topic);
            ModalManager.prototype.initEvents();
        });
    }

    function displayCRLTableM() {
        BNPPPF.readFormula({ "product": "REV" }, function (result) {
            if (!result.error) {
                require(["jquery", "app"], function ($, app) {
                    headerM(currencyFormatter(result.maxAmount[0]), currencyFormatter(result.maxAmount[1]), 1);
                    headerM(currencyFormatter(result.maxAmount[0]), currencyFormatter(result.maxAmount[1]), 2);
                    headerM(currencyFormatter(result.maxAmount[0]), currencyFormatter(result.maxAmount[1]), 3);
                    var taeg = -1;
                    var k = 0, l = 1, m = 2;
                    for (var i = 0; i < result.formulaList.length; i++) {
                        //rows(result.formulaList[i],currencyFormatter(result.taegList[++taeg]),currencyFormatter(result.taegList[++taeg]),currencyFormatter(result.taegList[++taeg]));
                        firstColumnM(result.formulaList[i]);
                    }
                    for (var i = 0; i < result.formulaList.length; i++) {
                        //rows(result.formulaList[i],currencyFormatter(result.taegList[++taeg]),currencyFormatter(result.taegList[++taeg]),currencyFormatter(result.taegList[++taeg]));
                        if (i !== 0) {
                            k = k + 3;
                            if (k >= result.taegList.length) {

                            } else {
                                crlColumn1M(currencyFormatter(result.taegList[k]));
                            }

                        } else {
                            crlColumn1M(currencyFormatter(result.taegList[k]));
                        }

                    }
                    for (var i = 0; i < result.formulaList.length; i++) {

                        if (i !== 0) {
                            l = l + 3;
                            if (l >= result.taegList.length) {

                            } else {
                                crlColumn2M(currencyFormatter(result.taegList[l]));
                            }

                        } else {
                            crlColumn2M(currencyFormatter(result.taegList[l]));
                        }

                    }
                    for (var i = 0; i < result.formulaList.length; i++) {

                        if (i !== 0) {
                            m = m + 3;
                            if (m >= result.taegList.length) {

                            } else {
                                crlColumn3M(currencyFormatter(result.taegList[m]));
                            }

                        } else {
                            crlColumn3M(currencyFormatter(result.taegList[m]));
                        }

                    }
                    TableStaticHeadManager.prototype.initEvents();
                });
            }
        });
    }

    function displayNewCRLTableM(newCRBlock) {
        newCrBlk = newCRBlock;
        BNPPPF.readFormulaNewCR({ "product": "REV", "newCRBlock": newCRBlock }, function (result) {
            if (!result.error) {
                require(["jquery", "app"], function ($, app) {
                    var taeg = -1;
                    var k = 0, l = 1, m = 2;
                    var ncr_table = '<div class="tbl-row" id="ncr-rev-table"><div class="tbl-cell-view newcr-tc row1"></div><div class="tbl-cell-view newcr-tc row2"><p id="ncr-revTbl-title">Montant de l\'utilisation</p></div><div class="tbl-cell-view newcr-tc row3"></div></div><div class="tbl-row"><div class="tbl-cell-view newcr-tc">Dur&eacute;e</div><div class="tbl-cell-view newcr-tc"> De 0  à <br class="show-for-small-only"/> 3 000,00 &euro; </div><div class="tbl-cell-view newcr-tc"> De  3 000,01 à <br class="show-for-small-only"/> 4 000,00 &euro;</div></div>';
                    for (var i = 0; i < result.formulaList.length; i++) {
                        var durVal = result.formulaList[i];
                        var durValMin = 0;
                        if (i != 0) {
                            var durValMin = parseInt(result.formulaList[i - 1], 10) + 1;
                        }
                        var taegFirst = currencyFormatter(result.taegList[k]);
                        k += 1;
                        var taegSecond = currencyFormatter(result.taegList[k]);
                        k += 2;
                        var tempDiv = "";
                        if (newCrBlk == "DTS") {
                            tempDiv = '<div class="tbl-row"> <div class="tbl-cell-view newcr-tc">' + durVal + ' mois</div> <div class="tbl-cell-view newcr-tc"> ' + taegFirst + ' %</div> <div class="tbl-cell-view newcr-tc">' + taegSecond + ' %</div></div>';
                        } else {

                            tempDiv = '<div class="tbl-row"> <div class="tbl-cell-view newcr-tc"> De ' + durValMin + ' &agrave; ' + durVal + ' <br /><span>mois / max</span></div> <div class="tbl-cell-view newcr-tc"> ' + taegFirst + ' %</div> <div class="tbl-cell-view newcr-tc">' + taegSecond + ' %</div></div>';
                        }
                        ncr_table += tempDiv;
                    }
                    $("#rev-ncr-rst-tbl").html(ncr_table);
                    if (newCrBlk == "EMI") {
                        $("#ncr-revTbl-title").text("Somme restante dûe");
                        $("#rev-ncr-rst-tbl").addClass("ncr-emi-tbl");
                    }
                });
            }
        });
    }

    function currencyFormatter(value) {
        if (value) {
            if ((value !== 0.0) && (value != 0.00)) {
                if (value.toString().indexOf('.') !== -1) {
                    value = parseFloat(value).toFixed(2);
                    value = value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
                    value = value.replace(/\./g, ',');
                } else {
                    if (value.toString().indexOf(',') === -1) {
                        value = value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
                        value = value + ",00";
                    }
                }
                return (value);
            } else {
                var val = 0;
                return val;
            }
        } else {
            return "0,00";
        }
    }
    function headerM(minValue, maxValue, column) {
        var minValCol2 = currencyCalculM(minValue, 0.01);
        var minValCol3 = currencyCalculM(maxValue, 0.01);
        if (column === 1) {
            $(".crlheader1").append("<span><strong>Jusqu'&agrave; <br />" + minValue + "&euro;</strong></span>");
        } else if (column === 2) {
            $(".crlheader2").append("<span><strong>De " + minValCol2 + "&euro;<br />&agrave;&nbsp;" + maxValue + "&euro;</strong></span>");
        } else {
            $(".crlheader3").append("<span><strong>Au-del&agrave; de <br />" + minValCol3 + "&euro;</strong></span>");
        }
    }
    function currencyCalculM(value, increment) {
        var amount = value.replace(/\,/g, '.');
        amount = amount.replace(/ /g, '');
        amount = parseFloat(amount.replace(/,/g, '')) + increment;
        amount = currencyFormatter(amount);
        return amount;
    }
    function crlColumn3M(value) {
        $(".crlColumn3").append("<div><span>" + value + "%</span></div>");
    }
    function crlColumn2M(value) {
        $(".crlColumn2").append("<div><span>" + value + "%</span></div>");
    }
    function crlColumn1M(value) {
        $(".crlColumn1").append("<div><span>" + value + "%</span></div>");
    }
    function firstColumnM(value) {
        $(".firstColumn").append("<div><span><strong>" + value + "&nbsp;mois <br />maximum</strong></span>");
    }
    function webmarchandWCMWebAnalytics() {
        var jsonObj = { ModuleName: "wcm", event: "Retour Webdistrib" };
        window.PageBus.publish("ia.sf.webanalytics", jsonObj);
    }
    function contactPopupToDisplay(DatenIntervals, idToInsert, imageStr, altStr, jsId) {
        //Sys Time
        if (DatenIntervals) {
            require(["jquery", "app"], function ($, app) {
                var retDate = $("#compDatenTime").text();
                var todayDate = new Date(retDate);
                var currentday = dayOfWeekAsString(todayDate.getDay());
                var nowTime = (todayDate.getHours() * 60) + todayDate.getMinutes();
                var startLimit = DatenIntervals[currentday].Start;
                var endLimit = DatenIntervals[currentday].End;
                // User Entry
                if (idToInsert && startLimit && endLimit && startLimit.trim() != '00:00' && endLimit.trim() != '00:00') {

                    var openingHour = calculateMin(DatenIntervals[currentday].Start);
                    var endingHour = calculateMin(DatenIntervals[currentday].End);
                    var ida = "#" + idToInsert.toString();
                    if (openingHour <= nowTime && nowTime <= endingHour) {
                        $(ida).html("<a href=javascript:callContactform('Template=" + jsId + "'," + openingHour + "," + endingHour + ");> <img border=\"0\" alt=\"Click to Call\"src=\"" + imageStr + "\"></a>");
                    } else
                        $(ida).html("<a href=javascript:callContactform('Template=" + jsId + "'," + openingHour + "," + endingHour + ");> <img border=\"0\" alt=\"Click to Call\"src=\"" + altStr + "\">");

                } else { }
            });

        }
    }
    function calculateMin(inputStr) {
        var tempStr = inputStr.split(":");
        var tempHour = tempStr[0] * 60;
        var tempMin = tempStr[1];
        var tempTime = parseInt(tempHour) + parseInt(tempMin);
        return tempTime;
    }
    function dayOfWeekAsString(dayIndex) {
        return ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"][dayIndex];
    }

    function updateRetPopup(updateRetPopupObj) {
        if (sfSiteId === "cetelem") {
            $('div.hasModal').remove();
            if (updateRetPopupObj.code == "cheque") {
                require(['text!/rsc/contrib/html/IA/cetelem/S51/retPopup.html', 'underscore', "jquery"],
                    function (Template, _, $) {
                        var content = _.template(Template, updateRetPopupObj);
                        $('#connectionContainer').append(content);
                        ModalManager.prototype.initEvents();
                    });
            } else if (updateRetPopupObj.code == "video") {

                require(['text!/rsc/contrib/html/cetelem/video-crs.html', 'underscore', "jquery"],
                    function (Template, _, $) {
                        var content = _.template(Template, updateRetPopupObj);
                        $('#connectionContainer').append(content);
                        ModalManager.prototype.initEvents();

                        require(["jquery", "app"], function ($, app) {
                            $("#playerd7277e1a").mediaelementplayer({
                                startVolume: 1.0,
                                features: ['playpause', 'volume', 'progress', 'current', 'duration', 'tracks', 'fullscreen'],
                                defaultVideoWidth: '100%',
                                defaultVideoHeight: '100%',
                                videoWidth: '100%',
                                videoHeight: '100%',
                                enableAutoSize: true,
                                loop: false,
                                // force iPad's native controls
                                iPadUseNativeControls: true,
                                // force iPhone's native controls
                                iPhoneUseNativeControls: true,
                                // force Android's native controls
                                AndroidUseNativeControls: true
                            });
                        });
                    });
            }
            else {
                require(['text!/rsc/contrib/html/IA/cetelem/S51/retCashPopup.html', 'underscore', "jquery"],
                    function (Template, _, $) {
                        var content = _.template(Template, updateRetPopupObj);
                        $('#connectionContainer').append(content);
                        ModalManager.prototype.initEvents();
                    });
            }
        }
    }
    //var connect2Call = true; 
    function connectingCall() {
        (function (d) {
            var cm = d.createElement('scr' + 'ipt'); cm.type = 'text/javascript'; cm.async = true;
            cm.src = 'https://fccdc-1004255.dimelochat.com/chat/3ee3505af24433d72deb4cd4/loader.js';
            var s = d.getElementsByTagName('scr' + 'ipt')[0]; s.parentNode.insertBefore(cm, s);
        }(document));
    }

    function chatUpdate() {
        connectingCall();
        $.getScript("/rsc/contrib/html/IA/cetelem/S18/chat-bot.js", function (script, res, data) {
            window.callchatt(function () {
                if (window.glbl == 1) $('.dimelo_chat_item_markup').show();
                else $('.dimelo_chat_item_markup').hide();
            });
        });
    }

    /**
     * 
     * IA.SF.LOADED NEEDS TO BE REGISTERED HERE
     * 
     * **/

    window.PageBus.subscribe("ia.sf.loaded", null, function (topic, msg, data) {

        $(".wcmDate").text($("#idDate").text());
        if (msg.ModuleName === "fractionatedPayment Cofinoga") {
            $('head').append('<link id="dynamic-favicon" rel="shortcut icon" href="https://espaceclient.cofinoga.fr/rsc/sys/cofinoga/favicon.ico" />');
        }

		
		if(typeof msg.ModuleName !== "undefined" && (msg.ModuleName === "accountMgmtOnlinePayment" || msg.ModuleName === "accountMgmtNewOnlinePayment") && typeof(window.atos) !== "undefined" && window.atos !== "" && typeof(window.encode) !== "undefined" && window.encode !== "" && typeof(window.seal) !== "undefined" && window.seal !== "" && typeof(window.interfaceVersion) !== "undefined" && window.interfaceVersion !== "" && typeof(window.atosDecoded) !== "undefined" && window.atosDecoded !== ""){
			var paymentResponse = [window.atos, window.encode, window.seal, window.interfaceVersion, window.atosDecoded]; 
			if(window.atosSuccessResponse) {
				window.atosSuccessResponse(paymentResponse);
			}
		}
		if(sessionStorage.getItem("noPushMessage"))
		{
            $('.creditRequestList_ia').removeClass("hide");
            $('.votreheader').removeClass("hide");
        } else {
            $('.creditRequestList_ia').addClass("hide");
            $('.votreheader').addClass("hide");
        }
        if (msg.ModuleName === "statementOfOperations" && (window.location.href.indexOf("/comptes/credit-renouvelable-cr?to=panel2&ciid=pano") > -1) && (window.location.href.indexOf('panel2&ciid=pano') > -1)) {
            window.PageBus.publish("ia.sf.webanalytics", {
                'ModuleName': "statementOfOperations",
                'event': "module_interaction",
                'gtm.uniqueEventId': 30,
                'vpageName': "Releve d operation",
                'environment': wcmEnv,
            });
        }
        if (msg.ModuleName === "fullAuthentication" && (sfSiteId ==="cetelem" || sfSiteId ==="cofinoga")) {
            //if(sfSiteId ==="cofinoga") window.PageBus.publish("helpPopin",'','');
            var systemDate = $("#compDatenTime").html();
            systemDate = new Date(systemDate);
            systemTime = systemDate.getTime();
			var startDate = "2022-01-20 00:00:00";
			var schStrtTime = new Date(startDate.replace(" ", "T") + "Z");
			schStrtTime = schStrtTime.getTime();
			var endDate = "2024-12-25 24:00:00";
			var schEndTime = new Date(endDate.replace(" ", "T") + "Z");
			schEndTime	= schEndTime.getTime();
            if (systemTime >= schStrtTime && systemTime <= schEndTime) {
                $(".accesClient").addClass("maintanence-text-active");
            } else {
                $(".maintanenceText").addClass("hide");
            }
            $(".fullAuthentication_ia").removeAttr("style");
            $('.fullAuthentication_ia').append($('.cetelemchatbot'));
            $('.cetelemchatbot').removeClass('hide-for-all');
            localStorage.setItem("unreadMessageCount", "0");
            localStorage.removeItem("personPhysique");
            $("#accesClientIdentification .helperBtn.hasTooltip").click(function () { chatUpdate(); });
            $('.cetelemchatbot , .passwordPopin').on('click', function () {
                window.PageBus.publish("ia.sf.webanalytics", {
                    'ModuleName': "fullAuthentication",
                    'event': "module_interaction",
                    'vpageName': "Aide"
                });
                window.PageBus.publish("chatbotcall", '', '');

            });
        }
			
			if (msg.ModuleName === "generalDashboard" && sfSiteId === "cetelem") {
	
				// SYstem date				
					var systemDate=$("#compDatenTime").html();
					systemDate=new Date(systemDate);
					systemTime=systemDate.getTime();
				
				// Image 2 start date		
					var startDateImage2 = "2022-10-11 07:00:00";
					var schStrtTimeImage2 = new Date(startDateImage2.replace(" ", "T") + "Z");
					//console.log("warning Message startDateImage2 " + schStrtTimeImage2);
					schStrtTimeImage2 = schStrtTimeImage2.getTime();					
					//console.log("warning Message startDateImage2 " + schStrtTimeImage2.toString());
					
				// Image 2 end date	
					var endDateImage2 = "2022-10-27 06:59:59";
					var schEndTimeImage2 = new Date(endDateImage2.replace(" ", "T") + "Z");
					//console.log("warning Message endDateImage2 " + schEndTimeImage2);
					schEndTimeImage2	= schEndTimeImage2.getTime();
					//console.log("warning Message endDateImage2 " + schEndTimeImage2.toString());
					
				// Image 3 start date	
					var startDateImage3 = "2022-10-27 07:00:00";
					var schStrtTimeImage3 = new Date(startDateImage3.replace(" ", "T") + "Z");
					//console.log("warning Message startDateImage3 " + schStrtTimeImage3);
					schStrtTimeImage3 = schStrtTimeImage3.getTime();					
					//console.log("warning Message startDateImage3 " + schStrtTimeImage3.toString());
					
				// Image 3 end date					
					var endDateImage3 = "2022-11-09 06:59:59";
					var schEndTimeImage3 = new Date(endDateImage3.replace(" ", "T") + "Z");
					//console.log("warning Message endDateImage3 " + schEndTimeImage3);
					schEndTimeImage3	= schEndTimeImage3.getTime();
					//console.log("warning Message endDateImage3 " + schEndTimeImage3.toString());
					
					if (systemTime >= schStrtTimeImage2 && systemTime <= schEndTimeImage2){
					$(".Affichage-banner").attr("src","/rsc/sys/cetelem/new-img/medias/divers/Affichage-banniere-02.jpg");
					$(".Affichage-banner-mobile").attr("src","/rsc/sys/cetelem/new-img/medias/divers/Affichage-banniere-mobile-02.jpg");
					}else if (systemTime >= schStrtTimeImage3 && systemTime <= schEndTimeImage3){
					$(".Affichage-banner").attr("src","/rsc/sys/cetelem/new-img/medias/divers/Affichage-banniere-03.jpg");
					$(".Affichage-banner-mobile").attr("src","/rsc/sys/cetelem/new-img/medias/divers/Affichage-banniere-mobile-03.jpg");
					} /*else {
					(".Affichage-banner").attr("src","/rsc/sys/cetelem/new-img/medias/divers/Affichage-banniere-01.jpg");
					$(".Affichage-banner-mobile").attr("src","/rsc/sys/cetelem/new-img/medias/divers/Affichage-banniere-mobile-01.jpg");
					}*/
			}
			
        if(msg.ModuleName === "lostConnection") 
			{
				if(typeof lastConnection_json == 'undefined'){			
					lastConnection_json = lastConnectionV2_json;
					 (lastConnection_json.URL_numberDuVendeur);	
					}
				
				if(window.location.hostname === 'hm-staging.cetelem.fr' || window.location.hostname === 'pocisvacetelem.pf.staging.echonet' || window.location.hostname ===  'cetelem-prod2-speed.neuges.org'){
					
					var csrftoken;
					
					function logoutISVA(){
						require(["jquery","app"],function($,app){

						$.ajax({
								 url: "/mga/sps/apiauthsvc/policy/user_session",
								 method: "GET"
						}).done(function(data) {
							
								$.ajax({
										 url: "/logout",
										 method: "POST",
										 headers: {
											csrftoken: data.csrftoken
										}
								}).done(function(resp) {
								  document.cookie = "logintime=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
									localStorage.removeItem("IDPRFetched");
									localStorage.removeItem("ConfigFetched");
									sessionStorage.removeItem("noPushMessage");
									localStorage.removeItem("lastconnectiondata");
									localStorage.removeItem("Panoramadescomptes");
									localStorage.removeItem("personPhysique");
									window.top.location="/fr/accueil";
								});						  
						  //csrftoken = data.csrftoken;
						  //setCookie('csrftoken', data.csrftoken);
						});
						//csrftoken = getCookie('csrftoken');
						//window.top.location="/fr/accueil";
						});
					}

				$('.dismisExt').click(function(){
                    //localStorage.setItem("newpop", "true");
					logoutISVA();
				});
					//$("#sessionalertPopin .closeImg").attr('href','');
					//$("#sessionalertPopin .confirm").attr('href','');
					//$("#warnalertPopin .closeImg").attr('href','');
					//$("#warnalertPopin .dismisExt").attr('href','');
					//$("#warnalertPopin .dismisExtBtn").attr('href','');
					$("#sessionalertPopin .closeImg , #sessionalertPopin .confirm, #warnalertPopin .closeImg, #warnalertPopin .dismisExt, #warnalertPopin .dismisExtBtn").attr('href', '');
					$("#sessionalertPopin .closeImg , #sessionalertPopin .confirm, #warnalertPopin .closeImg, #warnalertPopin .dismisExt, #warnalertPopin .dismisExtBtn").on('click', function(){
                    //localStorage.setItem("newpop", "true");
						//window.location.href="/pkmslogout";
					logoutISVA();
				});
            }
            $('#disconnect-site-session').click(function () {
                window.PageBus.publish("ia.sf.webanalytics", {
                    "event": "deconnexionEc"
                });
					if(window.location.hostname === 'hm-staging.cetelem.fr'  || window.location.hostname === 'pocisvacetelem.pf.staging.echonet'  || window.location.hostname ===  'cetelem-prod2-speed.neuges.org'){
							//window.top.location="/pkmslogout";
							logoutISVA();
						}
					else{
                $.ajax({
                    url: "/SEEA-pa01/logoff"
                }).done(function () {
                    document.cookie = "logintime=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
                    localStorage.removeItem("IDPRFetched");
                    localStorage.removeItem("ConfigFetched");
                    sessionStorage.removeItem("noPushMessage");
                    localStorage.removeItem("lastconnectiondata");
                    localStorage.removeItem("Panoramadescomptes");
                    localStorage.removeItem("personPhysique");
                    if (lastConnection_json.sessionOutRedirectUrl)
                        window.top.location = lastConnection_json.sessionOutRedirectUrl;
                    else
                        window.top.location = "/SEEA-pa01/logoff";
                });
					}
            });
        }

        //Comment this if there is a change in pushMessage page to Dashboard Page 
        window.PageBus.subscribe("target.ia.frpfclientpe_accountMgmtMySituation.dashboard_redirect_pushMessage", null, function (topic, msg, data) {
            $(".dashboard-component").show();
            $(window).trigger('resize');
            $(".pushMessageController_ia").hide();
        });

        if (localStorage.getItem("unreadMessageCount") != '0' && localStorage.getItem("unreadMessageCount") != null && msg.ModuleName !== "pushMessageController") {
            $('.wcm-badge').removeClass('hide');
            $('.wcm-badge').html(localStorage.getItem("unreadMessageCount"));
        } else {
            $('.wcm-badge').addClass('hide');
        }

        if (msg.ModuleName === "newEpartnerLegalExample" && msg.Label === "CRL_Legal") {
            /* var className=".revTableDisplay"; */
            //newEpartnerLegalExampleFlag =  false;
            /* revTableDispaly(className); */
            nextSimulationButton(msg.ModuleName);
        }
        if (msg.ModuleName === "simulationResultSavings") {
            nextSimulationButton(msg.ModuleName);
        }
        if (msg.ModuleName === "subscribeCetelemController") {
            nextSimulationButton(msg.ModuleName);
        }
        if (msg.ModuleName === "resultBlock" || msg.ModuleName === "optiResultBlock") {
            if (msg.URL_productCode !== "REV") {
                nextSimulationButton(msg.ModuleName);
            }
            if (msg.URL_productCode === "REV") {
                var className = ".subscribeCetelemSimResult";
                revTableDispaly(className);
                nextSimulationButton(msg.ModuleName);
            }
        } else if (msg.ModuleName === "subscribeCetelemController" && msg.URL_productCode === "REV") {
            var className = ".simulationEtSouscription";
            revTableDispaly(className);
            nextSimulationButton(msg.ModuleName);
        }
        if (msg.ModuleName === "simulationResultBlock" && msg.URL_productCode === "REV") {
            var idName = "#ncr-simple-steps";
            var newCRBlock = "EMI";
            if (msg.methodeSimulation === "parDuree") {
                newCRBlock = "DTS";
            } else if (msg.methodeSimulation === "parMensualite") {
                newCRBlock = "EMI";
            }
            revTableDispalynewCR(idName, newCRBlock);
        }
        if (msg.ModuleName === "accountMgmtAlerte") {
            imageinterChange();
        }
        if (msg.ModuleName == "subscribeCetelemBlockSummary") {
            $(".removeLoader").removeClass("iaLoader");
        }

        if (msg.ModuleName === "accountMgmtNewCR") {
            // Hide Sav bascule starts
            var systemDate = $("#compDatenTime").html();
            systemDate = new Date(systemDate);
            systemTime = systemDate.getTime();
            var schStrtTime = new Date("03/23/2020 00:00:00");
            schStrtTime = schStrtTime.getTime();
            var schEndTime = new Date("04/07/2020 05:59:59");
            schEndTime = schEndTime.getTime();
            if (systemTime >= schStrtTime && systemTime <= schEndTime) {
                $(".prevelment-button.goToBascule").addClass("hide-for-all");
            }
            // Hide Sav bascule ends
        }


        if (msg.ModuleName === "generalDashboard") {
            // if(window.sfSiteId==="cetelem"){
            // window.PageBus.publish("ia.sf.strongAuth.cpaytransefer",{'cpayAccountEligibility': window.cpayAccountEligibility});
            // }
            window.PageBus.publish('ia.sf.suvidemand.idprdata', {});
            // Hide Sav bascule starts
            var systemDate = $("#compDatenTime").html();
            systemDate = new Date(systemDate);
            systemTime = systemDate.getTime();
            var schStrtTime = new Date("03/23/2020 00:00:00");
            schStrtTime = schStrtTime.getTime();
            var schEndTime = new Date("04/07/2020 05:59:59");
            schEndTime = schEndTime.getTime();
            if (systemTime >= schStrtTime && systemTime <= schEndTime) {
                $(".button.newCRL.newPrev").addClass("hide-for-all");
            }
            // Hide Sav bascule ends
        }

        require(["app"], function (app) {
            if (msg.ModuleName === "generalDashboard") {
                EqualBoxesManager.prototype.initEvents();
                $('div[class^="pushblock"] a').on('click', function (ele) { window.location.href = $(ele.target).attr("href"); });
            }
            if (msg.ModuleName) {
                EqualButtonsManager.prototype.initEvents();
                EqualHeightUntilManager.prototype.initEvents();
            }
            $(".sliderContainer").on("click", function () {
                if ($($(".sliderContainer input")[0]).attr("disabled")) {
                    if ($('[data-panel="panel-1"]').hasClass("active")) {
                        $("#creditProjectSelectorContent").css({ display: "block" });
                    }
                }
            });
        });

        var queryObj = window.PageBus.query('target.ia.frpfpciaaape_fullAuthentication_redirect');
        if (queryObj.length) {
            if (queryObj[0].value.Code === "REDIRECT" && authLoaded) {
                $('.connection > li.accesClient > a').trigger('click');
                authLoaded = false;
            }
        }

        //for simulatos for iphone and scroll to top feature

        if (msg.ModuleName === "simulationGeneric" || msg.ModuleName === "simulationCRLChoice" || msg.ModuleName === "simulationSaving" || msg.ModuleName === "simulationBoxCR") {
            if (navigator.userAgent.match(/(iPhone)/)) {
                $("#rightContainer .panel .sliderContainer .noUiSlider").css("width", "75%");
                $(".sliderContainer .stepContainer").css({ "padding-left": "2rem" }, { "padding-right": "2rem" });
            }
            //if(window.location.pathname==$(".logo").attr("href")){
            if (window.matchMedia("(max-width: 40em)").matches) {
                if (msg.ModuleName === "simulationGeneric") {
                    $('#panel-1').animate({
                        scrollTop: 60
                    });
                } else if (msg.ModuleName === "simulationCRLChoice") {
                    $('#panel-2').animate({
                        scrollTop: 60
                    });
                } else if (msg.ModuleName === "simulationCRLChoice") {
                    $('#panel-3').animate({
                        scrollTop: 60
                    });
                } else if (msg.ModuleName === "simulationBoxCR") {
                    $('#panel-3').animate({
                        scrollTop: 60
                    });
                }
            }
            //}
        }


        if (msg.ModuleName === "newEpartnerSlider") {
            var currentURL = window.location.toString();
            if (newCREpartnerSlider_json.URL_productCode !== "REV" && currentURL.search('codemateriel') > 0) {
                require(["jquery", "app",], function ($, app) {
                    $(document).ready(function () {
                        var mainValue = "";
                        var subId = newCREpartnerSlider_json.URL_materialCode;
                        newCREpartnerSlider_json.URL_productCode;
                        subId = subId.toString();
                        mainValue = $(".selected [data-code='" + subId + "']").data('id');
                        $("#" + mainValue).find(".selected [data-code='" + subId + "']").trigger('change');
                    });
                });
            }
        }
        if (msg.ModuleName === "newCREpartnerSlider") {

            var currentURL = window.location.toString();
            if (newCREpartnerSlider_json.URL_productCode !== "REV" && currentURL.search('codemateriel') > 0) {
                require(["jquery", "app",], function ($, app) {
                    $(document).ready(function () {
                        var mainValue = "";
                        var subId = newCREpartnerSlider_json.URL_materialCode;
                        newCREpartnerSlider_json.URL_productCode;
                        subId = subId.toString();
                        mainValue = $(".selected [data-code='" + subId + "']").data('id');
                        $("#" + mainValue).find(".selected [data-code='" + subId + "']").trigger('change');
                    });
                });
            }
        }

        $('.connectionContainer.logoff .accesClient').on('click', function () {
            document.cookie = "logintime=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            localStorage.setItem("newpop", "");
            localStorage.setItem("iCount", 0);
            localStorage.removeItem("IDPRFetched");
            localStorage.removeItem("ConfigFetched");
            sessionStorage.removeItem("noPushMessage");
            localStorage.removeItem("lastconnectiondata");
            localStorage.removeItem("Panoramadescomptes");
            localStorage.removeItem("personPhysique");


        });
        $('.accesClientSubmit').on('click', function () {
            document.cookie = "logintime=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            localStorage.setItem("newpop", "");
            localStorage.setItem("iCount", 0);
            localStorage.removeItem("IDPRFetched");
            localStorage.removeItem("ConfigFetched");
            sessionStorage.removeItem("noPushMessage");
            localStorage.removeItem("lastconnectiondata");
            localStorage.removeItem("Panoramadescomptes");
            localStorage.removeItem("personPhysique");
        });

        $('.goToBascule').on('click', function () {
            dataLayer.forEach(function (obj) {
                if (obj.ModuleName !== undefined) { dataLayer.pop(obj); }
            });
        });

        $('.panelDetail1').on('click', function () {
            if (equalflag) {
                EqualHeightUntilManager.prototype.initEvents();
                equalflag = false;
            }
        });

        if (typeof getCookie === "function") {
            var getIcm = getCookie("meomICM");
            require(["encrypt"], function (encrypt) {
                if (getIcm !== '')
                {
                    getIcm = new Array(getIcm.length - 2 + 1).join('x') + getIcm.slice(-2);
                    $('#accesClientIdentifiantClient').val(getIcm);
                    $("#to_store").prop("checked", true);
                    $("#accesClientIdentifiantClient").attr("disabled", true);
                }
            });
        }

        /*TEMP: if(typeof sfIaParam != "undefined")  {
            if(sfIaParam.Json && sfIaParam.Json.restituerinformations && sfIaParam.Json.restituerinformations.contratCreditConsommation && sfIaParam.Json.restituerinformations.contratCreditConsommation.indLiberte === "0")
                $(".monthlyAlertEnableButton").addClass("disabled hasTooltip");
        }*/

        if (isModifierScroll) {
            if (isModifierScroll === "modifyBankInfo_ia") {
                $('html, body').animate({
                    scrollTop: 475
                }, 0);
            }
        }

        $('.clicktoPanorama').click(function () {
            $('.subClientNav ul li:first').trigger('click');
        });
        if (sfSiteId === "creditmoderne" && siteInfo != 'reunion') $('.companyID').html('Crédit Moderne Antilles Guyane');
        wcm_debug_wa("loaded : ");
        wcm_debug_wa(msg);
    });





    /**
     * 
     * IA.SF.WEBANALYTICS NEEDS TO BE REGISTERED HERE
     * 
     * **/

    window.PageBus.subscribe("ia.sf.webanalytics", "", function (topic, msg, data) {
		
		// Paiement en ligne temp fix
		if (msg.event === "payment_ok"){
					window.PageBus.publish("ia.sf.webanalytics",{
						'event': "module_interaction",
						'vpageName': "Paiement en ligne : Confirmation",
						 'environment':wcmEnv,
						 'ModuleName': "accountMgmtNewOnlinePayment",
						 'site': sfSiteId,						 
					   //'gtm.uniqueEventId':30,
					});
			}

        if (localStorage.getItem("unreadMessageCount") != '0' && localStorage.getItem("unreadMessageCount") != null && msg.ModuleName !== "pushMessageController") {
            $('.wcm-badge').removeClass('hide');
            $('.wcm-badge').html(localStorage.getItem("unreadMessageCount"));
        } else {
            $('.wcm-badge').addClass('hide');
            //localStorage.setItem("unreadMessageCount","0");
        }
        if (msg.ModuleName == "resultBlock") {
            nextSimulationButton(msg.ModuleName);
        }
        if (msg.event === "simulation_altered" && msg.ModuleName === "resultBlock" && msg.URL_productCode === "REV") {
            var className = ".subscribeCetelemSimResult";
            $($(className + " article")[1]).find('.tableStaticHead').empty();
            revTableDispaly(className);
            nextSimulationButton(msg.ModuleName);
        }
        if (msg.event === "simulation_updated" && msg.ModuleName === "resultBlock" && msg.URL_productCode === "REV") {
            var className = ".subscribeCetelemSimResult";
            $($(className + " article")[1]).find('.tableStaticHead').empty();
            revTableDispaly(className);
            nextSimulationButton(msg.ModuleName);
        }
        if (msg.event === "simulation_updated" && msg.ModuleName === "resultBlock" && msg.URL_productCode === "CLA") {
            sfIaParam.Json.URL_productCode = msg.URL_productCode;
            sfIaParam.Json.URL_duration = msg.URL_duration;
            sfIaParam.Json.URL_goodAmount = msg.URL_goodAmount;
            sfIaParam.Json.URL_materialCode = msg.URL_materialCode;
            sfIaParam.Json.URL_monthlyInstalment = msg.URL_monthlyInstalment;
        }
        if (msg.ModuleName === "prestoController" && (msg.stepNumber === "4" || msg.stepNumber === "5.2")) {
            require(["jquery"], function ($) {
                $('.linkBackToWebsite').addClass('pfhide');
            });
        }
        $(".wcmDate").text($("#idDate").text());


        /*
         * TEMP: Temp Fixes from WCM needs to be added here
         * 
         * 
              	
         if(msg.event === "chargement_IA_CR" && msg.enseigne === "But" && !butFlag){
             $($(".votreheader")).append("<div>Suite à une erreur technique votre solde de points fidélité n’a pas été mis à jour dans votre relevé. Toutefois vos points accumulés sur la période ont bien été enregistrés.  Nous mettons tout en œuvre pour que votre relevé soit disponible le mois prochain. Nous vous remercions pour votre compréhension</div>");
             butFlag=true;
         }	
         if(msg.vpageName === "Report mensualite : Accueil"){
                var a =$($($(".demanderUnReport-step2").find(".row")[1]).find(".summary>span strong")).html();
                a = a.indexOf(" €") !==-1?a.replace(" €",""):a;
                a = a.indexOf(",") !==-1?a.replace(",","."):a;
                a = a.indexOf(" ") !==-1?a.replace(" ",""):a;
                a = a?parseFloat(a,10):a;
                $($($(".demanderUnReport-step2").find(".row")[1]).find(".summary>span strong")).html(a +" €"); 			
        }
        */
        if (sfSiteId === "creditmoderne" && siteInfo != 'reunion') $('.companyID').html('Crédit Moderne Antilles Guyane');
    });




    /**
     * 
     * OTHER SUBSCRIBE EVENTS NEEDS TO BE REGISTERED BELOW
     * 
     * **/


    window.PageBus.subscribe("target.ia.frpfsimulationpe_simulationGeneric_cofinoga.modifier", null, function (topic, msg, data) {
        msg.Json.URL_materialCode = (msg.Json.URL_materialCode === '919a') ? '919' : msg.Json.URL_materialCode;
        if (typeof msg.ModuleName !== 'undefined' && msg.ModuleName === "WCM" && typeof msg.Json !== 'undefined' && typeof msg.Json.URL_materialCode !== 'undefined') {
            if (msg.Json.URL_productCode === "RAC") {
                if (msg.Json.URL_materialCode === "897") {
                    racWithoutImmoCafinoga();
                }
            } else {
                resetSimulateDisplay();
            }

        }
    });

    window.PageBus.subscribe("target.ia.frpfsimulationpe_simulationGeneric.modifier", null, function (topic, msg, data) {
        wcm_debug('subscribe de : target.ia.frpfsimulationpe_simulationGeneric.modifier');
        msg.Json.URL_materialCode = (msg.Json.URL_materialCode === '919a') ? '919' : msg.Json.URL_materialCode;
        if (typeof msg.ModuleName !== 'undefined' && msg.ModuleName === "WCM" && typeof msg.Json !== 'undefined' && typeof msg.Json.URL_materialCode !== 'undefined') {
            if (msg.Json.URL_productCode === "RAC") {
                if (msg.Json.URL_materialCode === "897") {
                    //hide simulation and show button RAC without immo
                    racWithoutImmo();
                } else if (msg.Json.URL_materialCode === "897hypo") {
                    //hide simulation and show button RAC with immo
                    racWithImmo();
                }
            } else if (msg.Json.URL_productCode === "IMMO") {
                if (msg.Json.URL_materialCode === "ImmoItem3") {
                    //hide simulation + show loader
                    $("#panel-1").removeClass("iaInit");
                    document.location.href = "/fr/credit/credit-immobilier/achat-revente-bien-actuel";
                } else {
                    Immo();
                    //hide simulation and show button immo
                }
            } else if (msg.Json.URL_materialCode === "919GTX") {
                //show phone number
                traVexDisplay();

            } else {
                resetSimulateDisplay();
            }

        }
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_epartner.redirect_a", null, function (topic, msg, data) {
        wcm_debug('subscribe de : target.ia.frpfsubscriptionpe_epartner.redirect_a');

        if (typeof msg.ModuleName !== 'undefined' && msg.ModuleName === "WCM" && typeof msg.Json !== 'undefined' && typeof msg.Json.URL_materialCode !== 'undefined') {
            if (msg.Json.URL_productCode === "RAC") {
                if (msg.Json.URL_materialCode === "897") {
                    //hide simulation and show button RAC without immo
                    racWithoutImmo();
                } else if (msg.Json.URL_materialCode === "897hypo") {
                    //hide simulation and show button RAC with immo
                    racWithImmo();
                }
            } else if (msg.Json.URL_productCode === "IMMO") {
                if (msg.Json.URL_materialCode === "ImmoItem3") {
                    //hide simulation + show loader
                    $("#panel-1").removeClass("iaInit");
                    document.location.href = "/fr/credit/credit-immobilier/achat-revente-bien-actuel";
                } else {
                    Immo();
                    //hide simulation and show button immo
                }
            } else if (msg.Json.URL_materialCode === "919GTX") {
                //show phone number
                traVexDisplay();

            } else {
                resetSimulateDisplay();
            }
        }
    });

    window.PageBus.subscribe('target.ia.**', null, function (topic, msg, data) {
        wcm_debug("<mediator msg>");
        wcm_debug(topic);
        wcm_debug(msg);
        wcm_debug(data);
        wcm_debug("</mediator msg>");
        if (topic === "target.ia.frpfsubscriptionpe_resultBlock.subscribeCetelemController_cla" || topic === "target.ia.frpfsubscriptionpe_optiResultBlock.subscribeCetelemController_cla" || topic === "target.ia.frpfsubscriptionpe_optiResultBlock_creditModerne.subscribeCetelemControllernewCr_cla" || topic === "target.ia.frpfsubscriptionpe_subscribeCetelemController.subscribeCetelemController_cla" || topic === "target.ia.frpfsubscriptionpe_subscribeCetelemController.subscribeCetelemControllernewCr_cla") {
            if (msg.Code !== "RELOAD" && msg.Json.oldData) {
                require(["jquery", "app"], function ($, app) {
                    $('[data-panel="panel-1"]').click();
                    RightNavManager.prototype.mobileCloseRightNav();
                });
            }
        } else if (topic === "target.ia.frpfsubscriptionpe_resultBlock.subscribeCetelemController_rev" || topic === "target.ia.frpfsubscriptionpe_optiResultBlock.subscribeCetelemController_rev" || topic === "target.ia.frpfsubscriptionpe_subscribeCetelemController.subscribeCetelemController_rev") {
            if (Mediator.getregisteredIa(topic) != undefined) {
                require(["jquery", "app"], function ($, app) {
                    if ($(".rightNav").find(".active").length) {
                        $($(".rightNav").find(".active")).click();
                        //$('[data-panel="panel-2"]').click();
                    }
                    RightNavManager.prototype.mobileCloseRightNav();
                });
            }
        } else if (topic === "target.ia.frpfsubscriptionpe_simulationSavingsResultReload.subscription_redirect") {
            require(["jquery", "app"], function ($, app) {
                if ($(".rightNav").find(".active").length) {
                    $('[data-panel="panel-3"]').click();
                }
                RightNavManager.prototype.mobileCloseRightNav();
                //}

            });
        }
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_epartner.redirect_a", null, function (topic, msg, data) {
        if (msg.Json.goodsCodeInitial !== contolOfGoods) {
            contolOfGoods = msg.Json.goodsCodeInitial;
            $('.newEpartnerResult_ia').addClass('hide');
            $('.epartnerBreadCrum').removeClass('hide');
            $('.legalExample').addClass('hide');
            $('.reroutePPHldr').addClass('hide');
            //$('.legalSpecialBlockCRL').addClass('hide');
            $('.revTableDisplay').addClass('hide');
            $('.legalBlockPP').addClass('hide');
            $('.legalSpecialCRL').addClass('hide');
            $('.legalSpecialBlock').addClass('hide');
            $('.newEpartnerSlider_ia').removeClass('hide');
            $('.newCREpartnerSlider_ia').removeClass('hide');
            $('.newCREpartnerResult_ia').addClass('hide');
            msg.Json.URL_materialCode = (msg.Json.URL_materialCode === '919a') ? '919' : msg.Json.URL_materialCode;
        }
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_subscribeCetelemControllerRunB.form_redirect_epartner", null, function (topic, msg) {
        if (msg.Json.datacrl != undefined) {
            msg.Json.dataCRL = msg.Json.datacrl;
        }
    });

    window.PageBus.subscribe("target.ia.frpfsimulationpe_epartnerSlider.simulation_legal_update", null, function (topic, msg, data) {
        $('.pf_loader_div').removeClass('pf_hide');
        if (msg.Json.goodsCodeInitial === contolOfGoods) {
            contolOfGoods = msg.Json.goodsCodeInitial;
            $('.newEpartnerResult_ia').removeClass('hide');
            $('.newCREpartnerResult_ia').removeClass('hide');
            if (msg.Json.URL_productCode === "REV") {
                $('.revTableDisplay').empty();
                var className = ".revTableDisplay";
                var newCRBlock = "EMI";
                if (msg.Json.choice === "parDuree") {
                    newCRBlock = "DTS";
                } else {
                    newCRBlock = "EMI";
                }
                revTableDispalynewCR(className, newCRBlock);
            }
            $('.revTableDisplay').removeClass('hide');
            $('.legalExample').removeClass('hide');
            //$('.legalSpecialBlockCRL').removeClass('hide');
            $('.legalBlockPP').removeClass('hide');
            $('.legalSpecialCRL').removeClass('hide');
            $('.legalSpecialBlock').removeClass('hide');
        }
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_subscribeCetelemController.subscribeCetelemController_rev", null, function (topic, msg, data) {
        if (msg.ModuleName === "simulationCRLChoice") {
            msg.Json.entreeParcours = 'Carte';
            panelFlag = 'CRL';
        } else
            panelFlag = 'REV';
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_resultBlock.subscribeCetelemController_rev", null, function (topic, msg, data) {
        if (msg.ModuleName === "simulationCRLChoice") {
            msg.Json.entreeParcours = 'Carte';
            panelFlag = 'CRL';
        } else
            panelFlag = 'REV';
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock.subscribeCetelemController_rev", null, function (topic, msg, data) {
        if (msg.ModuleName === "simulationCRLChoice") {
            msg.Json.entreeParcours = 'Carte';
            panelFlag = 'CRL';
        } else
            panelFlag = 'REV';
    });
    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock_reunion.subscribeCetelemController_rev", null, function (topic, msg, data) {
        if (msg.ModuleName === "simulationCRLChoice") {
            msg.Json.entreeParcours = 'Carte';
            panelFlag = 'CRL';
        } else
            panelFlag = 'REV';
    });
    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock_martinique.subscribeCetelemController_rev", null, function (topic, msg, data) {
        if (msg.ModuleName === "simulationCRLChoice") {
            msg.Json.entreeParcours = 'Carte';
            panelFlag = 'CRL';
        } else
            panelFlag = 'REV';
    });
    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock_guadeloupe.subscribeCetelemController_rev", null, function (topic, msg, data) {
        if (msg.ModuleName === "simulationCRLChoice") {
            msg.Json.entreeParcours = 'Carte';
            panelFlag = 'CRL';
        } else
            panelFlag = 'REV';
    });
    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock_guyane.subscribeCetelemController_rev", null, function (topic, msg, data) {
        if (msg.ModuleName === "simulationCRLChoice") {
            msg.Json.entreeParcours = 'Carte';
            panelFlag = 'CRL';
        } else
            panelFlag = 'REV';
    });
    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_subscribeCetelemController.subscribeCetelemController_cla", null, function (topic, msg, data) {
        panelFlag = 'CLA';

    });
    /*test*/
    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_subscribeCetelemController.subscribeCetelemControllernewCr_cla", null, function (topic, msg, data) {
        panelFlag = 'CLA';
    });
    /*test*/

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_resultBlock.subscribeCetelemController_cla", null, function (topic, msg, data) {
        panelFlag = 'CLA';
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock.subscribeCetelemController_cla", null, function (topic, msg, data) {
        panelFlag = 'CLA';
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock_reunion.subscribeCetelemController_cla", null, function (topic, msg, data) {
        panelFlag = 'CLA';
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock_guyane.subscribeCetelemController_cla", null, function (topic, msg, data) {
        panelFlag = 'CLA';
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock_guadeloupe.subscribeCetelemController_cla", null, function (topic, msg, data) {
        panelFlag = 'CLA';
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiResultBlock_martinique.subscribeCetelemController_cla", null, function (topic, msg, data) {
        panelFlag = 'CLA';
    });

    window.PageBus.subscribe('target.ia.frpfpciaaape_fullAuthentication.subscription_redirect', null, function (topic, data, msg) {
        var urle = "";
        if (sfSiteId != "cetelem")
            urle = "/sites/" + sfSiteId + "/navigation-service.page"
        else
            urle = "/sites/cetelem/navigation-service.page";

        $.ajax({
            url: urle
        }).done(function (data) {
            $('.mainNav').html($(data).find('.mainNav').children()).append($(data).find('.subClientNav'));
            $('#mainContainer').removeClass('overlay');
            new NavigationManager();
            $(".authenticationBox").remove();
            $('#formSimulationCredit').html($(data).find('#formSimulationCredit').children());
            $('#formSimulationCreditRenouvelable').html($(data).find('#formSimulationCreditRenouvelable').children());
            $('#formSimulationEpargne').html($(data).find('#formSimulationEpargne').children());
            new ContactsManager();
            $('.socialBtn').html($(data).find('.socialBtn').children());
            $('.phoneNumber').html($(data).find('.phoneNumber').children());
            $('.contactBtn').html($(data).find('.contactBtn').children());
            new ContactsManager();
        });
    });
    window.PageBus.subscribe('target.ia.frpfsimulationpe_cardPage.back_resultPage', null, function (topic, msg) {
        /* 	var idName="#ncr-simple-steps";
         var newCRBlock="EMI";
         if(msg.methodeSimulation === "parDuree"){
             newCRBlock="DTS";
         }else if(msg.methodeSimulation === "parMensualite"){
             newCRBlock="EMI";
         }
         revTableDispalynewCR(idName,newCRBlock);   */
    })
    window.PageBus.subscribe("wcm.sf.displayError", null, function (topic, msg, data) {
        $(".wcmDate").text($("#idDate").text());
        if (msg.ModuleName === "simulationGeneric" || msg.ModuleName === "resultBlock" || msg.ModuleName === "optiResultBlock" || msg.ModuleName === "subscribeCetelemController" || msg.ModuleName === "subscribeCetelemControllerRunB" || msg.ModuleName === "simulationCRLChoice" || msg.ModuleName === "subscriptionRCSI" || msg.ModuleName === "simulationBoxCR") {
            displayCreditPopup();
        } else if (msg.ModuleName === "fullAuthentication") {
            $(".loader-cont1").addClass("pf_hide");
            $(".pf_loader_div").addClass("pf_hide");
            Mediator.registerIa("frpfpciaaape_fullAuthentication", true);
            displayErrorPopup();
        } else if (msg.ModuleName === "requestForFunding") {
            requestForFundingPopup();
        } else if (msg.ModuleName === "simulationResultSavings" || msg.ModuleName === "openSavingAccount" || msg.ModuleName === "simulationSaving") {
            displaySavingsPopup();
        }

    });

    //subscription_error 4 Temp pwd 
    window.PageBus.subscribe('target.ia.frpfpciaaape_fullAuthentication.subscription_error', null, function (topic, data, msg) {
        $.ajax({
            url: "/rsc/contrib/html/IA/cetelem/S40-S41/subscription_error_msg.html"
        }).done(function (data) {
            $('#connectionContainer').append(data);
            ModalManager.prototype.initEvents();
        });

    });
    //S56 Modifier le capital souscrit - Included capital folder in path as part of CR 186
    window.PageBus.subscribe("target.ia.frpfclientpe_insuranceDetails.capital_redirect", null, function (topic, msg, data) {
        window.open('/rsc/contrib/documents/espace-client/assurance/' + msg.Json.URL_codeSociete + '/capital/' + msg.Json.codeCategorieProduit + '.pdf', '_blank');
    });

    //S56 MODIFIER LA CLAUSE BENEFICIAIRE - Included clause folder in path as part of CR 186
    window.PageBus.subscribe("target.ia.frpfclientpe_insuranceDetails.clause_redirect", null, function (topic, msg, data) {
        window.open('/rsc/contrib/documents/espace-client/assurance/' + msg.Json.URL_codeSociete + '/clause/' + msg.Json.codeCategorieProduit + '.pdf', '_blank');
    });

    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_prestoController.updateStep", null, function (topic, msg, data) {
        require(["jquery"], function ($) {
            $('.linkBackToWebsite').addClass('pfhide');
        });
    });
    window.PageBus.subscribe("target.ia.frpfsubscriptionpe_optiPrestoController.updateStep", null, function (topic, msg, data) 
    {
        require(["jquery"], function ($) {
            $('.linkBackToWebsite').addClass('pfhide');
        });
    });

    /* window.PageBus.subscribe("target.ia.frpfsimulationpe_epartnerSlider.simulation_legal_update", null, function (topic, msg, data) 
    {
    if(msg.Json.URL_productCode =='REV'){
        var className=".revTableDispaly";
        revTableDispaly(className);
        nextSimulationButton(msg.ModuleName);

    }
    }); */


    function activateEbilling() {
        var json_empty = {};
        if (activateEbillingFlag) {
            window.PageBus.publish("target.ia.frpfclientpe_accountMgmtEBilling", json_empty);
            activateEbillingFlag = false;
        }
    }

    function activateStmts() {
        var json_empty = {};
        if (activateStmtsFlag) {
            window.PageBus.publish("target.ia.frpfclientpe_statementOfOperations", json_empty);
            activateStmtsFlag = false;
        }
    }

    //Message Batch 
    window.PageBus.subscribe('target.ia.frpfclientpe_unread_MessageCount', null, function (topic, msg, data) {
        if (msg.unreadMessageCount != '0' && msg.unreadMessageCount != null) {
            $('.wcm-badge').removeClass('hide');
            $('.wcm-badge').html(msg.unreadMessageCount);
            localStorage.setItem("unreadMessageCount", msg.unreadMessageCount);
        }
        else localStorage.setItem('unreadMessageCount', '0');
    });

    window.PageBus.subscribe("target.ia.frpfsimulationpe_simulationGeneric_reunion.simulation_update", null, function (topic, msg, data) {
        wcm_debug('subscribe de : target.ia.frpfsimulationpe_simulationGeneric_reunion.simulation_update');

        if (typeof msg.ModuleName !== 'undefined' && msg.ModuleName === "WCM" && typeof msg.Json !== 'undefined' && typeof msg.Json.URL_materialCode !== 'undefined') {
            resetSimulateDisplay();
        }
    });

    window.PageBus.subscribe("target.ia.frpfsimulationpe_simulationGeneric_guyane.simulation_update", null, function (topic, msg, data) {
        wcm_debug('subscribe de : target.ia.frpfsimulationpe_simulationGeneric_guyane.simulation_update');

        if (typeof msg.ModuleName !== 'undefined' && msg.ModuleName === "WCM" && typeof msg.Json !== 'undefined' && typeof msg.Json.URL_materialCode !== 'undefined') {
            resetSimulateDisplay();
        }
    });

    window.PageBus.subscribe("target.ia.frpfsimulationpe_simulationGeneric_martinique.simulation_update", null, function (topic, msg, data) {
        wcm_debug('subscribe de : target.ia.frpfsimulationpe_simulationGeneric_martinique.simulation_update');

        if (typeof msg.ModuleName !== 'undefined' && msg.ModuleName === "WCM" && typeof msg.Json !== 'undefined' && typeof msg.Json.URL_materialCode !== 'undefined') {
            resetSimulateDisplay();
        }
    });

    window.PageBus.subscribe("target.ia.frpfsimulationpe_simulationGeneric_guadeloupe.simulation_update", null, function (topic, msg, data) {
        wcm_debug('subscribe de : target.ia.frpfsimulationpe_simulationGeneric_guadeloupe.simulation_update');
        if (typeof msg.ModuleName !== 'undefined' && msg.ModuleName === "WCM" && typeof msg.Json !== 'undefined' && typeof msg.Json.URL_materialCode !== 'undefined') {
            resetSimulateDisplay();
        }
    });

    window.PageBus.subscribe("target.ia.frpfclientpe_insuranceHeader_descriptif.descriptif_redirect", null, function (topic, msg, data) {
        var catCode = msg.Json.CodeCategorieProduit;
        if (catCode && sfSiteId === "cetelem") {
            catCode = catCode.toString();
            switch (catCode) {
                case "ASPF": window.location.href = variation + "assurance/vous-vos-proches/assurance-deces"; break;
                case "PFP": window.location.href = variation + "assurance/vous-vos-proches/assurance-depenses-courantes"; break;
                case "ASGA": window.location.href = variation + "assurance/vehicules/garantie-panne-mecanique"; break;
                case "ASVL": window.location.href = variation + "assurance/vehicules/garantie-valeur-achat"; break;
                case "ASVI": window.location.href = variation + "assurance/vehicules/assistance-vehicules"; break;
                case "ASE": window.location.href = variation + "epargne/protection-epargne"; break;
                default:
            }
        }

    });

    window.PageBus.subscribe('target.ia.frpfclientpe_accountMgmtNewCR.newCR_cardpopin', null, function (topic, msg, data) {
        $('#connectionContainer .hasModal').parent().empty();
        require(['text!' + accountMgmtNewCR_json.popinContent + '', 'underscore', "jquery"],
            function (Template, _, $) {
                var content = _.template(Template, msg.Json);
                $('#connectionContainer').append(content);
                ModalManager.prototype.initEvents();
                if (sfAxes2 === 'MOBILE') $('#sf-master').addClass('hide');
                window.scrollTo(0, 0);
            });
    });

    window.PageBus.subscribe('target.ia.frpfclientpe_accountMgmtRemboursement.reimboursement_PopIn_Alert', null, function (topic, msg, data) {
        $('#connectionContainer .hasModal').parent().empty();
        require(['text!' + accountMgmtRemboursement_json.popinContent + '', 'underscore', "jquery"],
            function (Template, _, $) {
                var content = _.template(Template, msg.Json);
                $('#connectionContainer').append(content);
                ModalManager.prototype.initEvents();
                if (sfAxes2 === 'MOBILE') $('#sf-master').addClass('hide');
            });

    });

    window.PageBus.subscribe('target.ia.frpfpciaaape_fullAuthentication.icmStoreInfo_popin', null, function (topic, msg, data) {
        // $('.hasModal').remove();
        require(['text!' + fullAuthentication_json.icmStoreInfo + '', 'underscore', "jquery"],
            function (Template, _, $) {
                var content = _.template(Template, msg.Json);
                $('#connectionContainer').append(content);
                ModalManager.prototype.initEvents();
                $("#to_store").attr("disabled", false);
                if (sfAxes2 === 'MOBILE') $('#sf-master').addClass('hide');
            });

    });

    window.PageBus.subscribe('target.ia.frpfclientpe_modifyPostalAddress.identityRules', null, function (topic, msg, data) {
        $('#connectionContainer .hasModal').parent().empty();
        if (typeof modifyPostalAddress_json === "undefined") {
            modifyPostalAddress_json = infoPersonal_json;
        }
        require(['text!' + modifyPostalAddress_json.identityRules + '', 'underscore', "jquery"],
            function (Template, _, $) {
                var content = _.template(Template, msg.Json);
                $('#connectionContainer').append(content);
                ModalManager.prototype.initEvents();
                if (sfAxes2 === 'MOBILE') $('#sf-master').addClass('hide');
            });
    });

    window.PageBus.subscribe('target.ia.frpfclientpe_modifyBankInfo.popin', null, function (topic, msg, data) {
        $('#connectionContainer .hasModal').parent().empty();
        if (typeof modifyBankInfo_json === "undefined") {
            modifyBankInfo_json = infoPersonal_json;
        }
        require(['text!' + modifyBankInfo_json.popin + '', 'underscore', "jquery"],
            function (Template, _, $) {
                var content = _.template(Template, msg.Json);
                $('#connectionContainer').append(content);
                ModalManager.prototype.initEvents();
                if (sfAxes2 === 'MOBILE') $('#sf-master').addClass('hide');
            });
    });

    window.PageBus.subscribe('target.ia.frpfclientpe_RFF.limitationRules', null, function (topic, msg, data) {
        $('#connectionContainer .hasModal').parent().empty();
        require(['text!' + accountMgmtRFF_json.kyc_demandefinancement + '', 'underscore', "jquery"],
            function (Template, _, $) {
                var content = _.template(Template, msg.Json);
                $('#connectionContainer').append(content);
                ModalManager.prototype.initEvents();
                if (sfAxes2 === 'MOBILE') $('#sf-master').addClass('hide');
            });
    });

    window.PageBus.subscribe('target.ia.frpfclientpe_virement.limitationRules', null, function (topic, msg, data) {
        $('#connectionContainer .hasModal').parent().empty();
        require(['text!' + requestForFunding_json.virementLimits + '', 'underscore', "jquery"],
            function (Template, _, $) {
                var content = _.template(Template, msg.Json);
                $('#connectionContainer').append(content);
                ModalManager.prototype.initEvents();
                if (sfAxes2 === 'MOBILE') $('#sf-master').addClass('hide');
            });
    });


    window.PageBus.subscribe('chatbotcall', null, function (topic, msg, data) {
        if (popclose) {
            require(['text!' + fullAuthentication_json.lossPassword + '', 'underscore', "jquery"],
                function (Template, _, $) {
                    var content = _.template(Template, msg.Json);
                    $('#connectionContainer').append(content);
                    ModalManager.prototype.initEvents();
                    popclose = false;
                });
        }
        else {
            chatUpdate();
        }
    });

    window.PageBus.subscribe('displayQuelsCodePopup', null, function (topic, msg, data) {
        require(['text!/rsc/contrib/html/IA/cofinoga/S18-auth-connection/quels-code.html', 'underscore', "jquery"],
            function (Template, _, $) {
                var content = _.template(Template, msg.Json);
                $('#connectionContainer').append(content);
                ModalManager.prototype.initEvents();
            });
    });

    /*window.PageBus.subscribe('helpPopin', null, function (topic, msg, data) {
    require(['text!/rsc/contrib/html/IA/cofinoga/S18-auth-connection/help-popin.html','underscore',"jquery"],
    function(Template,_,$) {
        var content = _.template(Template, msg.Json);
        $('#connectionContainer').append(content);
        ModalManager.prototype.initEvents();
    });
    });*/

    window.PageBus.subscribe("progress.show", this, function (subj, msg) {
        if (msg.ModuleName !== '') {
            loadingCount++;
            if (loadingCount === 1) {
                require(["jquery"], function ($) {
                    $('.pf_loader_div').removeClass('pf_hide');
                    $("html").addClass("hidescroll");
                });
            }
        }
    });
    window.PageBus.subscribe("progress.hide", this, function (subj, msg) {
        if (msg.ModuleName !== '') {
            if (loadingCount > 0) loadingCount--;
            if (loadingCount === 0) {
                require(["jquery"], function ($) {
                    $('.pf_loader_div').addClass('pf_hide');
                    $("html").removeClass("hidescroll");
                });
            }
        }
    });
    window.PageBus.subscribe("progress.reset", this, function (subj, msg) {
        loadingCount = 0;
        require(["jquery"], function ($) {
            $('.pf_loader_div').addClass('pf_hide');
            $("html").removeClass("hidescroll");
        });
    });

    //BetaTesters /Landing page - status 0 - popin issue

    var cpayAccountEligibility = "";
    var strongAuth = false;
    PageBus.subscribe("ia.sf.strongAuth.cpaytransefer", null, function (topic, msg, data) {

        console.log(msg.cpayAccountEligibility);
        cpayAccountEligibility = msg.cpayAccountEligibility;

    });

    PageBus.subscribe("ia.sf.strongAuth.loaded", null, function (topic, msg, data) {

        var strongAuth = msg.subscribed;

        if (strongAuth && !cpayAccountEligibility) {

            PageBus.subscribe("ia.sf.strongAuth.cpaytransefer", null, function (topic, msg, data) {

                console.log(msg.cpayAccountEligibility);
                //cpayAccountEligibility=msg.cpayAccountEligibility;
                window.PageBus.publish("ia.sf.strongAuth.cpaytransefer.receive", msg);


            });

        } else if (strongAuth && cpayAccountEligibility) {
            window.PageBus.publish("ia.sf.strongAuth.cpaytransefer.receive", cpayAccountEligibility);
        }

    });

}
catch (e) {
    console.log("Exception in the Mediator" + e);
}

Zerion Mini Shell 1.0