moved open and close functions into the global javascript files to be called elsewhere. functions still buggy