(function () {

    var _shell_wrapper = null,
        _data = null,
        _userDetails = null,
        _shell_wrapper = $('#shell_wrapper');

    let _pageData = {
        'aD': {},
        'pr': "",
        'sr': 0,
        'sts': 0
    };

    let _btn_next = $(".btn_next");
    let _btn_prev = $(".btn_prev");

    $('#shell_wrapper').off("initPage").on("initPage", function (e) {
        $('#shell_wrapper').off("initPage");
        _shell_wrapper.off("takePageDetails").on("takePageDetails", function (e, pageData) {
            e.stopPropagation();
            _pageData = pageData || _pageData; tree_pTile_1_5
            updateDom();
        });

        _shell_wrapper.off("sentUserDetails").on("sentUserDetails", function (e, userData) {
            e.stopPropagation();
            _userDetails = userData;
            _data = getData(_userDetails)[0];
            _shell_wrapper.trigger('getPageDetails', _data.userDataRef.currentPageNo);
        });
        _shell_wrapper.trigger('getUserDetails');

    });


    var updateDom = function () {
        clearTimeout(_timerInstance);
        _shell_wrapper.off("componentDidMount").on("componentDidMount", function (e) {
            e.stopPropagation();
            _activity_1();
        });

        Utils.loadTemplate('#templateHolder', 'simple_start', function () {
            Utils.log('simple_start: templateHolder')
            var _simple_start = new Simple_Start();
            _simple_start.init(getData(_userDetails));
        });

    }

    var pageInit = function () {
        clearTimeout(_timerInstance);
        let _init_obj = {
            'callback': function () {
                Utils.updateAudio(_data.audio[0], function () {
                    let _tabs = $(".text_model_style .tabclick");
                    _tabs.removeClass('disabled').addClass('active');

                    let _aD = _pageData['aD'];
                    $.each(_tabs, function (index, item) {
                        //  console.log(index, item, _aD[index+1]);
                        try {
                            if (_aD[index + 1]) {
                                //  $(item).addClass("visiteded");
                            }
                        } catch (err) {

                        }
                    })

                    lastStep();
                })
                addEvents();
            }
        }

        enabledDisable(_btn_next, false);
        enabledDisable(_btn_prev, false);
        if ($("#tree_pTile_1_5").hasClass("completed")) {
            let _data = {
                mNo: 1,
                pNo: 4
            }
            let btn = $(".closebgtn");
            btn.off("click").on("click", function () {
                btn.off("click");
                _shell_wrapper.trigger("gotoModule", _data)
            }).addClass("active");
        }

        _shell_wrapper.trigger('pageLoaded', _init_obj);
    }

    var lastStep = function () {
        let _data = {
            mNo: 1,
            pNo: 4
        }

        enabledDisable(_btn_next, false);
        enabledDisable(_btn_prev, false);

        let btn = $(".closebgtn");
        btn.off("click").on("click", function () {
            btn.off("click");
            _shell_wrapper.trigger("gotoModule", _data)
        })

        Utils.pageCompleted();
        setTimeout(function () {
            enabledDisable($(".btn_next"), false);
        }, 200)


    }

    var addEvents = function () {
        _shell_wrapper.off("tabClicked").on("tabClicked", function (e, data) {
            let _aD = _pageData['aD'];
            _aD[data.qNo] = data.r;
            _shell_wrapper.trigger("setActivityData", _pageData);
        });
    }

    var _activity_1 = function () {
        Utils.loadTemplate('#activity-holder', 'simple_next_back', function () {
            _activity_1_init();
        });
    }

    var _activity_1_init = function () {
        var _activity = new init_activity();
        _activity.init(_data, function () {

        });
        pageInit();
    }


    var getData = function (_userDetails) {
        var _data = [{
            section: "<div id='activity-holder'></div>",
            id: 'm01_l03_p03_01',
            userDataRef: {
                currentPageNo: 6
            },
            popupData: [
                {
                    id: "1",
                    description: "<h5 class='secTitle'>Wage and Hour Issues</h5><div class = 'sub-sections' id = 'sub-sections-1'><p class='item-1'>Common requests from clients and information about why we try to dissuade clients from pursuing certain practices are in the areas of: ​</p> <ul class='bulletlist'> <li  class='item-2'>Rounding</li> <li  class='item-3'>Buffers</li> <li  class='item-4'>Compliant Meal Periods</li>  </ul>  <p  class='item-5'>The company can be held liable for violations of these laws and that liability can be attributed to both the client and Employbridge.</p></div>",
                    hasVideo: false
                },
                {
                    id: "2",
                    description: "<div class = 'sub-sections' id = 'sub-sections-2'> <div class='midSide'> Wage and Hour Issues </div> <div class='leftSide'> <div class='midDesc'> <p class='item-1-0 title'><b>Limiting Liability: What do we expect from our clients?</b></p> <ul class='bulletlist'> <li class='item-1-1'>Use Employbridge timeclocks.​</li> <li class='item-1-2'>Keep precise time records for Talent.</li> <li class='item-1-3'>Ensure timekeeping compliance.​</li> <li class='item-1-4'>Avoid rounding or buffers.</li> <li class='item-1-5'>Guarantee legally compliant meal and rest breaks.</li> </ul> </div> </div> <div class='rightSide'> <div class='midDesc'> <p class='item-2-0  title'><b>What are the potential impacts to the field/company?</b></p> <ul class='bulletlist'> <li class='item-2-1'>Class Actions are extremely expensive. ​</li> <li class='item-2-2'>In California, there is an additional exposure to Private Attorneys General Act (PAGA) claims.</li> <li class='item-2-3'>Claims of high value hurt profitability and reduce incentive compensation.</li> </ul> </div> </div></div>",
                    hasVideo: false
                }
            ],
            audio: [
                {
                    id: "1",
                    autoplay: true,
                    url: './shell/audio/blank.mp3',
                    timeline: [,
                        {
                            'element': ".contentWrapper",
                            'sTime': 0.1,
                            'eTime': '',
                            'classIn': 'blueUp',
                            'classOut': ''
                        }, {
                            'element': ".pageInstruction",
                            'sTime': 4,
                            'eTime': '',
                            'classIn': 'd-show',
                            'classOut': ''
                        }],
                    title: "",
                    description: "",
                    transcript: ''
                },
                {
                    id: "2",
                    autoplay: true,
                    url: './views/m01_l03_p03_01/m01_l03_p03_01_01.mp3',
                    timeline: [{
                        'element': ".contentWrapper",
                        'sTime': 0.1,
                        'eTime': '',
                        'classIn': 'blueUp',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-1 .item-1",
                        'sTime': 0.5,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-1 .item-2",
                        'sTime': 21,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-1 .item-3",
                        'sTime': 23,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-1 .item-4",
                        'sTime': 24,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-1 .item-5",
                        'sTime': 27,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }
                    ],
                    title: "",
                    description: "",
                    transcript: '<p>Employbridge wants to be good partners with our clients, so we adopt practices that protect both us and our clients. One area where employers are vulnerable is potential wage and hour violations. ​</p> <p>Some common requests from clients and information about why we try to dissuade them from pursuing certain practices are in the areas of: </p> <ul> <li>Rounding</li> <li>Buffers</li> <li>Compliant Meal Periods</li> </ul> <p>Another thing to keep in mind is that California has very rigorous and employee friendly wage and hour laws and as a result, there is huge liability attached to violations of these laws and that liability can be attributed to both the client and Employbridge. This means that it is even more important for us to educate our clients on best practices that limit our and their liability.</p>'
                },
                {
                    id: "3",
                    autoplay: true,
                    url: './views/m01_l03_p03_01/m01_l03_p03_01_02.mp3',
                    timeline: [{
                        'element': "#sub-sections-2 .item-1-0",
                        'sTime': 0.38,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .midSide",
                        'sTime': 0.4,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .item-1-1",
                        'sTime': 3.53,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .item-1-2",
                        'sTime': 5.15,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .item-1-3",
                        'sTime': 8.40,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .item-1-4",
                        'sTime': 12.32,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .item-1-5",
                        'sTime': 14.62,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },

                    {
                        'element': "#sub-sections-2 .item-2-0",
                        'sTime': 18.10,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .item-2-1",
                        'sTime': 21.70,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .item-2-2",
                        'sTime': 24.97,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    },
                    {
                        'element': "#sub-sections-2 .item-2-3",
                        'sTime': 31.94,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }],
                    title: "",
                    description: "",
                    transcript: '<p><b>Limiting Liability: What do we expect from our clients?</b></p> <ul> <li>Use Employbridge timeclocks<ul><li>Maintain accurate time records for our Talent.</li> <li>Ensure other aspects of timekeeping are compliant.</li> </ul></li> <li>No rounding or buffers.</li> <li>Ensure Talent get legally compliant meal and rest breaks.</li> </ul> <p><b>What are the potential impacts to the field/company?</b></p> <ul> <li>Class Actions are extremely expensive. In California, we have the additional exposure of Private Attorneys General Act (PAGA) claims.​</li> <li>Claims of high value have a detrimental impact on branch, market, and regional profitability, which directly impacts incentive compensation.</li> <li>For example, in real numbers, if a PAGA claim is settled for $350,000<ul> <li>The branch P&L will absorb the first $25,000</li> <li>The area P&L will absorb the next $75,000</li> <li>The region P&L will absorb anything over $100,000</li> </ul> </li> </ul>'
                }
            ]
        }];
        return _data;
    };

    _shell_wrapper.trigger("initPage");
})();