First problem:
When the submit button is clicked, a new window is written to which means that you are in effect, dynamically creating a new page; the form is technically not being 'submitted' becuase you are having javascript handle everything on the client side instead of the data being sent...