Update cloth.js

- switched to closure-based classes
- worked on generate id and check type functions
- created lookup table for check type
- the function wrapping all of the code is named cloth again instead of being anonymous