// INICIO Funciones de visualización
function getSelectedRadio(buttonGroup) 
	{
     if (buttonGroup[0]) 
		 { 
          for (var i=0; i<buttonGroup.length; i++) 
			  {
               if (buttonGroup[i].checked) { return i }
              }
		 } 
	 else { if (buttonGroup.checked) { return 0; } }
     return -1;
	} 

function getSelectedRadioValue(buttonGroup) 
	{
     var i = getSelectedRadio(buttonGroup);
     if (i == -1) { return 0; } 
	 else {
		   if (buttonGroup[i]) 
			 { 
			  return buttonGroup[i].value;
			 } 
		   else { return buttonGroup.value; }
		  }
	}
// FIN Funciones de visualización


function display_date(ididioma)
  {
   date = new Date();
   var day_of_week_number = date.getDay();
   var day_of_month = date.getDate();
   var month_number = date.getMonth();
   var year = date.getYear();
   if(year < 1900) year += 1900;
   var day_of_week = '';
   var month = ''
		
	 if(ididioma==1)
	 {
	   if(month_number == 0){month = ' de Enero';}
	   if(month_number == 1){month = ' de Febrero';}
	   if(month_number == 2){month = ' de Marzo';}
	   if(month_number == 3){month = ' de Abril';}
	   if(month_number == 4){month = ' de Mayo';} 
	   if(month_number == 5){month = ' de Junio';}
	   if(month_number == 6){month = ' de Julio';}
	   if(month_number == 7){month = ' de Agosto';}
	   if(month_number == 8){month = ' de Septiembre';}
	   if(month_number == 9){month = ' de Octubre';}
	   if(month_number == 10){month = ' de Noviembre';}
	   if(month_number == 11){month = ' de Diciembre';}
	   if(day_of_week_number == 0){day_of_week = 'Domingo';}
	   if(day_of_week_number == 1){day_of_week = 'Lunes';}
	   if(day_of_week_number == 2){day_of_week = 'Martes';}
	   if(day_of_week_number == 3){day_of_week = 'Miércoles';}
	   if(day_of_week_number == 4){day_of_week = 'Jueves';}
	   if(day_of_week_number == 5){day_of_week = 'Viernes';}
	   if(day_of_week_number == 6){day_of_week = 'Sábado';}
	   var date_to_show = day_of_week + ', ' + day_of_month + '<br>' + month + ' del ' + year; 
	 }
	 if(ididioma==2)
	 {
	   if(month_number == 0){month = ' de Gener';}
	   if(month_number == 1){month = ' de Febrer';}
	   if(month_number == 2){month = ' de Març';}
	   if(month_number == 3){month = ' d´Abril';}
	   if(month_number == 4){month = ' de Maig';} 
	   if(month_number == 5){month = ' de Juny';}
	   if(month_number == 6){month = ' de Juliol';}
	   if(month_number == 7){month = ' d´Agost';}
	   if(month_number == 8){month = ' de Setembre';}
	   if(month_number == 9){month = ' d´Octubre';}
	   if(month_number == 10){month = ' de Novembre';}
	   if(month_number == 11){month = ' de Decembre';}
	   if(day_of_week_number == 0){day_of_week = 'Diumenge';}
	   if(day_of_week_number == 1){day_of_week = 'Dilluns';}
	   if(day_of_week_number == 2){day_of_week = 'Dimarts';}
	   if(day_of_week_number == 3){day_of_week = 'Dimecres';}
	   if(day_of_week_number == 4){day_of_week = 'Dijous';}
	   if(day_of_week_number == 5){day_of_week = 'Divendres';}
	   if(day_of_week_number == 6){day_of_week = 'Dissabte';}
	   var date_to_show = day_of_week + ', ' + day_of_month + '<br>' + month + ' del ' + year; 
	 }
	 if(ididioma==3)
	 {
	   if(month_number == 0){month = ' January';}
	   if(month_number == 1){month = ' February';}
	   if(month_number == 2){month = ' March';}
	   if(month_number == 3){month = ' April';}
	   if(month_number == 4){month = ' May';} 
	   if(month_number == 5){month = ' June';}
	   if(month_number == 6){month = ' July';}
	   if(month_number == 7){month = ' August';}
	   if(month_number == 8){month = ' September';}
	   if(month_number == 9){month = ' October';}
	   if(month_number == 10){month = ' November';}
	   if(month_number == 11){month = ' December';}
	   if(day_of_week_number == 0){day_of_week = 'Sunday';}
	   if(day_of_week_number == 1){day_of_week = 'Monday';}
	   if(day_of_week_number == 2){day_of_week = 'Tuesday';}
	   if(day_of_week_number == 3){day_of_week = 'Wednesday';}
	   if(day_of_week_number == 4){day_of_week = 'Thursday';}
	   if(day_of_week_number == 5){day_of_week = 'Friday';}
	   if(day_of_week_number == 6){day_of_week = 'Saturday';}
	   var date_to_show = day_of_week + ', ' + day_of_month + '<br>' + month + ' of ' + year; 
	 }

   document.write('<font size="1" face="arial">' + date_to_show.fontcolor("#FFFFFF") + '</font>');
  } 

function LTrim(s) // Devuelve una cadena sin los espacios del principio
	{
	var i= 0;
	var j= 0;
	for(i= 0; i<=s.length-1; i++) // Busca el primer caracter <> de un espacio
		if(s.substring(i, i+1) != ' '){
			j= i;
			break;
		}
	return s.substring(j, s.length);
	}

function RTrim(s) // Quita los espacios en blanco del final de la cadena
	{
	var j= 0;
	for(var i=s.length-1; i>-1; i--) // Busca el último caracter <> de un espacio
		if(s.substring(i, i+1) != ' '){
			j= i;
			break;
		}
	return s.substring(0, j+1);
	}

function Trim(s) // Quita los espacios del principio y del final
	{
	return LTrim(RTrim(s));
	}

function NoComillaSimple()
	{
	 var isNS4 = (navigator.appName=="Netscape")?1:0;

     if(!isNS4)
		 {
		  if (event.keyCode==39) event.returnValue = false;
		 }
	 else {
		   if (event.which==39) return false;
		  }
	}

function SoloNumeros()
	{
	 var isNS4 = (navigator.appName=="Netscape")?1:0;

     if(!isNS4)
		 {
		  if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;
		 }
	 else {
		   if (event.which < 48 || event.which > 57) return false;
		  }
	}

function SoloFechas()
	{
	 var isNS4 = (navigator.appName=="Netscape")?1:0;

     if(!isNS4)
		 {
		  if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode != 47)) event.returnValue = false;
		 }
	 else {
		   if ((event.which < 48 || event.which > 57) && (event.which != 47)) return false;
		  }
	}


function AfegirItem(a,b,c)
{
  MarcarTodosItems(c); //selecciono todos los items de la caja

  var repetido = false;
  for (i=0; i<c.length; i++ )	
	{
	 if (a == c.options[i].value) 
	 {
	  repetido = true;
	  break;
	 }
	}

	if ((a != "") && (!repetido))
	    {
	      texte = b.options[b.selectedIndex].text;		
		  valor = a;
    	  newOpt = new Option(texte, valor);
		  c.add(newOpt, c.length);
		  b.remove(b.selectedIndex);		
    }
    else {
		if (!repetido)
		{
    	 alert("No hi ha item per agregar");
		 b.focus();
		}
    }

  DesMarcarTodosItems(c)
}

function MarcarTodosItems(c)
{
	for (i=0; i<c.length; i++ )	//selecciono todos los items de la caja
	{
		c.options[i].selected = true;
	}
}

function DesMarcarTodosItems(c)
{
	for (i=0; i<c.length; i++ )	//selecciono todos los items de la caja
	{
		c.options[i].selected = false;
	}
}

function TreureItem(a,b,c) 
{
    if (c.selectedIndex!=-1) 
    {
		valor= c[c.selectedIndex].value;
		texte= c[c.selectedIndex].text;
		newOpt= new Option(texte, valor);
		b.add(newOpt, b.length);
		c.remove(c.selectedIndex);
	}
	else
	{
		alert("No s'ha seleccionat cap registre de la llista");
		c.focus();
	}	
}

function TreureTotItem(c) //borro todos los items
{
    MarcarTodosItems(c);
	for (i = c.length - 1; i>=0; i--)	
	{
		c.remove(i);
	}
}

function validaEmail(email)
	{
	  if (Trim(email) == '') 	
		  { 
		    return false; 
		  }
      else if (email.indexOf("@") != -1)
				  {
					dominio=email.substring(email.indexOf("@")+1,email.length)
					if (dominio.indexOf(".") == -1 || email.lastIndexOf(".") == email.length-1)
						{
						  return false;
						}
				  }
				else if (email.length != 0  && email.indexOf("@") == -1)
					  {
						return false;
					  }
	  return true;
	}

function validaFitxerPDF(fitxer)
	{

	 if (fitxer.indexOf("'") != -1)
		{	
		 alert("El nom del fitxer no pot contenir el caràcter apòstrof (')");	
		 return false;
		}

	 var punto = 0;
	 for (var i = 0; i < fitxer.length; i++)
		{
		 var car = fitxer.charAt (i);
		 if (car == '.') 
			{
			 punto ++;
			 if (punto == 2)
				{
				 alert("El nom del fitxer no pot contenir el caràcter '.' dues vegades");
				 return false;
				}
			}
		}

	 if ((fitxer.indexOf(".pdf") == -1) && (fitxer.indexOf(".PDF") == -1))
		{				
		 alert("L´extensío del fitxer te que ser 'pdf'");	
		 return false;
		}

	  if (fitxer.length > 100)
	  {
	   alert("El nom del fitxe és massa llarg");	
	   return false;
	  }	

	  return true;
	}

function fecha_valida(a) 
{
	 if (a.length != 10) return -1;
	 for(var i=0;i<a.length;i++) 
	  {
		if (i==2 || i==5) {	if (a.charAt(i) != '/')  return -1; }
		else { if (a.charAt(i) < '0' || a.charAt(i)>'9')  return -1; }
	  }

	 var dd = parseInt(a.charAt(0) + a.charAt(1), 10);
	 var mm = parseInt(a.charAt(3) + a.charAt(4), 10);
	 var any = parseInt(a.charAt(6) + a.charAt(7) + a.charAt(8) + a.charAt(9));

	 // el día debe ser menor que 31 y el mes menor que 12
	 if (dd<1 || dd>31) return -2;
	 if (mm<1 || mm>12) return -3;

	 if ((mm > 12) || (dd > 31)) return -4
	 else
	 {
		if (((mm == 01) || (mm == 03) || (mm == 05) || (mm == 07) || (mm == 08) || (mm == 10) || (mm == 12)) && (dd > 31)) return -4
		else
		{
				if (((mm == 04) || (mm == 06) || (mm == 09) || (mm == 11)) && (dd > 30)) return -4
				else
				{
				 if ((mm == 02))
				 {
					if (dd > 29) return -4
					else
					{
						resto = any % 4
						if ((resto != 0) && (dd > 28)) return -4
						else
						{
							resto = any / 100;
							if ((resto == 0) && (dd > 28)) return -4
						}
					}
				 }
				} 
		 }
	 }
	 return 1;
}

formatoEuro = function( n ) 
	{
	if (n == undefined)
	{
	 return '';
	}
	else {
	var d = ","; var t = "."; var c = 2; 
	var m = ( c = Math.abs( c ) + 1 ? c : 2, d = d || ",", t = t || ".", /(\d+)(?:(\.\d+)|)/.exec( n + "" ) ), x = m[1].length % 3;
	var resultado = ( x ? m[1].substr( 0, x ) + t : "" ) + m[1].substr( x ).replace( /(\d{3})(?=\d)/g, "$1" + t ) + ( c ? d + ( +m[2] ).toFixed( c ).substr( 2 ) : "" ); 
	return resultado.replace(".,", ",") + " €"
		}
	};

function desconectar()
	{
	document.fDatosDes.submit();
	}

///////////////////////////////////////////// MANTENIMENTS ////////////////////////////////////////////////////////////////////////////////////

function comprueba_noticiasubscripcio()
	{
	var fmForm = document.fDatos;

    var nom = Trim(fmForm.nom.value);
		if (nom.length == 0)
		{
			alert ("El camp 'Nom' està buit");
			return false;
		}

    var mail = Trim(fmForm.mail.value);
	   if (!validaEmail(mail))
	   {
		alert ("E-Mail mal escrit");
		return false;
	   }

	return true
	}

function comprueba_areaclub()
	{
	var fmForm = document.fDatos;

    var password1 = Trim(fmForm.password1.value);
		if (password1.length == 0)
		{
			alert ("El Password està buit");
			return false;
		}

    var codi = Trim(fmForm.codi.value);
		if (codi.length == 0)
		{
			alert ("Al Codi està buit");
			return false;
		}

	return true
	}

function comprueba_areallicencies()
	{
	var fmForm = document.fDatosForm;

    var password1 = Trim(fmForm.clave.value);
		if (password1.length == 0)
		{
			alert ("El Password està buit");
			return false;
		}

    var dni = Trim(fmForm.usuario.value);
		if (dni.length == 0)
		{
			alert ("El DNI està buit");
			return false;
		}

	return true
	}

function comprueba_provaPuntuableRP()
	{
	var fmForm = document.fDatos;
	var repetido = false;

	if (fmForm.FederatM1Id.value.length == 0) { fmForm.FederatM1Id.value = 0; } 
	if (fmForm.FederatM2Id.value.length == 0) { fmForm.FederatM2Id.value = 0; } 
	if (fmForm.FederatM3Id.value.length == 0) { fmForm.FederatM3Id.value = 0; } 
	if (fmForm.FederatDirectorId.value.length == 0) { fmForm.FederatDirectorId.value = 0; } 
	if (fmForm.FederatComisariId.value.length == 0) { fmForm.FederatComisariId.value = 0; } 
	if (fmForm.FederatCronometradorId.value.length == 0) { fmForm.FederatCronometradorId.value = 0; } 

	repetidos = new Array(fmForm.FederatM1Id.value, fmForm.FederatM2Id.value, fmForm.FederatM3Id.value, fmForm.FederatDirectorId.value, fmForm.FederatComisariId.value, fmForm.FederatCronometradorId.value);
	numero = 0;
	for (i=0; i<repetidos.length; i++ )	
	  {
	    for (j=0; j<repetidos.length; j++ )	
	      {
		   if (repetidos[i] == repetidos[j]) { numero++; }
	      }
       	if ((numero > 1) && (repetidos[i] != 0)) { repetido = true }
		numero = 0;
	  }

	if (repetido)
	 {
 	  alert ("No hi poden haver persones repetides al jurat");
	  return false;
	 }

    var email = Trim(fmForm.mail.value);
		if (email != '')
		  {
		   if (!validaEmail(email))
		   {
			alert ("E-Mail mal escrit");
			return false;
		   }
		  }

	if (fmForm.FitxerInf.value.length != 0) { fmForm.arxiuInf.value = 1; } 
	if (fmForm.FitxerMap.value.length != 0) { fmForm.arxiuMapa.value = 1; } 

	return true;
	}

function comprueba_provaPuntuableAJ()
	{
	var fmForm = document.fDatos;
	var repetido = false;

	if (fmForm.FederatM1Id.value.length == 0) { fmForm.FederatM1Id.value = 0; } 
	if (fmForm.FederatM2Id.value.length == 0) { fmForm.FederatM2Id.value = 0; } 
	if (fmForm.FederatM3Id.value.length == 0) { fmForm.FederatM3Id.value = 0; } 
	if (fmForm.FederatDirectorId.value.length == 0) { fmForm.FederatDirectorId.value = 0; } 
	if (fmForm.FederatComisariId.value.length == 0) { fmForm.FederatComisariId.value = 0; } 
	if (fmForm.FederatCronometradorId.value.length == 0) { fmForm.FederatCronometradorId.value = 0; } 

	repetidos = new Array(fmForm.FederatM1Id.value, fmForm.FederatM2Id.value, fmForm.FederatM3Id.value, fmForm.FederatDirectorId.value, fmForm.FederatComisariId.value, fmForm.FederatCronometradorId.value);
	numero = 0;
	for (i=0; i<repetidos.length; i++ )	
	  {
	    for (j=0; j<repetidos.length; j++ )	
	      {
		   if (repetidos[i] == repetidos[j]) { numero++; }
	      }
       	if ((numero > 1) && (repetidos[i] != 0)) { repetido = true }
		numero = 0;
	  }

	if (repetido)
	 {
 	  alert ("No hi poden haver persones repetides al jurat");
	  return false;
	 }

    if (fmForm.TemesSele != undefined)
    {
	MarcarTodosItems(fmForm.TemesSele);
	var c = fmForm.TemesSele 
	for (i=0; i<c.length; i++ )	
		{
		 if (i == c.length-1) fmForm.ListaPilotsAccident.value = fmForm.ListaPilotsAccident.value + c.options[i].value
		   else fmForm.ListaPilotsAccident.value = fmForm.ListaPilotsAccident.value + c.options[i].value + ', ';
		}
	}

	return true;
	}

function Comprueba_LlicenciaAnomalia()
	{
	var fmForm = document.fDatos;

    var anomalia = Trim(fmForm.anomalia.value);
		if (anomalia.length == 0)
		{
			alert ("El camp Anomalia està buit");
			return false;
		}
	return true
	}

function comprueba_federatweb()
	{
	var fmForm = document.fDatosFederat;

    var nom = Trim(fmForm.nom.value);
		if (nom.length == 0)
		{
			alert ("El camp 'Nom' està buit");
			return false;
		}

    var cognom1 = Trim(fmForm.cognom1.value);
		if (cognom1.length == 0)
		{
			alert ("El camp '1er Cognom' està buit");
			return false;
		}

	var result2 = fecha_valida(fmForm.f_naixament.value);
		if (result2==-1) 
			{
			alert ("Les dates no tenen format DD/MM/AAAA");
			return false;
			}
		if (result2==-2) 
			{
			alert ("En el format data el dia (DD) ha de ser menor que 31");
			return false;
			}
		if (result2==-3) 
			{
			alert ("En el format data el mes (MM) ha de ser menor que 12");
			return false;
			}
		if (result2==-4) 
			{
			alert ("Format de data incorrecte");
			return false;
			}

    var via = Trim(fmForm.via.options[fmForm.via.selectedIndex].value);
		if (via == 0)
		{
			alert ("El camp 'Tipus Via' està buit");
			return false;
		}

    var adreca = Trim(fmForm.adreca.value);
		if (adreca.length == 0)
		{
			alert ("El camp 'Via' està buit");
			return false;
		}

	if (fmForm.poblacioL.selectedIndex == -1)
		{
			alert ("No s'ha seleccionat cap població");
			return false;
		}

    var poblacio = Trim(fmForm.poblacioL.options[fmForm.poblacioL.selectedIndex].value);
		if (poblacio == 0)
		{
			alert ("El federat no pot ser fora de Catalunya");
			return false;
		}

    var email = Trim(fmForm.email.value);
	   if (!validaEmail(email))
	   {
		alert ("E-Mail mal escrit");
		return false;
	   }

    var tutor = Trim(fmForm.tutor.value);
    var tutorDNI = Trim(fmForm.tutorDNI.value);
 	  if ((tutor != '') && (tutorDNI == ''))
 	    {
		 alert ("El camp 'DNI Tutor' està buit");
	 	 return false;
	    }

    var dni = Trim(fmForm.dni.value);
 	  if ((tutorDNI == '') && (dni == ''))
 	    {
		 alert ("El camp 'DNI' està buit");
	 	 return false;
	    }

    var telefon = Trim(fmForm.telefon.value);
    var mobil = Trim(fmForm.mobil.value);
 	  if ((mobil == '') && (telefon == ''))
 	    {
		 alert ("El mòbil i telèfon estàn buits, omple un");
	 	 return false;
	    }

    var password1 = Trim(fmForm.password1.value);
    var password2 = Trim(fmForm.password2.value);
	if (password1.length == 0)
		{
		 alert ("Les contrasenyas estàn buides");
		 return false;
		}

	if ((password1 != '') || (password2 != ''))
	{
	   if (password1 != password2)
	   {
		alert ("Les contrasenyas no son iguals");
		return false;
	   }
	}

	return true
	}

function comprueba_inscripcioweb()
	{
	var fmForm = document.fDatosInscripcio;

    var proves = fmForm.proves.options[fmForm.proves.selectedIndex].value;
		if (proves == 0)
		{
			alert ("El camp 'Proves' està buit");
			return false;
		}

    var categoria = fmForm.categoria.selectedIndex;
		if (categoria == -1)
		{
			alert ("El camp 'Categoria' està buida");
			return false;
		}

    fmForm.Ds_Merchant_ProductDescription.value = fmForm.proves.options[fmForm.proves.selectedIndex].text;
    fmForm.NomCategoria.value = fmForm.categoria.options[fmForm.categoria.selectedIndex].text;
    fmForm.NomMarca.value = fmForm.marca.options[fmForm.marca.selectedIndex].text;

	return true
	}

function comprueba_inscripciocampionatweb()
	{
	var fmForm = document.fDatosInscripcio;

    var proves = fmForm.proves.options[fmForm.proves.selectedIndex].value;
		if (proves == 0)
		{
			alert ("El camp 'Campionat' està buit");
			return false;
		}
    var categoria = fmForm.categoria.selectedIndex;
		if (categoria == -1)
		{
			alert ("El camp 'Categoria' està buida");
			return false;
		}
    var categoria = fmForm.categoria.options[fmForm.categoria.selectedIndex].value;
		if (categoria == 0)
		{
			alert ("El camp 'Categoria' està buida");
			return false;
		}
//    var dorsals = fmForm.dorsals.options[fmForm.dorsals.selectedIndex].value;
//		if (dorsals == 0)
//		{
//			alert ("El camp 'Dorsals' està buit");
//			return false;
//		}
    fmForm.Ds_Merchant_ProductDescription.value = fmForm.proves.options[fmForm.proves.selectedIndex].text;
    fmForm.NomCategoria.value = fmForm.categoria.options[fmForm.categoria.selectedIndex].text;
    fmForm.NomMarca.value = fmForm.marca.options[fmForm.marca.selectedIndex].text;
    fmForm.NomDorsal.value = fmForm.dorsals.options[fmForm.dorsals.selectedIndex].text;

	return true
	}

function comprueba_contrasenyaclub()
	{
	var fmForm = document.fDatosClubContrasenya;

    var password1 = Trim(fmForm.password1.value);
    var password2 = Trim(fmForm.password2.value);

	if (password1.length == 0)
	{
		alert ("El camp 'Contrasenya' està buit");
		return false;
	}

	if ((password1 != '') || (password2 != ''))
	{
	   if (password1 != password2)
	   {
		alert ("Les contrasenyas no son iguals");
		return false;
	   }
	}

	return true
	}

function comprueba_dorsals()
	{
	var fmForm = document.fDorsalsDatos;

    var especialitat = fmForm.especialitat.options[fmForm.especialitat.selectedIndex].value;
		if (especialitat == 0)
		{
			alert ("El camp 'Especialitat' està buit");
			return false;
		}

    var categoria = fmForm.categoria.selectedIndex;
		if (categoria == -1)
		{
			alert ("El camp 'Categoria' està buida");
			return false;
		}

	return true
	}


function comprueba_inscripcion_campeonato()
	{
	var fmForm = document.fDatosInscripcion;

    var categoria = fmForm.categoria.selectedIndex;
		if (categoria == -1)
		{
			alert ("No hi ha categoria seleccionada");
			return false;
		}

    var categoria = fmForm.categoria.options[fmForm.categoria.selectedIndex].value;
		if (categoria == 0)
		{
			alert ("No hi ha categoria seleccionada");
			return false;
		}

	return true
	}


function comprueba_llicencia()
	{
	var fmForm = document.fDatos;

	var llicencia_categoria = fmForm.llicencia_categoria.options[fmForm.llicencia_categoria.selectedIndex].value;
	if (llicencia_categoria == 0) 
	  {
		alert ("Falta posar la Categoria");
		return false;
	  }

	if (((llicencia_categoria == 108) || (llicencia_categoria == 208) || (llicencia_categoria == 217)) && (fmForm.prova.options[fmForm.prova.selectedIndex].value == 0))
		{
		 alert ("No hi ha cap prova sel·leccionada");
		 return false;
		} 	

	return true
	}

function comprueba_credencial()
	{
	var fmForm = document.fDatosCredencial;

	var llicencia_categoriacredencial = fmForm.llicencia_categoriacredencial.options[fmForm.llicencia_categoriacredencial.selectedIndex].value;
	if (llicencia_categoriacredencial == 0) 
	  {
		alert ("Falta posar el tipus");
		return false;
	  }

	if ((llicencia_categoriacredencial == 252) && ((fmForm.provacredencial.selectedIndex == -1) || (fmForm.provacredencial.options[fmForm.provacredencial.selectedIndex].value == 0)))
		{
		 alert ("No hi ha cap prova sel·leccionada");
		 return false;
		} 	

	return true
	}


function comprueba_inscripcion1()
	{
	var fmForm = document.fDatosInscripcion;

	if (getSelectedRadioValue(fmForm.informacio) == 0) 
		{
		alert ("Escull una licéncia");
		return false;
		}

	if (getSelectedRadioValue(fmForm.tipoinscripcion) == 0) 
		{
		alert ("Escull un tipus d´inscripció");
		return false;
		}

	var especialitat = fmForm.especialitatinscripcion.options[fmForm.especialitatinscripcion.selectedIndex].value;
		if (especialitat == 0)
		{
			alert ("El camp 'Especialitat' està buit");
			return false;
		}

	return true
	}

function comprueba_inscripcion2()
	{
	var fmForm = document.fDatosInscripcion;

    var proves = fmForm.proves.options[fmForm.proves.selectedIndex].value;
		if (proves == 0)
		{
			alert ("No hi ha prova sel·leccionada");
			return false;
		}

    var categoria = fmForm.categoria.selectedIndex;
		if (categoria == -1)
		{
			alert ("No hi ha categoria sel·leccionada");
			return false;
		}

    var categoria = fmForm.categoria.options[fmForm.categoria.selectedIndex].value;
		if (categoria == 0)
		{
			alert ("No hi ha categoria sel·leccionada");
			return false;
		}

	return true
	}

function comprueba_inscripcion_equipo()
	{
	var fmForm = document.fDatosInscripcion;

    var proves = fmForm.proves.options[fmForm.proves.selectedIndex].value;
		if (proves == 0)
		{
			alert ("No hi ha proba sel·leccionada");
			return false;
		}

    var categoria = fmForm.categoria.selectedIndex;
		if (categoria == -1)
		{
			alert ("No hi ha categoria sel·leccionada");
			return false;
		}

    var categoria = fmForm.categoria.options[fmForm.categoria.selectedIndex].value;
		if (categoria == 0)
		{
			alert ("No hi ha categoria sel·leccionada");
			return false;
		}

	if (fmForm.FederatM1Id.value == '0') 
	  { 
	   alert("Falta posar el segon pilot");
	   return false;
	  }
/*
	switch (fmForm.NParticipants.value)
		{
		case '2': { 
					if (fmForm.FederatM1Id.value == '0') 
					  { 
					   alert("Falta poner el Piloto 2");
					   return false;
					  }
					break; 
				  }
		case '3': { 
					if ((fmForm.FederatM1Id.value == '0') || (fmForm.FederatM2Id.value == '0'))
					  { 
					   alert("Falta poner el Piloto 2 o 3");
					   return false;
					  }
					break; 
				  }
		}

*/

	return true
	}
