Javascript Pivot Point Calculator