Copied some of the javascript ready for the redesign