Fixed distance calculation with javascript