function validarAlta(isUserFacebook) 
   {
 //Comprobaci�n valores del formulario
	
    usuario = document.formulario.usuario.value;
        if(!isUserFacebook) {
                if(document.formulario.clave != null) clave = document.formulario.clave.value;
                if(document.formulario.clave2 != null) clave2 = document.formulario.clave2.value;
        }
	correoe = document.formulario.email.value;
	
	//NO obligado
	edad = document.formulario.fechanaci.value;
// comprueba idioma de inteface
	idiSesiSel = document.formulario.idiSesiSel.value;

    valor = 0;
    txt = mensaGlobal[0][idiLang]
	//ELIMINADO DEBIDO A NUEVO FORM NADIGITAL
	/*chkk=cheIdioKO(idiSesiSel)
    if (chkk != ""){
		  txt = txt+ mensaGlobal[8][idiLang];
		  txt = txt+ mensaGlobal[9][idiLang];
		  txt = txt+ chkk;

		  valor = valor + 1;
		  document.getElementById("idiSesiSelMes").style.borderBottom="thin solid red"

    }*/
   var at, dot, coma, charac;
    at = false;
    if(correoe!="")
    {
        for(i=1;i<(correoe.length-1);i++)
        {
            charac = correoe.substring(i,i+1);
            if(charac=="@"){at = true;}
        }
        if(at)
        {
            for(i=3;i<(correoe.length-1);i++)
            {
                charac=correoe.substring(i,i+1)
                if(charac=="."){dot = true;}
            }
            if(dot){
			      coma = false
			      for(i=1;i<(correoe.length-1);i++)
					{
						charac = correoe.substring(i,i+1);
						if(charac==","){coma = true;}
					}
				if (!coma){	
                   valor = valor + 0;
			       document.getElementById("emaMes").style.borderBottom="thin solid white"
			    }else{
                     txt = txt+ mensaGlobal[1][idiLang];
					 valor = valor + 1;
					 document.getElementById("emaMes").style.borderBottom="thin solid red"
			  
			    }
           }
		   else
            {
                txt = txt+ mensaGlobal[1][idiLang];
                 valor = valor + 1;
				 document.getElementById("emaMes").style.borderBottom="thin solid red"
            }    
        }
        else
        {
                txt = txt+ mensaGlobal[1][idiLang];
                 valor = valor + 1;
				 document.getElementById("emaMes").style.borderBottom="thin solid red"
        }
    }
    else
    {
            txt = txt+'Email \n';
             valor = valor + 1;
			  document.getElementById("emaMes").style.borderBottom="thin solid red"
    }

   // txt = txt+'\n';
    if (usuario){
	    document.getElementById("usuMes").style.borderBottom="thin solid white"
        if (usuario.length < 6){
                txt = txt+ mensaGlobal[2][idiLang];
                  valor = valor + 1;
				  document.getElementById("usuMes").style.borderBottom="thin solid red"
            }
    }else{
         txt = txt+'Nick\n';
          valor = valor + 1;       
		  document.getElementById("usuMes").style.borderBottom="thin solid red";

    }

        if(!isUserFacebook){
                if (clave && clave2){

                        if (clave != clave2){
                                txt = txt+ mensaGlobal[4][idiLang];
                        valor = valor + 1;
		                        document.getElementById("claMes").style.borderBottom="thin solid red"
		                        document.getElementById("cla2Mes").style.borderBottom="thin solid red"
		                        }  
                        else{
                        if (clave.length < 4){
                                txt = txt+ mensaGlobal[3][idiLang];
                                valor = valor + 1;
			                        document.getElementById("claMes").style.borderBottom="thin solid red"
		                        document.getElementById("cla2Mes").style.borderBottom="thin solid red"

                        }else{
                        // Ok pasa a minuscula
                        clave = lower(clave)
                        document.formulario.clave.value = clave
                        document.formulario.clave2.value = clave
		                        document.getElementById("cla2Mes").style.borderBottom="thin solid white"
		                        document.getElementById("claMes").style.borderBottom="thin solid white"

                        }
                        }    
                }else{
                        txt = txt+ mensaGlobal[5][idiLang];
                        valor = valor + 1;       
	                                document.getElementById("claMes").style.borderBottom="thin solid red"
		                        document.getElementById("cla2Mes").style.borderBottom="thin solid red"
                }
        }
    

   if (edad){
        //var fecha = new Date();
        //fecha.setDate(fecha.getDate() - (18* 365));
        //anyolimite = fecha.getYear();
	  //anyolimite calculado en formusuario
		document.getElementById("edaMes").style.borderBottom="thin solid white"
		fechaMala = false
	 // barra
        re = /\//g;
        newEdad=edad.replace(re, "-");
	  // no numerico
	    re2 = /[^0-9]/g;
        newEdad2=newEdad.replace(re2, "-");
        fechaEdad=newEdad2.replace(/\./g, "-");

        puntero = fechaEdad.indexOf("-");
        puntero2 = fechaEdad.indexOf("-", puntero+1);

        dia = parseInt(fechaEdad.substring(0, puntero));
        mes = parseInt(fechaEdad.substring(puntero+1, puntero2));
        anyo = fechaEdad.substring(puntero2+1, fechaEdad.length);
        
        //tempEdad = mes + "-" + dia + "-" + anyo
        //var fechaEdad = new Date(tempEdad);
        if (anyo.length > 2){anyo = anyo - 1900}
        if (anyo < 0 || isNaN(anyo) || anyo > 99){
		     //alert(anyo + " " + anyo.length)
		     fechaMala = true
        }
		
		if (dia < 0 || dia > 31 || dia.length < 1 || isNaN(dia)){
		     fechaMala = true
        }

		if (mes < 0 || mes > 12 || mes.length < 1 || isNaN(mes)){
		     fechaMala = true
        }

        if (fechaMala){
			 document.getElementById("edaMes").style.borderBottom="thin solid red"
   			 txt = txt+ mensaGlobal[6][idiLang];
             valor = valor + 1;       
		}else{
			 document.formulario.fechanaci.value = fechaEdad
		}
       /* if (anyo <= anyolimite){
              //alert(anyolimite + 'OK solicitar el carnet' + anyo);
                valor = valor + 0;
             }
        else{
            txt = txt +'   Debes ser mayor de edad para convertirte en Usuario\n';
            txt = txt +'   Comprueba que has entrado una fecha valida: dd-mm-aa\n';
            txt = txt +'   Ejemplo: 12-1-65\n';
            valor = valor + 1;       
            }        */
   }else {
	      // NO OBLIGATORIO
          // txt = txt+'   Fecha de nacimiento\n';
           //valor = valor + 1;       
   }



if (valor == 0){
    return true;}
else{
     txt = txt+ mensaGlobal[7][idiLang];
    alert(txt)
     return false;
    }   

}

function cheIdioKO(idi){
    ckk=""
	   if (idiValidation[idi] == idi){
	      ckk = ""
	   }else{
	   
			//elemenx = document.getElementById('idiSesiSel').getElementsByTagName("option");
			for (x=0;x<maximosActivos;x++){
			elemenx =document.getElementById("idiSesiSel");
			// elemenx.options[i]
			chkOpt = document.getElementsByTagName("option")[x].value
				if( idiValidation[chkOpt] == chkOpt){
				// literal idiomas disponibles
					ckk = ckk  + "  " + document.getElementsByTagName("option")[x].text + "\n"
				}

			}
	   }
	return ckk

}

function lower(x) { 
x = x.toLowerCase() 
return x
} 
function caps(x) { 
x = x.toUpperCase() 
return x
} 


function LetraNIF (dni) {
/* Obtiene letra del NIF a partir del DNI */

 cadena="TRWAGMYFPDXBNJZSQVHLCKET"
   posicion = dni % 23
   letra = cadena.substring(posicion,posicion+1)
 
//alert(posicion+" " +letra + " " + dni)
return letra;
}

function testFecha(edad){

}


var compa = new Array();
compa[1] = "H"
compa[2] = "M"
var compades = new Array();
compades[1] = "Hombre"
compades[2] = "Mujer"


function definecompael()
{

for(i=0;i<document.formulario.sexoList.length;i++)
    {
        if(document.formulario.sexoList[i].selected)
        {
            document.formulario.sexo.value = compa[i]
            document.formulario.sexoShow.value = compades[i]
        }
    }



}


