Checking all checkboxes
You can streamline the code by caching the selectors; this will improve performance as well. Next, you should use prop instead of attr as the jQuery documentation states:


  The .prop() method should be used to set disabled and checked instead
  of the .attr() method.


Lastly, instead of using an if..else statement, you can write the condition inline, since checked expects a boolean, and the expression resolves to a boolean. In other words:

// Cache selectors
var $all = $('#checkall');
var $checks = $('input[type="checkbox"]').not($all);

$all.on('click', function () {
  $checks.prop('checked', $(this).is(':checked'));
});

$checks.on('click', function() {
  var checked = $checks.filter(':checked').length;
  $all.prop('checked', checked === $checks.length);
});


Here is a demo: http://jsfiddle.net/z7qy10nn/