finding x-nth tr of table (where x is current index of a looping array)

finding x-nth tr of table (where x is current index of a looping array)

I'm developing a plugin that lets you group table rows (based on "tr.subheader"s) and toggle them "open" or "closed". See here for a working example:

http://www.michaelsoutherton.com/sandbox/toggletablegroups/

The toggles work, and it even saves and loads the cookie correctly as well. The only thing I can't get it to do is "open/close" the appropriate table rows when the page loads. Specifically, I'm stuck on line 43 of the test page:
  1. $.each(CookieArray, function(index, value) {
  2.       var CurrentRow = $(tableID).find("tr.subheader:eq(" + index + ")");
  3.       ...
At this point I've stored the "open/closed" state of all my <tr class="subheader">s into a cookie and am now looping through the array. The line (in black) above is my attempt to try to select the subheader that is the [array index]-nth child of the table. So for example:

If I'm currently at the second index ( [1] ) of the array in the loop, and its value is 1 ("open"), I want to find the second instance of "tr.subheader" in the table (I want the second instance because it's at the second index of the array). The line I tried above, and all variations on it I could think of, keeps returning "-1".

Any suggestions?