$(document).ready(function(){
  filter = '<p>Select the contacts you\'re looking for:</p><ul id="service_filter">';
  $('#services input[type=hidden]').each(function(){
    filter += '<li><label><input type="checkbox" name="service" value="' + $(this).val() + '" checked="checked" /> ' + $(this).attr('name') + '</label></li>';
  });
  filter += '</ul>';
  $('table').before(filter);

  $('#service_filter input').change(function(){
    $('table tbody tr').hide();

    if ($(this).is(':checked'))
      $('.c_' + $(this).val()).removeClass('hidden_contact');
    else
      $('.c_' + $(this).val()).addClass('hidden_contact');

    $('table tbody tr:not(.hidden_contact)').show();
  });

  $('#service_filter input').attr('checked', false).trigger('change');
});