split functions into TinFormFunctions.js

These functions can be reployed in other projects.
agent objects now work