First, thank you all for your help!
It is fascinating how a solution very often comes when you get away from the problem. When I posted this question I was in the office working on a very complicated solution. I spent more than an hour testing various approaches. Nothing worked. But I learning some things about jQuery (good thing). Then it was time to go home. While driving home the solution came to me as a very simple and straight forward. So my suggestion: get in the car and drive around when you have an unsolvable problem :)
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham