Tidying up the javascript

Moving the javascript into the web page for now. May need to be moved
again in future depending on how the example site is programmed. Issue
#2