More semicolon fixes to make my editor happy.
remove document.write
reduced the number of global variables that did not need to be global