﻿function updateCarrerasHtml(intAnio){
	strUrl = '/modules/results/results.ajax.php?op=changeanio&intAnio=' + intAnio+'&catego_id=' + $("catego_id").value;
	AppObj.Ajax.updaterAjax( strUrl,"Div_Resultados");
}

function changeCatego(catego_id){
	strUrl = '/modules/results/results.ajax.php?op=change&catego_id=' + catego_id;
	AppObj.Ajax.updaterAjax( strUrl,"Div_Resultados");	
}

function changeCategoResume(catego_id){
	strUrl = '/modules/results/results.ajax.php?op=changeresume&catego_id=' + catego_id;
	AppObj.Ajax.updaterAjax( strUrl,"DivDetalle");	
}

function getTandas(idCarrera,idCategoria,idCalendario){
	strUrl = '/modules/results/results.ajax.php?op=gettandas&idCarrera=' + idCarrera+'&idCategoria='+idCategoria+'&idCalendario='+idCalendario;
	AppObj.Ajax.updaterAjax( strUrl,"calendario");	
}
function changeRace(intRace){
	var aleatorio = Math.round(Math.random()*10000);
	strUrl = '/upload/htmls/resultados_'+$("selanio").value+'_'+intRace+'_'+$("catego_id").value+'.htm?ale='+aleatorio;
	AppObj.Ajax.updaterAjax( strUrl,"Div_Resultados");
}

function changeTandas(tanda){
	
	
	var elementos=$$('div.tanda');
	if(tanda.value==""){
		elementos.each(function(ele){ele.style.display=""})		
	}else{
		elementos.each(function(ele){ele.hide();});		
		$(tanda.value).style.display="";
	}
	
	
	
}

function changeanioresume(){
	var aleatorio = Math.round(Math.random()*10000);
	strUrl = '/upload/htmls/resultados_resumen_'+$("selanio").value+'_'+$("catego_id").value+'.htm?ale='+aleatorio;
	AppObj.Ajax.updaterAjax( strUrl,"DivDetalle");	
}

function getResume(){
	var aleatorio = Math.round(Math.random()*10000);
	strUrl  = '/upload/htmls/resultados_resumen_'+$("selanio").value+'_'+$("catego_id").value+'.htm?ale='+aleatorio;
	window.open (strUrl,'WindowResumenAnual','');
}

	function exportexcel(){
			var body=document.getElementsByTagName("body");
			var frm=document.createElement('form');
			frm.id="frm_send";
			frm.name="frm_send";		
			frm.action='/modules/results/index.php' ;
			frm.method="post";
			frm.target="_blank";
			
			
			var idop=document.createElement('input');
			idop.type="hidden";
			idop.id="op";
			idop.name="op";
			idop.value="exportexcel";
			frm.appendChild(idop);
			
			var idCategoria=document.createElement('input');
			idCategoria.type="hidden";
			idCategoria.id="catego_id";
			idCategoria.name="catego_id";
			idCategoria.value=$("catego_id").value;
			frm.appendChild(idCategoria);		
	
			
			var intAnio=document.createElement('input');
			intAnio.type="hidden";
			intAnio.id="intAnio";
			intAnio.name="intAnio";
			intAnio.value=$("selanio").value;
			frm.appendChild(intAnio);	
			
			body[0].appendChild(frm);
			
			frm.submit();
			Element.remove(frm);
	}
//	alert("ACA");
	function changepiloto(valor){
//		alert(valor);
		for(y=0;y<$("selpiloto").length;y++){
			if($("selpiloto")[y].value!=""){
				var elementos = document.getElementsByName("nbr_"+$("selpiloto")[y].value);			
				for(x=0;x<elementos.length;x++){//alert(elementos[x].name);
					elementos[x].style.color="black";
				}						
			}
		
		}
		if(valor!=""){
			var elementos = document.getElementsByName("nbr_"+valor);			
			for(x=0;x<elementos.length;x++){
				elementos[x].style.color="red";
			}	
		}



	}
	
	function exportpdf(){
			var body=document.getElementsByTagName("body");
			var frm=document.createElement('form');
			frm.id="frm_send";
			frm.name="frm_send";		
			frm.action='/modules/results/index.php' ;
			frm.method="post";
			frm.target="_blank";
			
			
			var idop=document.createElement('input');
			idop.type="hidden";
			idop.id="op";
			idop.name="op";
			idop.value="exportpdf";
			frm.appendChild(idop);
			
			var idCategoria=document.createElement('input');
			idCategoria.type="hidden";
			idCategoria.id="catego_id";
			idCategoria.name="catego_id";
			idCategoria.value=$("catego_id").value;
			frm.appendChild(idCategoria);		
	
			
			var intAnio=document.createElement('input');
			intAnio.type="hidden";
			intAnio.id="intAnio";
			intAnio.name="intAnio";
			intAnio.value=$("selanio").value;
			frm.appendChild(intAnio);	
			
			body[0].appendChild(frm);
			
			frm.submit();
			Element.remove(frm);
	}	
