function solodigitos2(f,admitidos){
texto=f.value;
for (i=0;i<texto.length;i++){
 if (admitidos.indexOf(texto.charAt(i))==-1){
  alert('Ha escrito un caracter no permitido: "'+texto.charAt(i)+'"');
  f.focus();
  f.select();
  return false;
 }
}
return true;
}

function checksn(f) {
	if(f.checked==false) {
		alert('Es obligatorio aceptar las normas para poder enviar un mensaje.');
  		return false;
	 }		
}

function checkBottom(f,msg) {
	if(f.checked==false) {
		alert(msg);
  		return false;
	 }		
}

function solodigitos(f){
var Numero="abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
texto=f.value;
for (i=0;i<texto.length;i++){
 if (Numero.indexOf(texto.charAt(i))==-1){
  alert('El campo seleccionado sólo acepta números, letras o los signos "-" o "_".\n'+
   'Caracter ilegal "'+texto.charAt(i)+'"');
  f.focus();
  f.select();
  return false;
 }
}
}

function validosOtros(f){
var Numero="¿?¡!@_*+#&$%.()";
texto=f.value;
for (i=0;i<texto.length;i++){
 if (Numero.indexOf(texto.charAt(i))!=-1){
  alert('Caracter ilegal "'+texto.charAt(i)+'"');
  f.focus();
  f.select();
  return false;
 }
}
}

function validaEmail(t){
Val=t.value;
arroba=Val.indexOf("@");
punto=Val.lastIndexOf(".");
if (arroba!=-1 && punto>arroba){ return true;}
else{
 alert('El email que ha escrito no es válido.');
 t.focus();
 t.select();
 return false;
 }
}

function validaEmailTexto(Val){
 arroba=Val.indexOf("@");
 punto=Val.lastIndexOf(".");
 if (arroba!=-1 && punto>arroba){ return true;}
 else{alert('"'+Val+'" no es un email válido.');return false;}
}

function numero(f){
var Numero="1234567890";
texto=f.value;
for (i=0;i<texto.length;i++){
  if (Numero.indexOf(texto.charAt(i))==-1) {
	alert('El campo seleccionado sólo acepta números.');
	f.focus();
	f.select();
	return false;
	}
  }
}

function valor(f,min,max,num){
var s="";
  if (f.value==""){
    if (min>0||max>0){
    s='Rellene el campo seleccionado con un ';
	if (min>0) s+='mínimo de '+min;
	if (min>0 && max>0)s+=' y un ';
	if (max>0) s+='máximo de '+max;
	s+=' caracteres.';
	}
	else{s="Escriba un valor para el campo seleccionado.";}
    alert(s);
    f.focus();
    return (false);
  }
  if (min>0){
  if (f.value.length<min){
    alert("Escriba como mínimo "+min+" caracteres en el campo seleccionado.");
    f.focus();
    return (false);
  }
}
  if (max>0){
  if (f.value.length>max){
    alert("Escriba como máximo "+max+" caracteres en el campo seleccionado.");
    f.focus();
    return (false);
  }
}
return true;
}

function maxEnt(campo,maximo,campoMensaje){
 if (parseInt(campo.value)>maximo){
  alert("No se pueden asignar mas de "+maximo+" "+campoMensaje);
  campo.value=maximo;
  campo.select();
  return false;
 }else{return true;}
}

function VNum(cmp,mn,mx){
 if (!valor(cmp,mn,mx,0)||numero(cmp)==false) return false;
 return true;
}

function validaFecha(f)
{ 
   if (f.value)
   {  
      error = f.value;
      if ((f.value.substr(2,1) == "/") && (f.value.substr(5,1) == "/"))
      {      
         for (i=0; i<10; i++)
	     {	
            if (((f.value.substr(i,1)<"0") || (f.value.substr(i,1)>"9")) && (i != 2) && (i != 5))
			{
               error = '';
               break;  
			}  
         }
	     if (error)
	     { 
	        a = f.value.substr(6,4);
		    m = f.value.substr(3,2);
		    d = f.value.substr(0,2);
		    if((a < 1900) || (a > 2050) || (m < 1) || (m > 12) || (d < 1) || (d > 31))
		       error = '';
		    else
		    {
		       if((a%4 != 0) && (m == 2) && (d > 28))	   
		          error = ''; // Año no bisiesto y es febrero y el dia es mayor a 28
			   else	
			   {
		          if ((((m == 4) || (m == 6) || (m == 9) || (m==11)) && (d>30)) || ((m==2) && (d>29)))
			         error = '';	      				  	 
			   }
		    } 
         }
      } 			    			
	  else
	     error = '';
	  if (error == '') {
	     	alert('Fecha erronea');
			f.focus();
			f.select();
		 	return false;
 	  }
	  else
		return true;
   } 
} 

function validaFechaSup(String1, String2, msg){ 
	Data1_arr = String1.value.split('/');
	Data2_arr = String2.value.split('/');

	String1 = Data1_arr[2] + Data1_arr[1] + Data1_arr[0];
	String2 = Data2_arr[2] + Data2_arr[1] + Data2_arr[0];
	String1 = parseInt(String1);
	String2 = parseInt(String2);
	
	if (String1 >= String2) {
		alert(msg);
		return false;
	}
	return true;

}

