function moveodds(i,c)
	{
	var eq = document.eq;
	o = "odds["+i+"]";
	v = eval(eq[o].value ) * 1;

	if(isNaN(v)) v = 2;
	else if(v < 1) v = 2;

	if(v < 3) odds =  Math.round(v * 10)/10 + 0.1 * c;
	else if(v < 5) odds =  Math.round(v * 10)/10 + 0.2 * c;
	else if(v < 10) odds =  Math.round(v * 10)/10 + 0.5 * c;
	else if(v < 20) odds =  Math.round(v) + 1 * c;
	else if(v < 50) odds =  Math.round(v) + 5 * c;
	else if(v < 100) odds =  Math.round(v/10)*10 + 10 * c;
	else if(v < 500) odds =  Math.round(v/10)*10 + 50 * c;
	else odds =  eval(v) + 100 * c;
	eq[o].value = toPoundsAndPence(odds);
	update();
	}

function moveCommission(i,c)
	{
	var eq = document.eq;
	cm = "commission["+i+"]";
	v = eval(eq[cm].value ) * 1;

	if(isNaN(v)) v = 5;
	else if(v == 0) v = 5;
	else if(v < 0) v = 0.1;

	commission = v + (0.1 * c);
	eq[cm].value = toPoundsAndPence(commission);
	update();
	}

function toggle(i,type)
	{
	var eq = document.eq;
	var toggle = new Array();
	toggle[0] = "active["+i+"]";
	toggle[1] = "selection["+i+"]";
	toggle[2] = "odds["+i+"]";
	toggle[3] = "stakes["+i+"]";
	toggle[4] = "total["+i+"]";
	if(type == "lay")	toggle[5] = "win["+i+"]";
	else if(type == "back") toggle[5] = "bias["+i+"]";
	for(var t = 0; t < toggle.length ; t++)
		{
		if(toggle[t])
			{
			var item = toggle[t];
			if(eq[toggle[0]].checked == false)
				{
				eq[toggle[t]].className = "off";
				}
			else
				{
				eq[item].className = "smallbox";
				}
			}
		}
	}

function doColours()
	{

	var eq = document.eq;
	var len = eq.elements.length;
	for (var i = 0; i < len; i ++)
			{
			e=eq[i]
			if(e.name == "arb")
				{
				if(e.value>1)
				e.style.color = "red";
				else
				e.style.color = "black";
				continue;
				}
			if(parseFloat(e.value)<0)
				e.style.color = "red";
			else
				e.style.color = "black";
			}
	}

function toPoundsAndPence(n)
	{
	if (isNaN(n)) n = 0;
	var s = "" + Math.round(n * 100) / 100;
  	var i = s.indexOf('.');
  	if (i < 0) return s + ".00";
  	var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3);
  	if (i + 2 == s.length) t += "0";
	return  t;
	}

function setPointer(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
}

