(function() {

  $(function() {
    var extra_archives, meta;
    $('ul > li:last-child').addClass('last-child');
    $(window).resize(function() {
      return $('.container > .content').css('min-height', "" + ($(window).height() * 0.5 - $('.container > header').height() - $('.container > footer').height()) + "px");
    }).trigger('resize');
    extra_archives = $('.sidebar ul.archive li:gt(4)');
    extra_archives.hide().last().after('<li><a class="reveal" href="#">+' + extra_archives.length + ' more</a></li>');
    $('.projects .photography').each(function() {
      return window.flickr_checker_interval = window.setInterval((function() {
        var divs, img, n, _i, _len, _ref, _ref2, _results;
        if ($('.projects .photography').is(':has(.flickr_badge_image)')) {
          _ref = $('.projects .photography .flickr_badge_image img');
          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
            img = _ref[_i];
            if (!img.complete) return;
          }
          window.clearInterval(window.flickr_checker_interval);
          divs = $('.projects .photography .flickr_badge_image');
          _results = [];
          for (n = 0, _ref2 = divs.length - 1; 0 <= _ref2 ? n <= _ref2 : n >= _ref2; 0 <= _ref2 ? n++ : n--) {
            _results.push(divs.slice(n, n * 3 + 2).filter(':even:not(:animated)').each(function(i) {
              return $(this).delay(n * 100 + i * 50).animate({
                opacity: 1
              }, 500);
            }));
          }
          return _results;
        }
      }), 50);
    });
    $('.sidebar ul.archive li a.reveal').live('click', function(e) {
      e.preventDefault();
      return $(this).parent().hide().prevAll(':hidden').fadeIn();
    });
    if ($('body').is('.splash')) {
      meta = $('body.splash .container > header .meta');
      meta.data('original-html', meta.html());
      $('body.splash .container > header nav a').each(function() {
        return $(this).data('title', $(this).attr('title')).attr('title', null);
      }).mouseenter(function() {
        return $('p', meta).stop(true, true).hide().html($(this).data('title')).fadeIn();
      }).mouseleave(function() {
        return $('p', meta).stop(true, true).hide().html(meta.data('original-html')).fadeIn();
      });
      return $('body.splash .container > header h1').each(function() {
        var names;
        $(this).addClass('roller');
        $('.name', this).wrap($(document.createElement('span')).addClass('names'));
        names = $('.names', this);
        names.wrap($(document.createElement('span')).addClass('names-wrapper'));
        names.before($(document.createElement('span')).addClass('mask'));
        names.after($(document.createElement('span')).addClass('mask'));
        $.each($('.name:first', this).data('alternates').split(','), function(i, value) {
          return names.append($(document.createElement('span')).addClass('name').text(value));
        });
        names.append($('.name:first', this).clone());
        names.data('original-top', parseInt(names.css('top'))).bind('roll', function() {
          var d_roll, d_wind;
          if ($(this).is(':animated')) return;
          d_roll = 500 * $('.name', this).length;
          d_wind = 200;
          return $(this).css({
            top: $(this).data('original-top')
          }).animate({
            top: '+=4'
          }, d_wind, 'linear').delay(100).animate({
            top: -1 * $(this).height() + $('.name:first', this).outerHeight() + $(this).data('original-top')
          }, d_roll, function() {
            return $(this).css({
              top: $(this).data('original-top')
            });
          });
        }).mouseenter(function() {
          return $(this).trigger('roll');
        }).trigger('roll');
        return $('.names-wrapper').mouseenter(function() {
          if (!$('.names', this).is(':animated')) {
            return $('.names', this).trigger('roll');
          }
        });
      });
    }
  });

}).call(this);

