$(function() {
  $("body").addClass("hasjs");
  
  // Dropdowns
  $("#header #nav > li").hover(function(){
    $(this).find("ul").slideDown("fast");
  }, function(){
    $(this).find("ul").slideUp("fast");
  });
    
  // Membership Details (Apply Online)
  $("#applications_new, #dues_new").find(".moreinfo").each(function() {
    var link = $(this),
        info = link.parent().next("p").hide();
    
    link.toggle(function(){
      info.slideDown("fast");
    }, 	function(){
      info.slideUp("fast");
    });
  });
  
  // iframe Sizing
  $("iframe").attr("height", "150");
  $("iframe").attr({
    height: "150",
    width: "400"
  });
    
  // RSVP Form Magic
  $("#events a.rsvp").click(function(e){
    e.preventDefault();
    $(this).parents(".event").next(".rsvp-form").slideDown(500, "swing");
    $(this).slideUp(300, "swing");
  });
  
  $("#archive a.rsvp").click(function(e){
    e.preventDefault();
    $(".rsvp-form").slideDown(500, "swing");
    $(this).slideUp(300, "swing");
  });
    
  // RSVP Confirmation Click-to-hide
  $("h2.rsvp-confirm").click(function(){
    $(this).slideUp(300, "swing");
  });
  
  // Handle Delete Links (Rails Style)
  $("a[data-confirm]").click(function(event) {
    if (!confirm("Are you sure?")) {
      event.preventDefault();
    }
  });
});
  
