Javascript Function Extend