Adding javascript to page

OK I've been playing with this for a few evenings and not having much luck.

I placed the code in my question/type/marvin/module.js file outside. The module.js is modified version of jme question type. It fires up the applet but wipes the page of everything else and I never called the module/functions from render.php. i think I have code in wrong place. Here is code i started with.