I try to stray from javascript because it is client side, I would much rather code some php (server side) and have it all out-putted into html because it will render in browsers with js turned off. If 97% of your visitors have it on then I say go for it and use your current method.