Javascript: Basic function wiring