added docs for functions
converted to AMD to prevent window littering
fix missing ) -> causes js not to run