some functionality from afromb.py added in javascript
adding some stuff from afromb.py in js