I'm glad you pointed that out – I was completely baffled as to the cause of the behaviour Snuffleupagus described above. I should go and refresh my memory of Javascript before trying anything like this again.