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