(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;
            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_6").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_carousel', 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_02',
            userDataRef: {
                currentPageNo: 7
            },
            popupData: [
                {
                    id: "1",
                    description: "<h5 class='secTitle'>Rounding</h5><div class='sub-sections' id='sub-sections-1'><p class='item_1_0'><b>What is Rounding?</b></p><ul class='bulletlist'><li class='item_1_1'>Rounding is when an employee's timesheet is rounded either up or down to the shift start/end time.</li><li class='item_1_2'>Rounding is normally done to the nearest tenth of the hour (3 minutes before/after the start/end of the shift) or quarter hour minutes (7 minutes before/after the start/end of a shift upon clock in and clock out.​</li></ul><p class='item_1_3'><b>Example of quarter hour rounding:</b></p><p class='item_1_4'>Shift start: 8:00 am</p><ul class='bulletlist'><li class='item_1_5'>If an employee clocks in between 7:53 am and 7:59 am, the employee's time is rounded to 8 am.​</li><li class='item_1_6'>If an employee clocks in between 8:00 am and 8:07 am, the employee's time is rounded to 8 am.</li></ul>",
                    hasVideo: false
                },
                {
                    id: "2",
                    description: "<h5 class='secTitle'>Rounding</h5><div class='sub-sections' id='sub-sections-2'><p class='item_2_0'><b>Why do clients request rounding?</b></p><ul class='bulletlist'><li class='item_2_1'>Clients often request rounding to prevent perceived \"time theft\" (e.g., non-work activities).</li><li class='item_2_2'>Many resist changes, citing that rounding is legally permissible.</li><li class='item_2_3'>Rounding can become a liability if not managed correctly or if records fail to prove proper compensation.</li><li class='item_2_4'>Employers must ensure rounding does not lead to unpaid compensable time.</li></ul></div>",
                    hasVideo: false
                },
                {
                    id: "3",
                    description: "<h5 class='secTitle'>Rounding</h5><div class='sub-sections' id='sub-sections-3'><p class='item_3_0'>Examples of compensable time that are often overlooked:</p><ul class='bulletlist'><li class='item_3_1'>Meetings at the beginning or end of shift.</li><li class='item_3_2'>Donning and doffing (putting on or taking off special clothing or other requirements to do the work).</li><li class='item_3_3'>Preparation for start of shift-checking equipment, loading supplies, etc.</li><li  class='item_3_4'>Security or health checks​</li></ul></div>",
                    hasVideo: false
                },
                {
                    id: "4",
                    description: "<h5 class='secTitle'>Rounding</h5><div class='sub-sections' id='sub-sections-4'><p class='item_4_0'>If challenged, an employer will have to establish that:</p><ul class='bulletlist'><li  class='item_4_1'>The policy is either entirely neutral or benefits the employee. This requires a review of all time records.</li><li class='item_4_2'>An employer cannot always round time in one direction that results in an employee never receiving the benefit of the rounding.​</li><li class='item_4_3'>No work or compensable activity was performed during the rounding period (time before or after the shift that is not being treated as compensable time).​</li></ul></div>",
                    hasVideo: false
                },
                {
                    id: "5",
                    description: "<h5 class='secTitle'>Rounding</h5><div class='sub-sections' id='sub-sections-5'><p class='item_5_0'><b>Legal liability:</b> </p><ul class='bulletlist'><li class='item_5_1'>Timesheet rounding increases the risk of violating the Fair Labor Standards Act and state laws, as it can easily lead to inadvertent wage and hour violations. as well as give rise to claims that are difficult and expensive to defend​</li></ul><p class='item_5_2'><b>Off-the-clock work:</b></p><ul class='bulletlist'><li class='item_5_3'>Off-the-clock work is a serious violation of the Fair Labor Standards Act (FLSA) as well as state specific laws. Even a few minutes unpaid risks lawsuits. Examples include donning/doffing, pre-shift meetings, and shift preparation (e.g., equipment checks). ​</li></ul><p class='item_5_4'><b>Rounding primarily benefit the employer:</b></p><ul class='bulletlist'><li class='item_5_5'>To refute improper rounding claims, employers must show the practice equally benefits both parties or favors employees. This is challenging since employees often clock in early to ensure timely shift starts.</li></ul></div>",
                    hasVideo: false
                },
                {
                    id: "6",
                    description: "<h5 class='secTitle'>Rounding in California</h5><div class='sub-sections' id='sub-sections-6'><p class='item_6_0'><b>California-specific issues with rounding:</b></p><ul class='bulletlist'><li class='item_6_1'>A recent California case held that rounding is not permissible in California. This issue is currently being considered by the California Supreme Court.​</li><li class='item_6_2'>In California, both Employbridge and the client are liable for wage and hour violations under the joint employer liability theory.​</li><li class='item_6_3'>Employbridge California agreements include specific provisions regarding rounding and indemnification that will make the client entirely responsible if rounding is required by the client. However, clients frequently insist that these provisions be removed and replaced with language that makes Employbridge liable for any wage and hour claims.​</li></ul><p class='item_6_4'>Reference for clients: <a href='https://www.fisherphillips.com/en/news-insights/employee-timecard-rounding-california.html' target='_blank'>https://www.fisherphillips.com/en/news-insights/employee-timecard-rounding-california.html</a> </p></div>",
                    hasVideo: false
                }
            ],
            audio: [
                {
                    id: "1",
                    autoplay: true,
                    url: './shell/audio/blank.mp3',
                    timeline: [],
                    title: "",
                    description: "",
                    transcript: ''
                },
                {
                    id: "2",
                    autoplay: true,
                    url: './views/m01_l03_p03_02/m01_l03_p03_02_01.mp3',
                    timeline: [{
                        'element': "#sub-sections-1 .item_1_0",
                        'sTime': 0.70,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-1 .item_1_1",
                        'sTime': 1.5,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-1 .item_1_2",
                        'sTime': 7,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-1 .item_1_3",
                        'sTime': 12,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-1 .item_1_4",
                        'sTime': 13,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-1 .item_1_5",
                        'sTime': 14,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-1 .item_1_6",
                        'sTime': 15,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }
                    ],
                    title: "",
                    description: "",
                    transcript: '<p><b>What is Rounding?</b></p> <p>Rounding occurs when an employee\'s timesheet is rounded either up or down to the shift start or end time.</p><p>Rounding has typically been done to the nearest tenth of the hour (3 minutes before or after the start or end of the shift) or quarter hour (7 minutes before or after the start or end of a shift) upon clock-in and clock-out.</p> <p>Rounding may still be permissible in some states, including California; however, rounding policies must be neutral, fair, and ensure that employees are not underpaid. More often than not, employers are finding challenges in the courts regarding the fairness of this practice or "rounding" in favor of exact time payment.</p>'
                },
                {
                    id: "3",
                    autoplay: true,
                    url: './views/m01_l03_p03_02/m01_l03_p03_02_02.mp3',
                    timeline: [{
                        'element': "#sub-sections-2 .item_2_0",
                        'sTime': 0,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-2 .item_2_1",
                        'sTime': 0.5,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-2 .item_2_2",
                        'sTime': 19,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-2 .item_2_3",
                        'sTime': 26,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-2 .item_2_4",
                        'sTime': 49,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }],
                    title: "",
                    description: "",
                    transcript: '<p><b>Why do clients request rounding?</b></p><ul><li>It is very common for clients to request the use of rounding because they believe that this prevents employees from "stealing time" (such as, being paid for time spent doing other things besides working, such as getting coffee, chatting with co-workers, etc.).</li><li>Many clients will resist any changes to the way rounding is set up on the ground that rounding is permissible.</li><li>While rounding is legal under certain circumstances, it is very easy for rounding to become a liability, for both Employbridge and the client, if not done correctly or when we are not able to provide records that refute a claim that an employee (or employees) were not properly compensated for all time worked because of the rounding system in place.</li><li>The employer will have the responsibility to establish that the rounding does not result in a failure to compensate employees properly for compensable time.</li></ul>'
                },
                {
                    id: "4",
                    autoplay: true,
                    url: './views/m01_l03_p03_02/m01_l03_p03_02_03.mp3',
                    timeline: [{
                        'element': "#sub-sections-3 .item_3_0",
                        'sTime': 0.5,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-3 .item_3_1",
                        'sTime': 4,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-3 .item_3_2",
                        'sTime': 7,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-3 .item_3_3",
                        'sTime': 13,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-3 .item_3_4",
                        'sTime': 18,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }
                    ],
                    title: "",
                    description: "",
                    transcript: '<p>Sometimes compensable time can be overlooked. Some examples are:</p><ul><li>Meetings at the beginning or end of shift.</li><li>Donning and doffing (putting on or taking off special clothing or other requirements to do the work).</li><li>Preparation for start of shift-checking equipment, loading supplies, etc.</li><li>Security or health checks</li></ul>'
                },
                {
                    id: "5",
                    autoplay: true,
                    url: './views/m01_l03_p03_02/m01_l03_p03_02_04.mp3',
                    timeline: [{
                        'element': "#sub-sections-4 .item_4_0",
                        'sTime': 0.5,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-4 .item_4_1",
                        'sTime': 6,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-4 .item_4_2",
                        'sTime': 14,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-4 .item_4_3",
                        'sTime': 24,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }],
                    title: "",
                    description: "",
                    transcript: '<p><b>What if, when a client is challenged?</b></p><p>If challenged, an employer will have to establish that:</p><ul><li>The policy is either entirely neutral or benefits the employee. This requires a review of all time records.​</li><li>An employer cannot always round time in one direction that results in an employee never receiving the benefit of the rounding (equivalent to a buffer).</li><li>No work or compensable activity was performed during the rounding period (time before or after the shift that is not treated as compensable time).</li></ul><p>The exposure lies in both failure to pay straight time and overtime and can become significant very quickly.</p> '
                },
                {
                    id: "6",
                    autoplay: true,
                    url: './views/m01_l03_p03_02/m01_l03_p03_02_05.mp3',
                    timeline: [{
                        'element': "#sub-sections-5 .item_5_0",
                        'sTime': 0.2,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-5 .item_5_1",
                        'sTime': 4,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-5 .item_5_2",
                        'sTime': 33,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-5 .item_5_3",
                        'sTime': 34,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-5 .item_5_4",
                        'sTime': 59,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-5 .item_5_5",
                        'sTime': 61.28,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }
                    ],
                    title: "",
                    description: "",
                    transcript: '<p><b>What are the potential legal liability created by rounding?</b></p><p>Timesheet rounding can leave employers at a higher risk of violating the Fair Labor Standards Act (the federal law that governs wage and hour regulations) as well as specific state laws. Using rounding makes employers more vulnerable to wage and hour violations because it is very easy to inadvertently violate the law when using rounding and it is difficult to defend against lawsuits claiming unpaid wages when rounding is in place.</p><p><b>Off-the-clock:</b></p><p>This refers to tasks such as donning and doffing, pre-shift meetings, preparation for shift (equipment inspections, etc.). Off-the-clock work violates both federal law (Fair Labor Standards Act) and state laws. Failing to pay employees for any time worked off-the-clock—even just a few minutes each day—could result in large lawsuits.​</p><p>Rounding practices primarily benefit the employer. This is because in order for an employer to establish that rounding is lawful, the employer must be able to show that the employee benefited from the rounding practice just as frequently or more frequently than the employer. This is a difficult standard to meet because more often than not, employees arrive early to avoid being late to a scheduled shift. Understandably, employers want their employees to arrive at work in time for their shift start and do not want employees to leave before the shift ends. Naturally, this means that employees tend to be more inclined to clock in before shift start so they are there on time to start their shift.</p>'
                },
                {
                    id: "7",
                    autoplay: true,
                    url: './views/m01_l03_p03_02/m01_l03_p03_02_06.mp3',
                    timeline: [{
                        'element': "#sub-sections-6 .item_6_0",
                        'sTime': 0.2,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-6 .item_6_1",
                        'sTime': 3,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-6 .item_6_2",
                        'sTime': 17,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-6 .item_6_3",
                        'sTime': 34,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }, {
                        'element': "#sub-sections-6 .item_6_4",
                        'sTime': 54,
                        'eTime': '',
                        'classIn': 'd-show',
                        'classOut': ''
                    }],
                    title: "",
                    description: "",
                    transcript: '<p>Let us now look at California-specific issues with rounding:</p><ul><li>A recent case held that rounding is not permissible in California. This case will be heard by the California Supreme Court.</li><li>Because of the significant wage and hour exposure, we do not allow rounding in California.</li><li>It is important to explain to clients that both Employbridge and the client can be liable for wage and hour violations under the joint employer liability theory. Therefore, using minute to minute timekeeping protects both Employbridge and the client. </li><li>California agreements include specific provisions regarding rounding and indemnification that will make the client entirely responsible if rounding is required by the client. However, it is common for clients to push back on these provisions and insist that Employbridge take full responsibility for any wage and hour claims.</li></ul>'
                }
            ]
        }];
        return _data;
    };

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