$(document).ready(
	function(){
	    $(".one_menu_item a").click(function(){
                $(this).next(".two_menu").slideToggle("slow");
            });

            $(".two_menu_item a").click(function(){
                var play_state = $(this).next(".three_menu").css("display");
                if(play_state == "block"){
                    $(this).next(".three_menu").css("display", "none");
                    $(".three_menu").css("height", "auto");
                    $(this).removeClass("two_menu_open").addClass("two_menu_close");
                }else if(play_state == "none"){
                    $(this).next(".three_menu").css("display", "block");
                    $(".three_menu").css("height", "auto");
                    $(this).removeClass("two_menu_close").addClass("two_menu_open");
                }
            });
	    gitbook.page.hasChanged(init());
	    function init(){
		$('.active' + '.two').parent('.two_menu_item').parent('.two_menu').css("display", "block");
		$('.active' + '.three').parent('.three_menu_item').parent('.three_menu').parent('.two_menu_item').parent('.two_menu').css("display", "block");
		$('.active' + '.three').parent('.three_menu_item').parent('.three_menu').css("display", "block");
		$('.active' + '.three').parent('.three_menu_item').parent('.three_menu').parent('.two_menu_item').children('a').removeClass("two_menu_close").addClass("two_menu_open");
	    }
		
		
		var back_to_top_button = ['<div class="back-to-top"><i class="fa fa-arrow-up"></i></div>'].join("");
		$(".book").append(back_to_top_button)

		$(".back-to-top").hide();

		$('.book-body,.body-inner').on('scroll', function () {
			if ($(this).scrollTop() > 100) { 
				$('.back-to-top').fadeIn();
			} else {
				$('.back-to-top').fadeOut();
			}
		});

		$('.back-to-top').click(function () { 
			$('.book-body,.body-inner').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	}
);