Working on the javascript. Needs refactoring though.