$(function() {
  document.createElement('header');
  document.createElement('section');


  var title            = $('#contact h2').remove();
  var emailAddress     = $('#contact p').remove();
  var emailText        = emailAddress.text().replace(' [at] ', '@').replace(' [dot] ', '.');
      emailAddress.text(emailText);
  var emailLink = '<a href="mailto:' + emailText + '"></a>';

  $('#contact').append(emailLink);
  $('#contact a').append(title).append(emailAddress);
   

  $('a[rel=external]').click(function() {
    var newWindow = window.open($(this).attr('href'), '_blank');
    if(newWindow) { if(newWindow.focus) { newWindow.focus(); return false; } }
    newWindow = null;
  });

  $('.photo').hover(
    function() {
      var newValue   = '-' + ($(this).find('img').height() - $(this).height()) + 'px';
      var properties = {}
          properties[$(this).hasClass('bottom') ? 'bottom' : 'top'] = newValue;
      
      $(this).find('img').animate(properties, 150, 'swing');
    },
    function(){
      var properties = {}
          properties[$(this).hasClass('bottom') ? 'bottom' : 'top'] = '0px';
      $(this).find('img').animate(properties, 150, 'swing');
    }
  );
});
