function GravarAposta(idConfronto)
{
	bolOK = true;
	intApostaCasa = document.getElementById('intApostaCasa'+idConfronto).value;
	if (intApostaCasa=='')
	{
		alert("Preencha o placar para o time mandante");
		document.getElementById('intApostaCasa'+idConfronto).focus();
		bolOK = false;
	}
	if (bolOK && isNaN(intApostaCasa))
	{
		alert("Preencha o placar para o time mandante com um valor numérico");
		document.getElementById('intApostaCasa'+idConfronto).focus();
		bolOK = false;
	}
	if (bolOK && intApostaCasa<0)
	{
		alert("Preencha o placar para o time mandante com um valor numérico maior ou igual a zero");
		document.getElementById('intApostaCasa'+idConfronto).focus();
		bolOK = false;
	}
	
	intApostaFora = document.getElementById('intApostaFora'+idConfronto).value;	
	if (bolOK && intApostaFora=='')
	{
		alert("Preencha o placar para o time visitante");
		document.getElementById('intApostaFora'+idConfronto).focus();
		bolOK = false;
	}
	if (bolOK && isNaN(intApostaFora))
	{
		alert("Preencha o placar para o time visitante com um valor numérico");
		document.getElementById('intApostaFora'+idConfronto).focus();
		bolOK = false;
	}
	if (bolOK && intApostaFora<0)
	{
		alert("Preencha o placar para o time visitante com um valor numérico maior ou igual a zero");
		document.getElementById('intApostaFora'+idConfronto).focus();
		bolOK = false;
	}
	
	if (bolOK)
	{
		aposta = '/_aposta/salvaraposta.asp?idConfronto='+idConfronto+'&intApostaCasa='+intApostaCasa+'&intApostaFora='+intApostaFora;		
		Desliga(idConfronto);		
		AbrirPagina(aposta,'btnGravar'+idConfronto,'POST',aposta,1);
	}
	else
	{
		bolTiltAposta = true; 	
	}
}

function Desliga(idConfronto)
{
	document.getElementById('intApostaCasa'+idConfronto).disabled = true;
	document.getElementById('intApostaFora'+idConfronto).disabled = true;	
}

function Liga(idConfronto)
{
	document.getElementById('intApostaCasa'+idConfronto).disabled = false;
	document.getElementById('intApostaFora'+idConfronto).disabled = false;
}

var bolTiltAposta = false;

function GravarTodasApostas()
{	
	try
	{		
		idConfrontoAux = document.fAposta.idConfronto;
		bolTiltAposta = false;
		for(x=0;x<idConfrontoAux.length;x++)
		{
			if (!bolTiltAposta)
				GravarAposta(idConfrontoAux[x].value)				
		}
	}
	catch(e){alert(e.description)};
}