refactor calculateInitialPosition method

Replace switch statements with if statements primarily for better
code readability.

There is a slight performance gain for switch in
firefox browsers, but all the other browsers seem to perform better
in if-else. So performance wise it is a status quo or slightly
better...