// jQuery Konami Code Plugin
//    by Kyle Bragger <kyle@kylebragger.com>
//    Created May 11, 2009
//    Do with it what you will.

(function(jQuery) {
  jQuery.fn.upUpDownDown = function(o){
    var options = jQuery.extend({
      watchFor : [38,38,40,40,37,39,37,39,66,65],
      callback : function() { }
      }, o);
        
    var key_accum = [];
    var match = options.watchFor;
 
    $(document).keyup(function(e){
      len = key_accum.push(e.keyCode ? e.keyCode : e.charCode);
            
      if(len > match.length) key_accum.shift();

      if (key_accum.join('-') == match.join('-')) {
        key_accum = [];
        if (options.callback) {
          options.callback($(this));
        }
      }
    });
  };
})(jQuery);

jQuery(function($) {
  $('body').upUpDownDown({
    watchFor: [38,38,40,40,37,39,37,39,66,65], // Array of keyCode and charCodes to watch for
      // This represents a sequence, ordered left (first) to right      (last), so:
      // [38,38,40,40,37,39,37,39,66,65] == up up down down left right left right B A, in that order
    callback: function(){
      $('body').fadeOut(1000, function() {
        $(this).fadeOut(0, function() {
          $(this).html('<h1 class="quote">&ldquo;All truly great thoughts are conceived by walking.&rdquo;</h1><p class="quote">&nbsp;&nbsp;&nbsp;&nbsp;&mdash;&nbsp;Friedrich&nbsp;Nietszche</p>')
                 .fadeIn(1500);
        });
      });
    }
  });
  if (window.devicePixelRatio != null) {
    var contactText = $('#contact-link').text();
    
    var link = $('#contact-link').attr('data-contact');
    var text = '<a href="mailto:' + link + '">' + link + '</a>';
    $('#contact-link').html(text);    
  }
});
