How do I add javascript to a module?
You can declare the script file inside mymodule.info with

scripts[] = myscriptfile.js


This way it's gonna be included in every page of your site, exactly the same result you obtain adding it manually to hook_init.

In case you want it only when you render a form, add this to the form declaration

$form['#attached']['js'][] = drupal_get_path('module', 'mymodule).'myscriptfile.js';