// JavaScript Document
resultados = {
	arrayLinks : new Array(),
	arrayClasses : new Array(),
	
	abrir : function(){
		document.getElementById('resultado').style.display = '';
		document.getElementById('ajuda').style.display = 'none';
		document.getElementById('numberGerado').style.display = 'none';
		document.getElementById('aResultados').className = 'aba on';
		document.getElementById('aFezinha').className = 'aba';
		
	},
	
	trocaJogo : function(idJogo){
		if(resultados.arrayLinks.length==0){
			resultados.arrayLinks.push('http://www1.caixa.gov.br/loterias/loterias/lotofacil/lotofacil_resultado.asp');
			resultados.arrayLinks.push('http://www1.caixa.gov.br/loterias/loterias/duplasena/duplasena_resultado.asp');
			resultados.arrayLinks.push('http://www1.caixa.gov.br/loterias/loterias/lotomania/lotomania_resultado.asp');
			resultados.arrayLinks.push('http://www1.caixa.gov.br/loterias/loterias/megasena/megasena_resultado.asp');
			resultados.arrayLinks.push('http://www1.caixa.gov.br/loterias/loterias/timemania/timemania_resultado.asp');
			resultados.arrayLinks.push('http://www1.caixa.gov.br/loterias/loterias/quina/quina_resultado.asp');
			
			resultados.arrayClasses.push('lotofacil');
			resultados.arrayClasses.push('duplasena');
			resultados.arrayClasses.push('lotomania');
			resultados.arrayClasses.push('megasena');
			resultados.arrayClasses.push('timemania');
			resultados.arrayClasses.push('quina');
		}
		if(idJogo!=0){
			ajax.post('j=' + idJogo,'http://www.paraasortetodomundoeigual.com.br/gadget/resultados.aspx');
			setTimeout("resultados.trocaJogoRetorno()",100);

			document.getElementById('h1TitJogo').className = resultados.arrayClasses[idJogo-1];
			document.getElementById('aMaisJogo').href = resultados.arrayLinks[idJogo-1];
			document.getElementById('aMaisJogo').style.display = '';
			//var url ='http://interno.playercom.net/2007/caixa/loterias/gadget/resultados.aspx?j=' + idJogo
			//gadgets.io.makeRequest(url, resultados.trocaJogoRetorno);
		}
	},
	
	trocaJogoRetorno : function(obj){
		if(ajax.retorno=='Processando'){
			setTimeout("resultados.trocaJogoRetorno()",100);
		}else if(ajax.retorno=='ok'){
			var objXML=ajax.objXML; 
			var numRodada   = objXML.getElementsByTagName("numRodada")[0].firstChild.nodeValue;
			var dtSorteio   = objXML.getElementsByTagName("dtSorteio")[0].firstChild.nodeValue;
			var dtProximaRodada   = objXML.getElementsByTagName("dtProximaRodada")[0].firstChild.nodeValue;
			
			document.getElementById('ddNumConcurso').innerHTML = numRodada + ' (' + dtSorteio + ')';
			document.getElementById('ddDataConcurso').innerHTML = dtProximaRodada;

			document.getElementById('ddResultadoConcurso').innerHTML = '';
			var xmlArray   = objXML.getElementsByTagName("valor");
			for(var i = 0 ; i < xmlArray.length ; i++) {
				var node = xmlArray[i];
				var valor = node.firstChild.nodeValue;
				document.getElementById('ddResultadoConcurso').innerHTML += '<span>' + valor + '</span>   ';
			}
			
			document.getElementById('dlNumConcurso').style.display = '';
			//document.getElementById('dlDataConcurso').style.display = '';
			document.getElementById('dlResultadoConcurso').style.display = '';
			
		}
	}
}
