Merge pull request #11 from d10/js

Change PHP functions to JS.