/* A little mojo for when the iPhone or iPad changes orientation */
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
  var viewportmeta = document.querySelector('meta[name="viewport"]');
  if (viewportmeta) {
    viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
    document.body.addEventListener('gesturestart', function () {
      viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
    }, false);
  }
}

$(function() {
  // Reconstruct the email link
  $('a[rel=email]').click(function(){
    
    // Declare some variables
    var linkToDecode = $(this).attr('href');
    
    /* Replace items wrapped in brackets */
    linkToDecode = linkToDecode.replace('[mailme]', 'mailto:');
    linkToDecode = linkToDecode.replace('[at]', '@');
    linkToDecode = linkToDecode.replace('[dot]', '.');
    linkToDecode = linkToDecode.replace('[com]', 'com');
    
    // Construct the proper email link and title
    $(this).attr('href', linkToDecode);
  });
  
  // Blur effect on hover if appropriate for the screen size */
  if (document.documentElement.clientWidth > 480) {
    // Blur effect on hover of contact icons
    $('.contact_list li a').hover(function() {
      $('.contact_list li a').not(this).addClass('blur');
    }, function() {
      $('.contact_list li a').removeClass('blur');
    });
  }
});
