Did you experiment with the previous code I posted to try and see why it wasn't working? If so, what were the results? It seems like the goal posts have changed each time you reply. I'd prefer to just work out a logical solution and debug it until it does work. It's hard to know why my code doesn't work without being able to debug it in context.
I'm going to have to ask to see the test pages so I can see all the variables and possibly advise you on a solution that I can verify actually works. Is this possible? Cheers Joel.