I would put all this js code in a separate .js file. What do you think?