2 function scrollToAnchor(anchor) {
4 var anchor_name = anchor.slice(1);
5 var element = $('a[name="' + anchor_name + '"]');
6 if (element.length > 0) {
7 $.scrollTo(element, 500, {offset: {top: -50, left: 0}});
8 foot_elem = $('#footnotes a[name="' + anchor_name + '"]');
9 if (foot_elem.length > 0) {
10 $(element).parent().highlightFade('yellow');
12 window.location.hash = anchor;
17 $.highlightFade.defaults.speed = 3000;
19 if ($('#toc li').length == 0) {
20 $('#menu li a[href="#toc"]').remove();
23 // On page load, scroll to anchor
24 scrollToAnchor(window.location.hash)
26 $('#toc, #themes, #book-text').delegate('click', 'a', function(event) {
27 event.preventDefault();
28 $('#menu li a.selected').click();
29 scrollToAnchor($(this).attr('href'));
32 $('#menu li a').toggle(function() {
33 $('#menu li a.selected').click();
34 $(this).addClass('selected');
35 $($(this).attr('href')).slideDown('fast');
37 $(this).removeClass('selected');
38 $($(this).attr('href')).slideUp('fast');