Add AMD/commonJS compatibility

I put in a relatively standard block that looks for different JavaScript module loaders and uses them if available, otherwise it defaults to the previous behavior of just sending globals to the closure.
updated with AMD/commonJS compatible code
Merge pull request #5 from isochronous/patch-1

Add AMD/commonJS compatibility