update javascript

timer function now has a max waiting time of 10 seconds, so that it can still adjust itself without taxing cpu.

a new function hook has been created, so that custom script can be easily added to the form submit event.