Added initial JavaScript code (needs rewriting)