Modified to support AMD, CommonJS, and global usage.

This effectively provides NodeJS support. It is a branch of #4.