// Inject the mailto link into the page via JS to prevent spam.
{ coded = "mL8xT@UHIbTHH.5T"
  key = "iN2LXVsJ7eDG6dQkvuoYErxlFTzRcApjwnISqbMHK3fam904PhCyW1gZOtU85B"
  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
}

// animate the scrolling to various bookmarks throughout the page.
$(function() {

    function scroll(direction) {

        var scroll, i,
                positions = [],
                here = $(window).scrollTop(),
                collection = $('.post');

        collection.each(function() {
            positions.push(parseInt($(this).offset()['top'],10));
        });

        for(i = 0; i < positions.length; i++) {
            if (direction == 'next' && positions[i] > here) { scroll = collection.get(i); break; }
            if (direction == 'prev' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
        }

        if (scroll) {
            $.scrollTo(scroll, {
                duration: 750
            });
        }
$(window).height();
        return false;
    }

    $("nav > ul > li > a").click(function() {
        $('#Container').scrollTo($($(this).attr("href")), {
            duration: 750
        });
        return false;
    });
});
