function limpiarFecha(d){
	d.value="";
	return true;
}

var nav4 = window.Event ? true : false;

function acceptNum(evt){
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57,'.' =46, ','=44
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57) );
}

function acceptNumPrecio(evt){
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57,'.' =46, ','=44
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57) || (key == 44)|| (key == 46));
}

function RevisaDNI(cadena) { 
	var dni = cadena; 
	letraNIE = dni.substr(0,1); 
	// compruebo si es un NIE
	if ((letraNIE=="X") || (letraNIE=="x")) 
		numero = dni.substr(1,dni.length-2); 
	else 
		numero = dni.substr(0,dni.length-1);  
	let = dni.substr(dni.length-1,1); 
	let = let.toUpperCase(); 
	numero = numero % 23; 
	letra='TRWAGMYFPDXBNJZSQVHLCKET'; 
	letra=letra.substring(numero,numero+1); 
	if (letra!=let){ 
		return false;  
	}else
		return true; 
} 
function str_replace(search, replace, subject) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
 
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}

//Retorna: 1 = NIF ok, 2 = CIF ok, 3 = NIE ok, -1 = NIF error, -2 = CIF error, -3 = NIE error, 0 = ??? error
function valida_nif_cif_nie(a) 
{
	
	var temp=a.toUpperCase();
	var cadenadni="TRWAGMYFPDXBNJZSQVHLCKE";
 
	if (temp!==''){
		//si no tiene un formato valido devuelve error
		if ((!/^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$/.test(temp) && !/^[T]{1}[A-Z0-9]{8}$/.test(temp)) && !/^[0-9]{8}[A-Z]{1}$/.test(temp))
		{
			return 0;
		}
 
		//comprobacion de NIFs estandar
		if (/^[0-9]{8}[A-Z]{1}$/.test(temp))
		{
			posicion = a.substring(8,0) % 23;
			letra = cadenadni.charAt(posicion);
			var letradni=temp.charAt(8);
			
			if (letra == letradni)
			{
			   	return 1;
			}
			else
			{
				return -1;
			}
		}
 
		//algoritmo para comprobacion de codigos tipo CIF
		suma = parseInt(a[2])+parseInt(a[4])+parseInt(a[6]);
		for (i = 1; i < 8; i += 2)
		{
			temp1 = 2 * parseInt(a[i]);
			temp1 += '';
			temp1 = temp1.substring(0,1);
			temp2 = 2 * parseInt(a[i]);
			temp2 += '';
			temp2 = temp2.substring(1,2);
			if (temp2 == '')
			{
				temp2 = '0';
			}
 
			suma += (parseInt(temp1) + parseInt(temp2));
		}
		suma += '';
		n = 10 - parseInt(suma.substring(suma.length-1, suma.length));
 
		//comprobacion de NIFs especiales (se calculan como CIFs)
		if (/^[KLM]{1}/.test(temp))
		{
			if (temp.charAt(8) == String.fromCharCode(64 + n))
			{
				return 1;
			}
			else
			{
				return -1;
			}
		}
 
		//comprobacion de CIFs
		if (/^[ABCDEFGHJNPQRSUVW]{1}/.test(temp))
		{
			temp = n + '';
			if (temp.charAt(8) == String.fromCharCode(64 + n) || temp.charAt(8) == parseInt(temp.substring(temp.length-1, temp.length)))
			{
				return 2;
			}
			else
			{
				return -2;
			}
		}
 
		//comprobacion de NIEs
		//T
		if (/^[T]{1}/.test(temp))
		{
			if (temp.charAt(8) == /^[T]{1}[A-Z0-9]{8}$/.test(temp))
			{
				return 3;
			}
			else
			{
				return -3;
			}
		}
 
		//XYZ
		if (/^[XYZ]{1}/.test(temp))
		{
			pos = str_replace(['X', 'Y', 'Z'], ['0','1','2'], temp).substring(0, 8) % 23;
			if (temp.charAt(8) == cadenadni.substring(pos, pos + 1))
			{
				return 3;
			}
			else
			{
				return -3;
			}
		}
	}
 
	return 0;
}
function validarAnuncio(){
	var error="";
	if (document.fAnuncio['titulo['+document.fAnuncio.iso639.value+']'].value == "")	{	
		error = error + "Debe escribir el título.\r\n";
	}
	if (document.fAnuncio['texto['+document.fAnuncio.iso639.value+']'].value == "")	{	
		error = error + "Debe escribir el texto.\r\n";
	}
		// validamos los datos del cliente
	if (document.fAnuncio.nombre_cliente.value == "")	{	
		error = error + "Debe escribir el nombre del cliente.\r\n";
	}
	if (document.fAnuncio.nif_cliente.value == "")	{	
		error = error + "Debe escribir el NIF del cliente.\r\n";
	}else{
		if(valida_nif_cif_nie(document.fAnuncio.nif_cliente.value)<=0){
			error = error +'NIF no válido\r\n';
		}
	}

	
	if (document.fAnuncio.telefono_cliente.value == "")	{	
		error = error + "Debe escribir el teléfono.\r\n";
	}else{
		if (/^([0-9\+\s\+\-\+\/\+\(\+\)\+\.])+$/.test(document.fAnuncio.telefono_cliente.value)){ 
		}else{ 
		error = error +'Teléfono 1 debe ser un teléfono válido\r\n';
		} 
	
	}
	if (document.fAnuncio.email_cliente.value == ""){	
		error = error + "Debe escribir el email del cliente.\r\n";
	}else{
		if (/^\w+([\.-]?\w*)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.fAnuncio.email_cliente.value)){ 
		}else { 
		error = error + "La dirección de email es incorrecta.\r\n"; 
		} 
	}


	if(error != "")	{	
		alert(error);
		return false;
	}else{// si no se ha producido ningun error, envia al formulario
		document.fAnuncio.submit();
	}
}

function validarReserva1(){
	
	var error='';
	
	if(!document.reserva.tarifa_id.value){
		error = error + "Debe seleccionar el tipo de carrera.\r\n";
	}
	
	if(document.reserva.num_personas.value=='' || document.reserva.num_personas.value>26){
		error = error + "Debe seleccionar el numero de personas entre 1 y 26.\r\n";
	}
	if(!document.reserva.fecha.value){
		error = error + "Debe seleccionar la fecha.\r\n";
	}
	if(error != "")	{
		alert(error);
		return false;
	}else{	
		document.reserva.submit();
	}
}
function compruebaNombreCarrera(){
	var error ='';
	if(!document.reserva.nombre_carrera.value){
		error = error + "Debe indicar el nombre de la carrera.\r\n";
	}
	if(error != "")	{
		alert(error);
		return false;
	}else{	
		document.reserva.submit();
	}
	
}
function validarHoraReserva(){
	var error ='';
	if(document.reserva2.hora_m.value=='' && document.reserva2.hora_t.value==''){
		var error= 'Seleccione la hora de inicio de la reserva.\r\n';
	}
	if(document.reserva2.hora_m.value!='' && document.reserva2.hora_t.value!=''){
		var error= 'Seleccione una hora de inicio de la reserva.\r\n';
	}
	if(error != "")	{
		alert(error);
		return false;
	}
	else{	
		document.reserva2.submit();
	}
}

function validarNuevoUsuario(){
	var error = "";
	
 	if (document.fNuevoCliente.nombre.value == "")	{	
		error = error + "Debe escribir el nombre.\r\n";
	}
	if (document.fNuevoCliente.apellidos.value == "")	{	
		error = error + "Debe escribir los apellidos.\r\n";
	}
	if (document.fNuevoCliente.nif.value == "")	{	
		error = error + "Debe escribir el DNI.\r\n";
	}else{
		if(valida_nif_cif_nie(document.fNuevoCliente.nif.value)<=0){
			error = error +'DNI no válido\r\n';
		}
	}
	if (document.fNuevoCliente.cp.value == "")	{	
		error = error + "Debe escribir el CP.\r\n";
	}
	if (document.fNuevoCliente.email.value == ""){	
		error = error + "Debe escribir el email.\r\n";
	}else{
		if (/^\w+([\.-]?\w*)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.fNuevoCliente.email.value)){ 
		}else { 
		error = error + "La dirección de email es incorrecta.\r\n"; 
		} 
	}
	
	
	if (document.fNuevoCliente.telefono1.value == ""){	
		error = error + "Debe escribir el teléfono.\r\n";
	}else{
		if (/^([0-9\+\s\+\-\+\/\+\(\+\)\+\.])+$/.test(document.fNuevoCliente.telefono1.value)){ 
		}else{ 
		error = error +'Teléfono 1 debe ser un teléfono válido.\r\n';
		} 
	
	}
	
	if(document.fNuevoCliente.telefono2.value != ""){
		if (/^([0-9\+\s\+\-\+\/\+\(\+\)\+\.])+$/.test(document.fNuevoCliente.telefono2.value)){ 
		}else{ 
		error = error +'Teléfono 2 debe ser un teléfono válido.\r\n';
		}
	}
	
	if(document.fNuevoCliente.password.value == ""){
		error = error +'Introduzca la contraseña.\r\n';
	}
	if(document.fNuevoCliente.password2.value == ""){
		error = error +'Confirme la contraseña.\r\n';
	}
	
	if(document.fNuevoCliente.password.value != document.fNuevoCliente.password2.value){
		error = error +'Compruebe que las contraseñas son iguales.\r\n';
	}
	if(document.fNuevoCliente.como_nos_conocio.value ==''){
		error = error + 'Seleccione cómo nos conocio.\r\n';
	}
	
	// si se ha producido algun error que salte la alerta
	if(error != "")	{
		alert(error);
		return false;
	}else{// si no se ha producido ningun error, envia al formulario
		document.fNuevoCliente.submit();
	}
}
function compruebaMayorEdad(){
 	var miFechaActual = new Date() ;
 	
	var anoActual = miFechaActual.getFullYear();
	var mesActual = miFechaActual.getMonth()+1;
	var diaActual = miFechaActual.getDate()+1;
	
	var anioEdad = anoActual-document.fNuevoCliente.f_nac_Year.value;
	var mesesEdad = mesActual-document.fNuevoCliente.f_nac_Month.value;
	
	
	var diasEdad = diaActual-document.fNuevoCliente.f_nac_Day.value;
	
	
	if(anioEdad<18){
		return false;
	}else if(anioEdad==18){
		if((mesesEdad<0)){
			return false;
		}else if( (mesesEdad==0) & (diasEdad<=0)){
			return false;
		}else	
			return true;
	}else{
		return true;
	}
 }
 

function validarDatosUsuario(){
	var error = "";
	
 	if (document.fNuevoCliente.nombre.value == "")	{	
		error = error + "Debe escribir el nombre.\r\n";
	}
	if (document.fNuevoCliente.apellidos.value == "")	{	
		error = error + "Debe escribir los apellidos.\r\n";
	}
	if (compruebaMayorEdad() && document.fNuevoCliente.nif.value == "")	{	
		error = error + "Debe escribir el DNI.\r\n";
	}else{
		if(compruebaMayorEdad() && valida_nif_cif_nie(document.fNuevoCliente.nif.value)<=0){
			error = error +'DNI no válido\r\n';
		}
	
	}
	if (document.fNuevoCliente.cp.value == "")	{	
		error = error + "Debe escribir el cp.\r\n";
	}
	if (document.fNuevoCliente.email.value == ""){	
		error = error + "Debe escribir el email.\r\n";
	}else{
		if (/^\w+([\.-]?\w*)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.fNuevoCliente.email.value)){ 
		}else { 
		error = error + "La dirección de email es incorrecta.\r\n"; 
		} 
	}
	
	
	if (document.fNuevoCliente.telefono1.value == ""){	
		error = error + "Debe escribir el teléfono.\r\n";
	}else{
		if (/^([0-9\+\s\+\-\+\/\+\(\+\)\+\.])+$/.test(document.fNuevoCliente.telefono1.value)){ 
		}else{ 
		error = error +'Teléfono 1 debe ser un teléfono válido.\r\n';
		} 
	
	}
	
	if(document.fNuevoCliente.telefono2.value != ""){
		if (/^([0-9\+\s\+\-\+\/\+\(\+\)\+\.])+$/.test(document.fNuevoCliente.telefono2.value)){ 
		}else{ 
		error = error +'Teléfono 2 debe ser un teléfono válido.\r\n';
		}
	}
	
	
	if(document.fNuevoCliente.password.value != document.fNuevoCliente.password2.value){
		error = error +'Compruebe que las contraseñas son iguales.\r\n';
	}
	
	// si se ha producido algun error que salte la alerta
	if(error != "")	{
		alert(error);
		return false;
	}else{// si no se ha producido ningun error, envia al formulario
		document.fNuevoCliente.submit();
	}
}

function validaLogin(){
	
	var error="";
	
	if (document.login.email.value == ""){	
		error = error + "Debe escribir el email.\r\n";
	}else{
		if (/^\w+([\.-]?\w*)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.login.email.value)){ 
		}else { 
		error = error + "La dirección de email es incorrecta.\r\n"; 
		} 
	}
	if(document.login.password.value == ""){
		error = error +'Introduzca la contraseña.\r\n';
	}
	// si se ha producido algun error que salte la alerta
	if(error != "")	{
		alert(error);
		return false;
	}else{// si no se ha producido ningun error, envia al formulario
		document.login.submit();
	}
}
function validarCambioPass(){
	
	var error="";
	
	if (document.login.email.value == ""){	
		error = error + "Debe escribir el email.\r\n";
	}else{
		if (/^\w+([\.-]?\w*)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.login.email.value)){ 
		}else { 
		error = error + "La dirección de email es incorrecta.\r\n"; 
		} 
	}
	
	// si se ha producido algun error que salte la alerta
	if(error != "")	{
		alert(error);
		return false;
	}else{// si no se ha producido ningun error, envia al formulario
		document.login.submit();
	}
}


function confirma(pregunta, url, objeto){
	if (confirm(pregunta)){
		window.location.href=url;
	}else{
		objeto.checked = false;
	};
}


function validaFormCarrera(){
	for(var i=0;i<(document.carrera.length)-3;i++){
	
		if (document.carrera.elements[i].value==''){
			i=document.carrera.length;
			alert('Todos los campos son obligatorios');
			return false;
		}
	}
	document.carrera.submit();
}

function cambia_mes(objeto,enlace){
	enlacea = enlace+objeto.value+"&btn=combo";
	document.location.href=enlacea;
}
function muestraTiempos(fecha,usuario){
	var temp = new Array();
	temp = fecha.split('/');
	var dia=temp[0];
	var mes=temp[1];
	var anio=temp[2];
	var tiemposUsr ={
		success:muestroTiempoUsr,
		failure:muestroTiempoUsr
	}
	var request = YAHOO.util.Connect.asyncRequest('GET', "../ajax/muestra_tiempos.php?dia="+dia+"&mes="+mes+"&anio="+anio+"&usuario_id="+usuario, tiemposUsr); 
	return(false);
}


function muestroTiempoUsr(o){
	var recojo = o.responseText; 
	capita = document.getElementById('mostrar_tiempos');
	capita.style.display = 'block';
	capita.innerHTML = recojo;
}

function aceptarInvitacion(invitacion_id,campeonato_id){
	
	var invitacion ={
		success: function(o) {
					var recojo = o.responseText;
					var temp = new Array();
					temp = recojo.split('|');
					// mensaje de la transaccion
					capas_msj = document.getElementById('respuestaOK');
					capas_msj.style.display = 'none';
					capas_msj = document.getElementById('respuestaKO');
					capas_msj.style.display = 'none';
					
					if(temp[0]=='KO' || temp[0]=='OK'){
						var namecapa='respuesta'+temp[0];
						capa_msj = document.getElementById(namecapa);
						capa_msj.style.display = 'block';
					}
					
					if(temp[2]!=""){// viene de campeonatos, eviamos por ajax para mostrar su contenido
						// cargaDatosCampeonato(temp[2]);
						// ponemos estado pendiente
						document.getElementById('acepta_'+invitacion_id).innerHTML=''
						document.getElementById('rechazar_'+invitacion_id).innerHTML=''
						document.getElementById('estado_'+invitacion_id).innerHTML='Pte. Confirmaci&oacute;n';
					}
					
					return false;
			},
				failure: function(o) {
					var recojo = o.responseText;
					var temp = new Array();
					temp = recojo.split('|');
					// mensaje de la transaccion
					capas_msj = document.getElementById('respuestaOK');
					capas_msj.style.display = 'none';
					capas_msj = document.getElementById('respuestaKO');
					capas_msj.style.display = 'none';
					
					if(temp[0]=='KO' || temp[0]=='OK'){
						var namecapa='respuesta'+temp[0];
						capa_msj = document.getElementById(namecapa);
						capa_msj.style.display = 'block';
					}
			
			
					if(temp[2]!=""){// viene de campeonatos, eviamos por ajax para mostrar su contenido
						// cargaDatosCampeonato(temp[2]);
						// ponemos estado pendiente
						document.getElementById('acepta_'+invitacion_id).innerHTML=''
						document.getElementById('rechazar_'+invitacion_id).innerHTML=''
						document.getElementById('estado_'+invitacion_id).innerHTML='Pte. Confirmaci&oacute;n';
					}
					
					return false;
			}
	}
	var request = YAHOO.util.Connect.asyncRequest('GET', 
												  "../ajax/invitacion.php?accion=aceptar&invitacion_id="+invitacion_id+"&campeonato_id="+campeonato_id,
												  invitacion); 
	return(false);
}
function rechazarInvitacion(invitacion_id,campeonato_id){
	var invitacion ={
		success:resultInvitacion,
		failure:resultInvitacion
	}
	var request = YAHOO.util.Connect.asyncRequest('GET', 
												  "../ajax/invitacion.php?accion=rechazar&invitacion_id="+invitacion_id+"&campeonato_id="+campeonato_id,
												  invitacion); 
	return(false);
}

function resultInvitacion(o){
	var recojo = o.responseText;
	var temp = new Array();
	temp = recojo.split('|');
	// mensaje de la transaccion
	capas_msj = document.getElementById('respuestaOK');
	capas_msj.style.display = 'none';
	capas_msj = document.getElementById('respuestaKO');
	capas_msj.style.display = 'none';
	
	if(temp[0]=='KO' || temp[0]=='OK'){
		var namecapa='respuesta'+temp[0];
		capa_msj = document.getElementById(namecapa);
		capa_msj.style.display = 'block';
	}


	if(temp[1]!=""){
		var rowNumber=document.getElementById('invitacion_'+temp[1]).rowIndex;
		deleteRow("tbl_invitaciones",rowNumber);
	}
	
	
	return false;
}
function cargaDatosCampeonato(campeonato_id){
	var campeonato ={
			success:resultCampeonato,
			failure:resultCampeonato
		}
		var request = YAHOO.util.Connect.asyncRequest('GET', 
													  "../ajax/campeonato.php?campeonato_id="+campeonato_id,
													  campeonato); 
		return(false);
}

function resultCampeonato(o){
	var recojo = o.responseText;
	var temp = new Array();
	temp = recojo.split('|');
	// añadimos la fila correspondiente, pasamos el nombre de la tabla y los
	// campos (celdas) en un array [valor1,valor2,....]
	addRow('tbl_campeonatos',temp);

}


function addRow(tableId, cells){
	 var tableElem = document.getElementById(tableId);
	 var newRow = tableElem.insertRow(tableElem.rows.length);
	 var newCell;
	 for (var i = 0; i < cells.length; i++) {
	  newCell = newRow.insertCell(newRow.cells.length);
	  newCell.innerHTML = cells[i];
	 }
	 return newRow;
	}

function deleteRow(tableId, rowNumber){
	 var tableElem = document.getElementById(tableId);
	 if (rowNumber > 0 && rowNumber < tableElem.rows.length) {
	  tableElem.deleteRow(rowNumber);
	 }
}

function muestraClasificacion(id){
		var resultados ={
					success:function(o){
						// contenido_tandas
						document.getElementById('resultados').innerHTML=o.responseText;
					},
					failure:function(o){
						document.getElementById('resultados').innerHTML=o.responseText;
					}		
					};
		
		var request = YAHOO.util.Connect.asyncRequest('GET', "../ajax/resultadosCampeonatoWeb.php?accion=campeonato&id="+id , resultados);
}
function muestraClasificacionCarrera(id_campeonato){
	var resultados ={
			success:function(o){
		// contenido_tandas
		document.getElementById('resultados').innerHTML=o.responseText;
	},
	failure:function(o){
		document.getElementById('resultados').innerHTML=o.responseText;
	}		
	};
	
	var request = YAHOO.util.Connect.asyncRequest('GET', "../ajax/resultadosCampeonatoWeb.php?accion=carrera&id="+id_campeonato , resultados);
}
function muestraClasificacionTanda(id_campeonato){
	var resultados ={
			success:function(o){
		// contenido_tandas
		document.getElementById('resultados').innerHTML=o.responseText;
	},
	failure:function(o){
		document.getElementById('resultados').innerHTML=o.responseText;
	}		
	};
	
	var request = YAHOO.util.Connect.asyncRequest('GET', "../ajax/resultadosCampeonatoWeb.php?accion=tanda&id="+id_campeonato , resultados);
}
function muestraClasificacionCarreraFecha(id_campeonato,id_fecha){
	var resultados ={
			success:function(o){
		// contenido_tandas
		document.getElementById('resultados').innerHTML=o.responseText;
	},
	failure:function(o){
		document.getElementById('resultados').innerHTML=o.responseText;
	}		
	};
	
	var request = YAHOO.util.Connect.asyncRequest('GET', "../ajax/resultadosCampeonatoWeb.php?accion=carrera&id="+id_campeonato+"&carrera_id="+id_fecha , resultados);
}
function muestraClasificacionCarreraTanda(id_campeonato,id_tanda){
	var resultados ={
			success:function(o){
		// contenido_tandas
		document.getElementById('resultados').innerHTML=o.responseText;
	},
	failure:function(o){
		document.getElementById('resultados').innerHTML=o.responseText;
	}		
	};
	
	var request = YAHOO.util.Connect.asyncRequest('GET', "../ajax/resultadosCampeonatoWeb.php?accion=tanda&id="+id_campeonato+"&tanda_id="+id_tanda , resultados);
}

function guardaConfirmacionCampeonato(campo){
	
	var num_pilotos_confirmados=parseInt(document.getElementById('num_confirmados').value);
	var max_num_pilotos=parseInt(document.getElementById('max_num_pilotos').value);
	var aux = num_pilotos_confirmados+1;
	
	
	if((campo.checked==true) && (aux>=max_num_pilotos)){
		alert('Ya ha seleccionado '+max_num_pilotos+' pilotos.\r\n');
		campo.checked=false;
		return false;
	}
	
	var guardaConfirmacion ={
			success : function(o) {
				if( o.responseText=='KO'){
				alert('Se ha producido un error al confirmar al usuario');
				if(campo.checked==true)
					campo.checked=false;
				else
					campo.checked=true;
				}else{
					if(campo.checked==true){
						document.getElementById('num_confirmados').value=num_pilotos_confirmados+1;
					}else{
						document.getElementById('num_confirmados').value=num_pilotos_confirmados-1;
					}
				}
			},
			failure : function(o) {
				alert('Se ha producido un error al confirmar al usuario');
				if(campo.checked==true)
					campo.checked=false;
				else
					campo.checked=true;
			}
	};
	var request = YAHOO.util.Connect.asyncRequest('GET', "../ajax/confirmarInscripcionCampeonato.php?id="+campo.value+"&valor="+campo.checked , guardaConfirmacion);
}


function generarReserva(campeonato,fecha){
	var guardaConfirmacion ={
			success : function(o) {
				if( o.responseText=='KO'){
				alert('Se ha producido un error al confirmar la carrera');
				return false;
				}else{
					var recojo = o.responseText;
					var temp = new Array();
					temp = recojo.split('|');
					document.tpv.Ds_Merchant_Order.value=temp[0];
					document.tpv.Ds_Merchant_MerchantSignature.value=temp[1];
					//enviamos el formulario	
					document.tpv.submit();
				}
			},
			failure : function(o) {
				alert('Se ha producido un error al confirmar la carrera');
				return false;
			}
	};
	var request = YAHOO.util.Connect.asyncRequest('GET', "../ajax/confirmarCampeonato.php?id_campeonato="+campeonato+"&fecha="+fecha , guardaConfirmacion);
}