making the javascript do my bidding - jesus, what a messy language