{% extends "!layout.html" %}
{% block extrahead %}
	<link rel="stylesheet" href="{{ pathto("_static/custom.css", True) }}" type="text/css">
{% endblock %}
{% block footer %}
<script type="text/javascript">
	var menuItems = $('.wy-menu-vertical').find('a');

	var scrollItems = menuItems.map(function(){
		var item = $($(this).attr('href'));
		if (item.length) { return item; }
	});

	$(window).on('scroll',function(){
		var fromTop = $(this).scrollTop()

		var cur = scrollItems.map(function(){
			if ($(this).offset().top < fromTop+30) return this;
		});

		cur = cur[cur.length-1];
		var id = cur && cur.length ? cur[0].id : "";

		var target = $('#'+id);
		target.attr('id','');
		window.location.hash = '#'+id;
		target.attr('id',id);

		menuItems
			.parent().removeClass("current")
			.end().filter("[href='#"+id+"']").parent().addClass("current");
	});

	$(window).on('hashchange',function(){

		var hash = window.location.hash.replace('#','');

		menuItems
			.parent().removeClass("current")
			.end().filter("[href='#"+hash+"']").parent().addClass("current");
	})
</script>
{% endblock %}