You can't really determine which checkbox was clicked first without catching the event in Javascript. What you're trying do is basically the same as a "select all" checkbox, except inverted in the case where you select it (everything else gets deselected) and I'm assuming just doing nothing in case it gets deselected.
Have a look at how Wicket's CheckboxMultipleChoiceSelector does it (particularly what AbstractCheckSelector and CheckboxSelector.js do). The code there adds click handlers to all the checkboxes plus the "select all" checkbox. The ones on the regular checkboxes update the "select all" and vice versa. You basically need the same, except you invert the effects.