You can't change calculated fields through the API, but you can use Parameters (or multiple parameters) to mimic this behavior.
IF [MyJSParam] = "Type1"
THEN [Type1 Calculation]
ELSEIF [MyJSParam] = "Type2"
THEN [Type2 Calculation]
Or, something like this:
IF [Country] = [JS Country A] OR [Country] = [JS Country B] OR ...
Hope this helps!
I've been doing that for the obvious combinations...
but when you have 100+ countries, it's not feasible to do every combination like this.
Wish the JS API would allow you to do more things.