/* Author: Adam Jahnke */

$.fn.ready(function(){

  $('h1').animate({
    left: 0,
    opacity: 1
  }, 400);
  $('p').animate({
    left: 0,
    opacity: 1
  }, 600);

  $('a.email').click(function(){
    $('audio#mail')[0].play()
  });

  $('.scramble').each(function(){
    el = $(this);
    el.attr('data-text', el.text());
  });
  $('.scramble').hover(function(){
    el = $(this);
    text = el.data('text');
    repeat = setInterval(function(){
      chars = [];
      scramble = ''
      for (l = 0, i = text.length; l < i; l++){
        chars.push(l);
      };
      chars = _.shuffle(chars);
      for (l = 0, i = chars.length; l < i; l++){
        scramble += text[chars[l]];
      };
      el.text(scramble);
    }, 200);
  }, function(){
    el = $(this);
    el.text(el.data('text'));
    clearInterval(repeat);
  });

});

