Load Javascript when a particular form is loaded
Loading which page causes the error? The enabled modules are loaded on every page request, because your module is enabled so it is loaded on pages, it tries to get an element that is not built yet!

Look at hook_init documentation. it says:


  This hook is run at the beginning of the page request. It is typically
  used to set up global parameters that are needed later in the request.
  When this hook is called, the theme and all modules are already loaded
  in memory.This hook is not run on cached pages.To add CSS or JS that
  should be present on all pages, modules should not implement this
  hook, but declare these files in their .info file.


So you shouldn't load the js files in there.

$(document).ready does not wait for images or scripts, try $(document).load