Miscelaneous js functions