It is one of those jobs you think is only going to take about an hour and so far I have spent two days on it!
I think the code I have posted to date is flawed is several areas and is not a clean as I would like it to be. Sometimes it is best just to go back to the drawing board.
I noticed there is a forum for people whom like a challenge, so I could also try there.
Using JQuery might simplify the task, but again I'm not an expert at this.
When I find or am told the solution I'll let you all know!