See attached file (javascript section that works at least under IE8 and Firefox 3.6 but should also work on older versions of these browsers).