[WIP] a couple of improvements to the js, no functional changes at all

we've wrapped the whole file in a document ready function