Here is there's

```
function CalculateRatingChange()
{
// Ensure Elo1 is an number
var Elo1 = document.rating.elo1.value * 1;
// Ensure Elo2 is an number
var Elo2 = document.rating.elo2.value * 1;
// Ensure k value is a number
var K = document.rating.K.value * 1;
// Take the difference in the Elo's
var EloDifference = Elo2 - Elo1;
// This is where they do one calc and you do 2
// basically in your example works out to
// 1 / ( 1 + 10^.5) ~ 75%
var percentage = 1 / ( 1 + Math.pow( 10, EloDifference / 400 ) );
// Basically 25% goes to the win
var win = Math.round( K * ( 1 - percentage ) );
var draw = Math.round( K * ( .5 - percentage ) );
// Create the labels
if (win > 0 ) win = "+" + win;
// Create the labels
if (draw > 0 ) draw = "+" + draw;
// Write to the document
document.ratingchange.win.value = win;
document.ratingchange.draw.value = draw;
// 75% goes to the loss - in this example
document.ratingchange.loss.value = Math.round( K * ( 0 - percentage ) );
document.ratingchange.percent.value = Math.round( percentage * 100 ) + "%";
}
```