var $ = layui.jquery;
$(function() {;
	(function($) {
		$.fn.totop = function(opt) {
			var scrolling = false;
			return this.each(function() {
				var $this = $(this);
				$(window).scroll(function() {
					if(!scrolling) {
						var sd = $(window).scrollTop();
						if(sd > 100) {
							$this.fadeIn();
						} else {
							$this.fadeOut();
						}
					}
				});

				$this.click(function() {
					scrolling = true;
					$('html, body').animate({
						scrollTop: 0
					}, 500, function() {
						scrolling = false;
						$this.fadeOut();
					});
				});
			});
		};
	})($);

	$("#backtotop").totop();

});