Question : help modifying javascipt for a checkbox control

The javascript attached is doing the following but needs to be revised to do something different.  Currently I have a gridview on my form with a checkbox in the header.  When a user checks this box
all the checkboxes are checked...and if they uncheck the box all the checkboxes are unchecked.  Essentially this action is performed by storing a value in a hidden control that keeps up with the state of the box.

Here is what I need revised:  If someone has already checked a box in the grid I need the javascript to not reverse the action but still check all or remove all the checkboxes.  Currently it just does the opposite of what state the checkbox is in.  so if I have a grid with 5 checkbox rows and one is already checked...When you click the check all box...it checks all the ones..and then one checkbox checked now becomes unchecked....

I also need a function to do something like this as well:  
If a user checks any checkbox in the gridview....while the check all box is checked...I need the check all box in the header to be removed and any and all checkboxes checked removed except the one the user just checked...


Please help...I am at a deadline on this one.

thanks

I am doing this javascript in an asp.net 2.0 environment by the way
and I do have AJAX enabled on this site as well.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:

   
   

Random Solutions  
 
programming4us programming4us