Start of Javascript part of dialogue app.