$(function() {
  $('a[rel=external]').attr('target', '_blank');
  $('#agenda dt:not(.agenda-header), .over_mij_section #resultaten dt:not(.resultaten-header), .uitslagen_en_rankings_section #resultaten dt:not(.resultaten-header), #links dt, #newsletters dt').click(function(evt) {
    if($(this).hasClass('active')) {
      $(this).removeClass('active').next('dd:first').hide();
    } else {
      $('#agenda dt:not(.agenda-header), .over_mij_section #resultaten dt:not(.resultaten-header), .uitslagen_en_rankings_section #resultaten dt:not(.resultaten-header), #links dt, #newsletters dt').removeClass('active').next('dd').hide();
      $(this).addClass('active').next('dd:first').show();
    }
  });
  $('a[href=#wordlid]').click(openPopup);
});

function openPopup(evt) {
  evt.preventDefault();
  $('body').addClass('popup_visible');
  $('#popup a[href=#annuleren]').click(closePopup);
}

function closePopup(evt) {
  evt.preventDefault();
  $('body').removeClass('popup_visible');
  $('#popup a[href=#annuleren]').unbind('click', closePopup);  
}