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