Javascript function overloader