Fixed some speed issue with Chrome.

Restructure to use JavaScript as the main interaction with the DOM.