var initList = initList || [];
initList.push(function() {

    var buttons1 = $(".content_nav.tab1 .buttons");
    var sections1 = $(".content_nav.tab1 .time_line");
    var stage1 = 1;
    var num_sections1 = 5; //sections.children().length;
    var height_sections1 = 665; //1014;//parseInt (sections.children().css("width")) + parseInt(sections.children().css("marginRight") )  + parseInt(sections.children().css("marginLeft") );
    var time_factor1 = 1.5 * height_sections1;

    buttons1.click(function() {
        var variation;

        if ($(this).hasClass("prev")) {
            variation = "+=";
            stage1--;
        } else {
            variation = "-=";
            stage1++;
        }
        if (stage1 == 1) {
            $(".content_nav.tab1 .buttons.next").addClass('first');
        } else {
            $(".content_nav.tab1 .buttons.next").removeClass('first');
        }
        $(this).fadeOut(50,
            function() {
                sections1.animate({
                    marginTop: variation + height_sections1
                }, time_factor1, function() {
                    if (stage1 < 5) buttons1.last().fadeIn();
                    if (stage1 < 5 && stage1 > 1) buttons1.first().fadeIn();
                });
            });
    });

    var restart_button = $('.content_nav.tab1 .restart-button');
    restart_button.click(function() {
        stage1 = 1;

        sections1.animate({
            marginTop: 0
        }, time_factor1, function() {
            buttons1.last().fadeIn().addClass('first');
            buttons1.first().fadeOut();
        });

    });

    requirejs(['jquery', 'sgSlider'], function($, sgSlider) {
        sgSlider.pageEffectBool = true;
        sgSlider.pageEffect = function(elem) {
            //Control buttons

            if (elem.hasClass('page1')) {
                $('.prevNext .p_next').addClass('first');
                $('.prevNext .p_prev').hide();
            } else {
                $('.prevNext .p_next').removeClass('first');
                $('.prevNext .p_prev').show();
            }
            elem.slideDown(1000);
        }
    });
});