jQuery checkbox multi select
<p>I have the following code for selecting multiple checkboxes:</p>

<pre><code>$(document).ready(function() {

    /* All groups functionality */
    $(".allGroups").change(function() {
        var checked = this.checked;
        if (checked == true) {
            $(".group").attr("checked", true);
            $(".c").attr("checked", true);
        }
        if (checked == false) {
            $(".group").attr("checked", false);
            $(".c").attr("checked", false);
        }
    })

    /* Individual Group functionality */
    $(".group").change(function() {
        var checked = this.checked;
        var number = this.value
        var set = '.group-' + number;
        $(set).attr("checked", checked);
    })


} )
</code></pre>

<p>I gave 'contacts' the class <code>c</code> and <code>group-#</code>. Groups get the class <code>group</code>.
The select all checkbox gets <code>.allGroups</code></p>

<p>Now how do I achieve that the 'select all' checkbox unchecks itself when not everything is checked anymore?</p>

<p>Got a jsFiddle up here: <a href="http://jsfiddle.net/nqHtu/1/" rel="nofollow">http://jsfiddle.net/nqHtu/1/</a></p>
