$(function(){

  $.path = function(name, fn) {
    if(window.location.pathname.match(name)) fn();
  };

  // Enable the photo gallery
  $('#gallery a').zoomimage({caption: false});

  // Hover effect for nav
  $('#nav li').hover(hover_in, hover_out);

  function hover_in(){
    $(this).addClass('hover');
  }

  function hover_out(){
    $(this).removeClass('hover');
  }

  // All external links and documents need to open in a new window
  $('a').filter(function() {
    if(this.hostname !== location.hostname){ return true; }
    if(this.pathname.match('pdf')) { return true; }
    return false;
  }).click(function() {
    window.open($(this).attr('href'), '_target');
    return false;
  });

  $(function(){
    $.path('/donations/new', function(){
      $('#donation_flow').donations();
    });
  });

});
