	function Finalizar()
	{
		var FORM = document.FormLoteria;
		var acumulado = 0;
		var URL = "Carrinho.php?Func=adicionar";
		var j=0;
		var erro = 0;
		
		//concursos
		if(FORM.Concurso.length > 0)
		{
			var Length = parseInt(FORM.Concurso.length);
			for(i=0; i < Length; i++)
			{
				var Concurso = FORM.Concurso[i].value;
								
				//boloes
				var NumBoloes = parseInt(FORM.NumBoloes[i].value)+parseInt(acumulado);
				
				for(y=(0+acumulado); y<NumBoloes; y++)
				{
					var Bolao = FORM.Bolao[y].value;
										
					var Q = Bolao.split("_");
					var Loteria = Q[0];
					var Concurso = Q[1];
					var IdBolao		= Q[2];
					var NomeSel = "LT"+ Loteria +"_"+ Concurso +"_"+ IdBolao;
					var Cotas = parseInt(document.getElementById(""+NomeSel+"").value);
						
					if(Cotas > 0)
					{
						if(j > 9)
						{
							alert("Nossos Bolões\n --------------------------------\n Você deve selecionar no máximo 10 bolões.\n");
							erro = 1;
							break;
						}
						else
						{
							var URL = URL + "&Aposta_"+ j +"="+ Bolao +"_"+ Cotas;
							j++;
						}
					}
				}
				var acumulado = parseInt(acumulado) + parseInt(FORM.NumBoloes[i].value);
			}
		}
		else
		{
			
			var Concurso = FORM.Concurso.value;
			var Length = 1;  
			
			//boloes
			var NumBoloes = parseInt(FORM.NumBoloes.value)+parseInt(acumulado);
				
			for(y=(0+acumulado); y<NumBoloes; y++)
			{
				if(NumBoloes > 1)
				{
					var Bolao = FORM.Bolao[y].value;
				}
				else
				{
					var Bolao = FORM.Bolao.value;
				}
				
				var Q = Bolao.split("_");
				var Loteria = Q[0];
				var Concurso = Q[1];
				var IdBolao		= Q[2];
				var NomeSel = "LT"+ Loteria +"_"+ Concurso +"_"+ IdBolao;
				var Cotas = parseInt(document.getElementById(""+NomeSel+"").value);
					
				if(Cotas > 0)
				{
					if(j > 9)
					{
						alert("Nossos Bolões\n --------------------------------\n Você deve selecionar no máximo 10 bolões.\n");
						erro = 1;
						break;
					}
					else
					{
						var URL = URL + "&Aposta_"+ j +"="+ Bolao +"_"+ Cotas;
						j++;
					}
				}
			}
			var acumulado = parseInt(acumulado) + parseInt(FORM.NumBoloes.value);
		}				
				
		if((j>0) && (erro == 0))
		{
			if(confirm("Nossos Bolões\n --------------------------------\n Colocar os bolões selecionados em seu carrinho de compras?\n"))
			{
				window.location= URL;
			}
		}
		else if(j == 0)
		{
			alert("Nossos Bolões\n --------------------------------\n Você deve selecionar no mínimo 1(um) dos bolões disponíveis.\n");
		}
	}