function validarFormu(pagina) {
  var pais0="ESPAÑA";
    var valor;
	//En caso de registro, verifico el código
	if(pagina=="reg"){
		// Verifico el id máquina
		if(document.getElementById('WLK') && !comprobarLlave(document.getElementById('WLK').value))
		{
		  alert("La llave que ha introducido no es correcta");
			document.getElementById('WLK').focus();
			return false;
				}
	// Verifico el código CD
	     	if(!es_codigoUsuario(document.formu.cd1.value, document.formu.cd2.value, document.formu.cd3.value)){
				valor = document.formu.cd1.value + "-" + document.formu.cd2.value + "-" + document.formu.cd3.value;
				alert(valor + " no es un código de producto correcto");
				document.formu.cd1.focus();
				return false;																		
				}
	}
	
	// Verifico el primer apellido
	if(document.getElementById('ape1') && esVacio(document.getElementById('ape1').value))
	{
		alert("Por favor, introduzca el primer apellido");
		document.getElementById('ape1').focus();
		return false;
	}

	valor=document.getElementById('nombre').value;
	if(esVacio(valor))
	{
		alert("Por favor, introduzca el nombre");
		document.getElementById('nombre').focus();
		return false;
	}
	// Verifico la dirección
	valor=document.getElementById('direccion').value;
	if(esVacio(valor))
	{
		alert("Por favor, introduzca su dirección");
		document.getElementById('direccion').focus();
		return false;
	}

	// Verifico la localidad
	valor=document.getElementById('localidad').value;
	if(esVacio(valor))
	{
		alert("Por favor, introduzca su localidad");
		document.getElementById('localidad').focus();
		return false;
	}
	
	// Verifico la provincia
	valor=document.getElementById('provincia').value;
	if(esVacio(valor))
	{
		alert("Por favor, introduzca su provincia");
		document.getElementById('provincia').focus();
		return false;
	}
	
	/* Verifico que el código postal tenga 5 dígitos entre 01xxx y 52xxx
	valor=document.formu.c_p.value;
	var ind=document.formu.provincia.selectedIndex;
	var numero=document.formu.provincia.options[ind].value;
	if(esVacio(valor))
	{
		alert("Por favor, introduzca su código postal");
		document.formu.c_p.focus();
		return false;
	}
	else if(!es_codigoPostal(valor,numero))
	{
		document.formu.c_p.focus();
		document.formu.c_p.select();
		return false;
	}*/

//Verfico el país
    if (document.getElementById('pais')){
             // Verifico el pais
             valor=document.getElementById('pais').value;
             pais0=valor.toUpperCase();
             //alert("País= "+pais0);
             if(esVacio(valor))
             {
                alert("Por favor, introduzca su país");
                document.getElementById('pais').focus();
                return false;
             }
                    //if (pagina=="demo" && document.formu.profesion.selectedIndex==2){pais(pais0);}
                    //if (pagina=="demo"){pais(pais0);}
    }
		
    // Verifico el teléfono ()
    //if (pagina!="ext" && pagina!="extAct"){
    if (document.getElementById('telefono')){
        valor=document.getElementById('telefono').value;
        if(esVacio(valor)){
             alert("Por favor, introduzca su telefono");
            document.getElementById('telefono').focus();
            return false;
         }
        else if(pais0=="ESPAÑA" && !es_telefono(valor, pais0)){
            document.getElementById('telefono').focus();
            //document.formu.telefono.select();
            return false;
        }
    }
    //}
	
	// Verifico el email, true/false (requerido/no requerido)
	if (!VerificaEMAIL(document.getElementById('email').value, true))
	{
		//document.formu.email.select();
		document.getElementById('email').focus();
		return false;
	}
		
	// Paso el valor del mail
	if (pagina!="act")document.getElementById('e_mail').value=document.getElementById('email').value;

/*	if (pagina=="demo"){
	// Verifico la profesión
	valor=document.formu.profesion.value;
	if(esVacio(valor))
	{
		alert("Por favor, introduzca su profesion");
		document.formu.profesion.focus();
		return false;
	}
	*/	

/*
 if (pagina=="ext" || pagina=="extAct"){
		 valor1=document.formu.titular.value;
		 valor2=document.formu.CreditCardNumber.value;
		 valor3=document.formu.mes.value;
		 valor4=document.formu.ano.value;
		 if(esVacio(valor1)||esVacio(valor2)||esVacio(valor3) || esVacio(valor4))
		 {
		 alert("Por favor, complete todos los datos de la tarjeta");
		 document.formu.titular.focus();
		 return false;
		 }
	}
*/
 if (pagina=="act"){
		 var valor1=document.getElementById('titular').value;
		 if(esVacio(valor1))
		 {
		 alert("Por favor, introduzca el titular de la cuenta");
		 document.getElementById('titular').focus();
		 return false;
		 }

		 var valor2=document.getElementById('CCC-Entidad').value;
		 var valor3=document.getElementById('CCC-Oficina').value;
		 var valor4=document.getElementById('CCC-Dc').value;
		 var valor5=document.getElementById('CCC-Cuenta').value;
                 if(!validarCuenta(valor2, valor3, valor4, valor5)){
                    document.getElementById('CCC-Entidad').focus();
                    return false;
                 }
	}

  var nombre=document.formu.nombre.value+" "+document.formu.ape1.value+" "+document.formu.ape2.value;
  document.formu.realname.value=nombre;
                    //alert(nombre);
  //document.formu.action="scripts/escribe.php";
  //document.formu.submit();
  return true;
}

