jQuery check/uncheck all checkboxes in a form

jQuery check/uncheck all checkboxes in a form

Hi All,
 
I am very new to jQuery, but I have checked over my code several times and cannot find what I've done wrong with my first script, which is to check/uncheck all checkboxes in a html form. Nothing is checking or unchecking, and I am seeing the "Error on this page" in IE whenever i first click one of the two buttons.
 
Here are the steps I have taken
 
1. I have imported the jQuery library which I have just downloaded (1.4.2 development version, 155kb) with the following code:
 
  1. < script type = "text/javascript" src = "styles/jquery.js" > </ script >
For the record, the script is definitely in the correct location, under the correct name.
 
2. I also have the following function in my "head" tags.
 
  1. < script type = "text/javascript" >
  2.        function CheckAll( id, name, flag )
  3.       {
  4.              if (flag == 0 )
  5.             {
  6.                   $( "form#" + id + " INPUT[@name=" + name + "][type='checkbox']" ).attr( 'checked' , false);
  7.             }
  8.             else
  9.             {
  10.                   $( "form#" + id + " INPUT[@name=" + name + "][type='checkbox']" ).attr( 'checked' , true);
  11.             }
  12.       }
  13. </ script >
Which I didn't think was a problem (I will be reusing the function many times in different forms with different checkbox names in my site)
 
3. I have a form with a name of "news" and id of "news" also, and checkboxes like this:
 
  1. <input class="check" type="checkbox" name="deletenews" value="1" />
 
as you can see, the name being "deletenews"
 
4. Finally, my check and uncheck buttons are as follows
 
  1. <input class="button" type="button" value="Select All" name="CheckAll" onclick="CheckAll('news', 'deletenews', 1);" />
  2. <input class="button" type="button" value="De-Select All" name="UnCheckAll" onclick="CheckAll('news', 'deletenews', 0);" />

 
I would much appreciate any help, and i'm sorry for the long post, just wanted to make sure you knew everything I was trying to do to save time.
 
Regards,
Jason