/**
 * Main JS file for Casper behaviours
 */

/* globals jQuery, document */
(function ($, undefined) {
    "use strict";

    var $document = $(document);

    $document.ready(function () {

        var $postContent = $(".post-content");
        $postContent.fitVids();

        $(".scroll-down").arctic_scroll();

        $(".menu-button, .nav-cover, .nav-close").on("click", function(e){
            e.preventDefault();
            $("body").toggleClass("nav-opened nav-closed");
        });

    });

    // Arctic Scroll by Paul Adam Davis
    // https://github.com/PaulAdamDavis/Arctic-Scroll
    $.fn.arctic_scroll = function (options) {

        var defaults = {
            elem: $(this),
            speed: 500
        },

        allOptions = $.extend(defaults, options);

        allOptions.elem.click(function (event) {
            event.preventDefault();
            var $this = $(this),
                $htmlBody = $('html, body'),
                offset = ($this.attr('data-offset')) ? $this.attr('data-offset') : false,
                position = ($this.attr('data-position')) ? $this.attr('data-position') : false,
                toMove;

            if (offset) {
                toMove = parseInt(offset);
                $htmlBody.stop(true, false).animate({scrollTop: ($(this.hash).offset().top + toMove) }, allOptions.speed);
            } else if (position) {
                toMove = parseInt(position);
                $htmlBody.stop(true, false).animate({scrollTop: toMove }, allOptions.speed);
            } else {
                $htmlBody.stop(true, false).animate({scrollTop: ($(this.hash).offset().top) }, allOptions.speed);
            }
        });

    };
})(jQuery);

@@ -270,52 +270,8 @@
 );%0A%0A
-        $(%22.scroll-down%22).arctic_scroll();%0A%0A
     
@@ -454,330 +454,138 @@
     
-%7D);%0A%0A    // Arctic Scroll by Paul Adam Davis%0A    // https://github.com/PaulAdamDavis/Arctic-Scroll%0A    $.fn.arctic_scroll = function (options) %7B%0A%0A        var defaults = %7B%0A            elem: $(this),%0A            speed: 500%0A        %7D,%0A%0A        allOptions = $.extend(defaults, options);%0A%0A        allOptions.elem.click(
+    setTimeout(placeFootnotes, 1);%0A%0A        $(window).resize(placeFootnotes);%0A%0A    %7D);%0A%0A%7D)(jQuery);%0A%0Avar placeFootnotes = 
 function
  (ev
@@ -584,23 +584,17 @@
 tion
- (event
+(
 ) %7B%0A    
     
@@ -593,691 +593,433 @@
     
-        event.preventDefault();%0A            var $this = $(this),%0A                $htmlBody = $('html, body'),%0A                offset = ($this.attr('data-offset')) ? $this.attr('data-offset') : false,%0A                position = ($this.attr('data-position')) ? $this.attr('data-position') : false,%0A                toMove;%0A%0A            if (offset) %7B%0A                toMove = parseInt(offset);%0A                $htmlBody.stop(true, false).animate(%7BscrollTop: ($(this.hash).offset().top + toMove) %7D, allOptions.speed);%0A            %7D else if (position) %7B%0A                toMove = parseInt(position);%0A                $htmlBody.stop(true, false).animate(%7BscrollTop: toMove %7D, allOptions.speed
+if($('.footnotes').length %3E 0) %7B%0A        var numberOfFootnotes = $('.footnotes ol li').last().attr('id').substring($('.footnotes ol li').last().attr('id').indexOf(':')+1);%0A        var width = $(window).width();%0A%0A        if(width %3E 760) %7B%0A            for(var i=1; i%3C=numberOfFootnotes; i++) %7B%0A                var top = Math.floor($('#fnref%5C%5C:' + i).position().top);%0A                $('#fn%5C%5C:' + i).css('top', (top - 24) + 'px'
 );%0A 
@@ -1034,20 +1034,9 @@
    %7D
- else %7B%0A    
+%0A
     
@@ -1048,102 +1048,37 @@
    $
-htmlBody.stop(true, false).animate(%7BscrollTop: ($(this.hash).offset().top) %7D, allOptions.speed
+('a%5Bhref%5E=%22#fnref%22%5D').remove(
 );%0A 
@@ -1088,42 +1088,13 @@
     
-  
-  %7D%0A        %7D);%0A%0A    %7D;%0A%7D)(jQuery);%0A
+%7D%0A    %7D%0A%7D

Add function for placing footnotes