javascript if function not defined