Using custom JavaScript
There's three places where you can put your Javascript resources:


Your theme folder. If you have a theme in your site named Mechaflash, you could put it inside Mechaflash/js or just in Mechaflash. In order to make the theme folder "more organized", generally people create a dedicated js folder. I would place Javascript in the theme when your Javascript delivers functionality specific to the theme / presentation layer, or that it affects all of the site (global). 
In one of your custom modules. The same principle of creating a dedicated js folder can also apply here. I generally put JS on the modules when the Javascript is delivering a very specialized functionality relevant to a specific module. It also allows you to "package" your Javascript with your modules and to pass this modules to other sites (i.e. a modular approach).
In the site's library folder. I've never done this personally. Not because it's bad, but because I think it's reserved for more complex functionality that other modules (and themes) can use. A good example, the JQuery UI library.


You can do all of this using the drupal_add_js() function. Here are some examples of how to add a JS file from a module:

// Add a "javascript library" from your module. JS_LIBRARY is an integer constant with a value of -100, which means that `mecha_library.js` will be added before `mecha_ninja.js`.
$module_path = drupal_get_path('module', 'my_module');
drupal_add_js($module_path. 'js/mecha_library.js', array('group' =&gt; JS_LIBRARY));

// Add a javascript file from your module. The default 'group' here is JS_DEFAULT, so mecha_ninja.js will be added after mecha_library.js.
$path = drupal_get_path('module', 'my_module');
drupal_add_js($path. 'js/mecha_ninja.js', 'file');