Select all/unselect all checkbox

Select all/unselect all checkbox

Hi,

I'm using this code (http://jsfiddle.net/TzPW9/1/) which remembers which check box was checked on the page.  I would like to add a select all/unselect all check box but I'm not quite sure how to do this.  any help appreciated.

When I add this (see below) to the page it works but seems to interfere with the jQuery function from http://jsfiddle.net/TzPW9/1/ so the checkboxes aren't stored.

jQuery(document).ready(function(){
jQuery("#all").click(function(){
if(this.checked == true){
jQuery('.check').attr('checked','checked');
}else{
jQuery('.check').removeAttr('checked');
}
});
});