Add AMD compatibility.

For requireJS etc.
Merging PR #9. Adds AMD support.