First version of refactored JavaScript. Uses location.href to get params instead of set on the server.