Expand and Closurize dygraph-utils.js

This moves a few additional methods into dygraph-utils.js and fixes closure errors.

It also introduces a new file, dygraph-types.js, which will be helpful for defining custom closure types.