function update()
{
	var eq = document.eq;
	var sum = 0;
	var max = 0;
	var odds = new Array();
	var stakes = new Array();
	var back_lay = new Array();
	var winnings = new Array();
	var total_stake = parseFloat(eq["outlay"].value);
	back_lay[1] = 'back';
	back_lay[2] = 'lay';
	for (var i = 1; i <= 2; i ++)
	{
		s = "stakes["+i+"]";
		o = "odds["+i+"]";
		odds[i] = eq[o].value;
		if(odds[i].charAt(odds[i].length-2) == "/")
		{
			odds[i] = eval(eq[o].value) + 1;
		}
		else
		{
			odds[i] = parseFloat(eq[o].value);
		}
	}

	for (var i = 1; i <= outcomes; i ++)
	{
		s = "stakes["+i+"]";
		if(back_lay[i] == 'back')
		{
			eq[s].value =  total_stake;
			stakes[i] = parseFloat(eq[s].value);
			winnings[i] = toPoundsAndPence(odds[i] * stakes[i]);
		}
		if(back_lay[i] == 'lay')
		{
			eq[s].value = toPoundsAndPence((odds[1]/odds[2]) * total_stake);
			stakes[i] = parseFloat(eq[s].value);
			winnings[i] =  toPoundsAndPence((odds[i]-1) * stakes[i]);
		}

	}

	for (var i = 1; i <= outcomes; i ++)
	{
		t = "total["+i+"]";
		c = "commission["+i+"]";
		commission = (100 - parseFloat(eq[c].value))/100;
		if(back_lay[i] == 'back')
		{
			eq[t].value = toPoundsAndPence((winnings[1] - total_stake - winnings[2]) * commission);
		}
		if(back_lay[i] == 'lay')
		{
			eq[t].value = toPoundsAndPence((stakes[2] - stakes[1]) * commission);
		}
	}

	if(!isNaN(sum) && sum > 0)
	{
		eq["outlay"].value = toPoundsAndPence(Math.round(sum * 10) / 10);
	}
	eq["arb"].value = toPoundsAndPence((odds[1])/(odds[2]));
	doColours();
}


