I think you need to double define your functions because they are not inmediately assigned to the name you geve them in JS. Have a look at this: