Added gruntfile build process and universal module declaration pattern

Hi, I like this code. I needed to use it with RequireJS, and Node, but didn't want to have it leaving any traces in the global scope (which is generally the goal). I modified the code to use one of the universal module definition patterns: https://github.com/umdjs/umd

In doing so, I discovered a few variables here and there that weren't declared in a local scope (mostly "i"s in for loops). And I just spruced it up a bit.

I also added a gruntfile, and when grunt is run it will automatically check the code with jshint, place a versioned file into dist/ and minify it with uglify.js. The version is kept in package.json.

Grunt setup:

    # install grunt cli globally
    $ npm install -g grunt-cli 
    # install build dependencies locally
    $ npm install 

then

    $ grunt

Hope this is helpful. :)