
	function copiarValor (id){
			document.FomInscripciones.ID_PRUEBA.value = id;
			document.FomListado.ID_PRUEBA.value = id;
	}
	function enviarFormulario(){
		if(document.FomInscripciones.ID_PRUEBA.value.length<1){
			alert("Debes seleccionar una Prueba");
			return false;
		}else if(document.FomInscripciones.DNI.value.length<1){
			return false;
		}else{
			document.FomInscripciones.submit();
		}
	}
    function enviarFormularioDNI(dni){
        document.FomInscripciones.DNI.value=dni;
		if(document.FomInscripciones.ID_PRUEBA.value.length<1){
			alert("Debes seleccionar una Prueba");
			return false;
		}else if(document.FomInscripciones.DNI.value.length<1){
			return false;
		}else{
			document.FomInscripciones.submit();
		}
	}

	function enviarFormularioEquipo(){
		if(document.FomInscripciones.ID_PRUEBA.value.length<1){
			alert("Debes seleccionar una Pruebas");
			return false;
		}else{
			document.FomInscripciones.submit();
			return true;
		}
		return true;
	}
	function enviarFormulario1(){
		if(document.FomInscripciones.ID_PRUEBA.value.length<1){
			alert("Debes seleccionar una Prueba");
			return false;
		}else{
				document.getElementById('dd').style.visibility='hidden';
				document.getElementById('divdni').style.visibility='visible';
				document.FomInscripciones.DNI.focus();
		}
	}
 

	function enviarListado(){
		if(document.FomListado.ID_PRUEBA.value.length<1){
			alert("Debe seleccionar una Prueba");
			return false;	
		}else{
			document.FomListado.submit();
		}
	}

/*
*
*	VALIDACIONES DEL FORMULARIO DE INSCRIPCION
*
*
*/

	function obligatorios(formulario){
		campos_obligatorios= new Array();
		campos_obligatorios[0]=formulario.CATEGORIA;
		campos_obligatorios[1]=formulario.APELLIDO_1;
		campos_obligatorios[2]=formulario.APELLIDO_2;
		campos_obligatorios[3]=formulario.NOMBRE;
		campos_obligatorios[4]=formulario.NUMERO_LICENCIA;
		campos_obligatorios[5]=formulario.EMAIL;					campos_obligatorios[6]=formulario.CODIGO_UCI;
		campos_obligatorios[7]=formulario.CLUB_EQUIPO;
		campos_obligatorios[8]=formulario.DIRECCION;
		campos_obligatorios[9]=formulario.POBLACION;
		campos_obligatorios[10]=formulario.PROVINCIA;
		campos_obligatorios[11]=formulario.COD_POSTAL;
		campos_obligatorios[12]=formulario.TELEFONO;


			for(i=0;i<campos_obligatorios.length;i++){
				//comprobamos que no venga vacio
               // alert(campos_obligatorios[i].value);
				campo=trim(campos_obligatorios[i].value);
				if(campo.length<1){
					alert("El campo " + campos_obligatorios[i].name.replace('_',' ') + " es obligatorio.");
					capasObligatorios(campos_obligatorios[i].name);

					//Para los campos CODIGO_UCI y FECHA_NACIMIENTO hay que mover el foco al combo de fecha
					if(campos_obligatorios[i].name=='CODIGO_UCI'){
						formulario.ANIO.focus();
					}else if(campos_obligatorios[i].name=='FECHA_NACIMIENTO'){
						formulario.ANIOLUD.focus();
					}else{
						campos_obligatorios[i].focus();
					}
					return false;
				}//if campo.length
				//PARA CONTROLAR QUE SELECCIONA LOS 3 COMBOS
				if(campos_obligatorios[i].name=='CODIGO_UCI' && campo.length<11){
					alert("El campo CODIGO UCI es obligatorio");
					capasObligatorios('CODIGO_UCI');
					formulario.ANIO.focus();
					return false;
				}else if(campos_obligatorios[i].name=='FECHA_NACIMIENTO' && campo.length<8){
					alert("El campo FECHA NACIMIENTO es obligatorio");
					capasObligatorios('FECHA_NACIMIENTO');
					formulario.ANIOLUD.focus();
					return false;
				}
				
			}//for

			return true;
	}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

/*
* Muestra los datos del formulario en una capa copiados
*/
	function mostrarDatosConf(){
		formulario = document.form_inscripcion;
		document.getElementById("cat").innerHTML=formulario.CATEGORIA.value;
		document.getElementById("ap1").innerHTML=formulario.APELLIDO_1.value;
		document.getElementById("ap2").innerHTML=formulario.APELLIDO_2.value;
		document.getElementById("nom").innerHTML=formulario.NOMBRE.value;
		document.getElementById("lci").innerHTML=formulario.NUMERO_LICENCIA.value;
		document.getElementById("ucis").innerHTML=formulario.CODIGO_UCI.value;
		document.getElementById("clu").innerHTML=formulario.CLUB_EQUIPO.value;
		document.getElementById("ldi").innerHTML=getCheckedValue(formulario.LICENCIA_DIA);
		document.getElementById("mye").innerHTML=getCheckedValue(formulario.MAYOR_EDAD);
		document.getElementById("nac").innerHTML=formulario.NACIONALIDAD.value;
		document.getElementById("fec").innerHTML=formulario.FECHA_NACIMIENTO.value;
		document.getElementById("dir").innerHTML=formulario.DIRECCION.value;
		document.getElementById("pob").innerHTML=formulario.POBLACION.value;
		document.getElementById("pro").innerHTML=formulario.PROVINCIA.value;
		document.getElementById("cpo").innerHTML=formulario.COD_POSTAL.value;
		document.getElementById("tfn").innerHTML=formulario.TELEFONO.value;
		document.getElementById("ema").innerHTML=formulario.EMAIL.value;
	
	}
/*
* Habilita/Deshabilita la fecha de nacimiento
* en función del valor seleccionado en el campo LICENCIA_DIA.
*
*/
	function licenciaDiaBAK(valor)
	{
		formulario = document.form_inscripcion;
		if(valor.value=="SI"){
			//formulario.FECHA_NACIMIENTO.disabled=false;
			formulario.ANIOLUD.focus();//ES EL PRIMER COMBO (el año)
			//formulario.CODIGO_UCI.value="";
			//formulario.CODIGO_UCI.readOnly=true;
			formulario.CODIGO_UCI.disabled=true;
			formulario.FECHA_NACIMIENTO.disabled=false;
			formulario.CLUB_EQUIPO.disabled=true;
		}else if(valor.value=="NO"){
			formulario.FECHA_NACIMIENTO.value="";
			formulario.FECHA_NACIMIENTO.disabled=true;
			formulario.CODIGO_UCI.disabled=false;
			formulario.CODIGO_UCI.readOnly=false;
			formulario.CLUB_EQUIPO.disabled=false;
			//formulario.CLUB_EQUIPO.value="";
		}

	}

	function licenciaDia(valor)
	{
		formulario = document.form_inscripcion;
		if(valor.value=="SI"){
			//formulario.FECHA_NACIMIENTO.disabled=false;
			formulario.ANIOLUD.disabled=false;
			formulario.FECHA_NACIMIENTO.disabled=false;
			formulario.CLUB_EQUIPO.disabled=true;
			formulario.MESLUD.disabled=false;
			formulario.DIALUD.disabled=false;
			formulario.MAYOR_EDAD[0].disabled=false;
			formulario.MAYOR_EDAD[1].disabled=false;
			formulario.NACIONALIDAD.disabled=false;
			formulario.ANIOLUD.focus();//ES EL PRIMER COMBO (el año)
			//formulario.CODIGO_UCI.value="";
			//formulario.CODIGO_UCI.readOnly=true;
			formulario.CODIGO_UCI.disabled=true;
			formulario.FECHA_NACIMIENTO.disabled=false;


		}else if(valor.value=="NO"){
			formulario.ANIOLUD.disabled=true;
			formulario.MESLUD.disabled=true;
			formulario.DIALUD.disabled=true;
			formulario.MAYOR_EDAD[0].disabled=true;
			formulario.MAYOR_EDAD[1].disabled=true;
			formulario.NACIONALIDAD.disabled=true;

			formulario.FECHA_NACIMIENTO.value="";
			formulario.FECHA_NACIMIENTO.disabled=true;
			formulario.CODIGO_UCI.disabled=false;
			formulario.CODIGO_UCI.readOnly=false;
			formulario.CLUB_EQUIPO.disabled=false;
			//formulario.CLUB_EQUIPO.value="";
		}

	}
/*
* Esta función, envía definitivamente el formulario de inscripción.
*/
	function envioFormulario(){

		formulario=document.form_inscripcion;

		if(obligatorios(formulario)){
			formulario.submit();
		}
	}

	//OCULTA TODAS LAS CAPAS EXCEPTO LA PRIMERA DE DATOS DEPORTIVOS
	function inicio(){
        document.getElementById('fin').style.visibility='hidden';
        document.getElementById('fin').style.display='none';
		document.getElementById('lud').style.visibility='hidden';
        document.getElementById('lud').style.display='none';
		document.getElementById('dv').style.visibility='hidden';
        document.getElementById('dv').style.display='none';
		document.getElementById('conf').style.visibility='hidden';
        document.getElementById('conf').style.display='none';
	}
	function mostrar (capa)
	{

		switch (capa) {
			case "dd":
				document.getElementById('dd').style.visibility='visible';
                document.getElementById('dd').style.display='block';
				document.getElementById('lud').style.visibility='hidden';
				document.getElementById('dv').style.visibility='hidden';
				document.getElementById('fin').style.visibility='hidden';
				document.getElementById('conf').style.visibility='hidden';
				break
			case "lud":
				document.getElementById('dd').style.visibility='hidden';
				document.getElementById('lud').style.visibility='visible';
                document.getElementById('lud').style.display='block';
				document.getElementById('dv').style.visibility='hidden';
				document.getElementById('fin').style.visibility='hidden';
				document.getElementById('conf').style.visibility='hidden';
			   break
			case "dv":
				document.getElementById('dd').style.visibility='hidden';
				document.getElementById('lud').style.visibility='hidden';
				document.getElementById('dv').style.visibility='visible';
                document.getElementById('dv').style.display='block';
				document.getElementById('fin').style.visibility='hidden';
				document.getElementById('conf').style.visibility='hidden';
			   break
			case "fin":
				document.getElementById('dd').style.visibility='hidden';
				document.getElementById('lud').style.visibility='hidden';
				document.getElementById('dv').style.visibility='hidden';
				document.getElementById('fin').style.visibility='visible';
                document.getElementById('fin').style.display='block';
				document.getElementById('conf').style.visibility='hidden';
			   break
			case "conf":
				document.getElementById('dd').style.visibility='hidden';
				document.getElementById('lud').style.visibility='hidden';
				document.getElementById('dv').style.visibility='hidden';
				document.getElementById('fin').style.visibility='hidden';
				document.getElementById('conf').style.visibility='visible';
                document.getElementById('conf').style.display='block';
			   break
			default:
				document.getElementById('dd').style.visibility='visible';
                document.getElementById('dd').style.display='block';
				document.getElementById('lud').style.visibility='hidden';
                document.getElementById('lud').style.display='none';
				document.getElementById('dv').style.visibility='hidden';
                document.getElementById('dv').style.display='none';
				document.getElementById('fin').style.visibility='hidden';
                document.getElementById('fin').style.display='none';
				document.getElementById('conf').style.visibility='hidden';
                document.getElementById('conf').style.display='none';
}

	}

/*
* Se ocupa de hacer visible la capa que contiene
* el campo obligatorio sin rellenar por el usuario.
* Es llamado desde la function obligatorios(formulario)
*/
	function capasObligatorios(campo){
		switch(campo)
			{
				case "FECHA_NACIMIENTO":
					mostrar ('lud');
					break
				case "NACIONALIDAD":
					mostrar('lud');
					break
				case "DIRECCION":
					mostrar('dv');
					break
				case "POBLACION":
					mostrar('dv');
					break
				case "PROVINCIA":
					mostrar('dv');
					break
				case "COD_POSTAL":
					mostrar('dv');
					break
				case "TELEFONO":
					mostrar('dv');
					break
				case "EMAIL":
					mostrar('dv');
					break
				default:
					mostrar ('dd');
					
			}
	}
/* Estas 3 funciones son para eliminar espacios (ltrim,rtrim,trim)
* Hay que llamar a trim
*/
	function ltrim(s) {
		return s.replace(/^\s+/, ""); 
		}  
	function rtrim(s) {
		return s.replace(/\s+$/, ""); 
		}  
	function trim(s) {
		return rtrim(ltrim(s));
		}

/*
*
* PARA LA IMPRESION DE LA LICENCIA DE  UN DIA
*
*/
	function imprimirLicencia(){
		document.getElementById('ALERTA').style.visibility='hidden';
		self.print();
	}
	function guardarLicencia(){
		document.getElementById('ALERTA').style.visibility='hidden';
		//alert('guardar');
		//doSaveAs();
	}
	function inicioLicencia(){
		isReady=true;
		document.getElementById('ALERTA').style.visibility='visible';
	}

var isReady = false;

function doSaveAs(){
	if (document.execCommand){
	if (isReady){document.execCommand("SaveAs",false, "LICENCIA DE UN DIA.htm");}
	}else{
	alert('Esta opcion solo funciona con Internet Exlorer 4.0 o posteriores.');
	}
}

