Check onAttach and onDetach are callable

Default handlers for onAttach and onDetach have been removed from the AJ object initializer.
This is causing a spurious error when AllJoyn.js is run with a script that does not setup these handlers.
Added a check that these functions exist and are callable before attempting to call the functions.

Change-Id: I8eff22a526d6d22437cf4169c0f71a7f8bb88a17
Signed-off-by: gburns <gburns@qce.qualcomm.com>