complicated up the javascript and server code to handle popup windows and approval prompts