function checkPais(val,com)
{
	if ( val == 1 ) document.getElementById(com).style.display = 'block';
	else document.getElementById(com).style.display = 'none';
}
function checkNormas(box,bot)
{
	if ( document.getElementById(box).checked ) document.getElementById(bot).disabled = false;
	else document.getElementById(bot).disabled = true;
}
function checkField(f,n,v)
{
	f = document.getElementById(f);
	if ( f.value.length < v )
	{
		alert('El campo '+n+' debe tener un mínimo de '+v+' caracteres');
		f.focus();
		return false;
	}
	return true;
}
function sonIguales(ca1,ca2,des)
{
	var c1 = document.getElementById(ca1);
	var c2 = document.getElementById(ca2);
	if ( c1.value !== c2.value )
	{
		alert('El campo '+des+' y su confirmación no coinciden');
		c1.focus();
		return false;
	}
	return true;
}
function validarPass(ni,p1,p2)
{
	if ( p1 == ni )
	{
		return "<p>La contraseña no puede ser igual que tu nick.</p>";
	}
	if ( p1.length<6 || p1.length>12 )
	{
		return "<p>Introduce una contraseña que tenga entre 6 y 12 caracteres</p>";
	}
	if ( p1 != p2 )
	{
		return "<p>La contraseña y su confirmación no coinciden.</p>";
	}
	return true;
}
function validarRegistro()
{
	var formu=document.getElementById("formuRegistro");
	var nick = document.getElementById("nuevoNick").value;
	var email = document.getElementById("nuevoEmail1").value;
	var email2 = document.getElementById("nuevoEmail2").value;
	var fecha = document.getElementById("nuevoFechaNacimiento").value;
	var fechaOk;
	var nombre = document.getElementById("nuevoNombre").value;
	var pais = document.getElementById("nuevoPais").value;
	var localidad = document.getElementById("nuevoLocalidad").value;
	var pass1 = document.getElementById("nuevoPass1").value;
	var pass2 = document.getElementById("nuevoPass2").value;
	var error="";
	var nickValidation = validarNick(nick);
	if ( nickValidation != true )
	{
		error += nickValidation;
	}
	var validarPassRes = validarPass(nick,pass1,pass2);
	if ( validarPassRes != true )
	{
		error += validarPassRes;
	}
	if ( validarEmail2(email) != true )
	{
		error += '<p>El email '+email+' no es válido.</p>';
	}
	if ( validarEmail2(email2) != true )
	{
		error += '<p>El email de confirmación, '+email2+', no es válido.</p>';
	}
	if ( email != email2 )
	{
		error += '<p>El email y su confirmación no coinciden.</p>';
	}
	fechaOk = validarFecha2(fecha,'/');
	if ( fechaOk != true )
	{
		//error += '<p>Tu fecha de nacimiento es errónea. Verifica que el formato sea dd/mm/aaaa.</p>';
		error += "<p>Error en la fecha de nacimiento: </p>" + fechaOk;
	}
	if ( nombre.length < "2" )
	{
		error += '<p>Debes indicar tu nombre.</p>';
	}
	if ( pais == "" )
	{
		error += '<p>Debes indicar tu país.</p>';
	}
	if ( pais==1 )
	{
		var comunidad = document.getElementById("nuevoComunidad").value;
		if ( comunidad == "" )
		{
			error += '<p>Por favor, indica tu Comunidad Autónoma.</p>';
		}
	}
	if ( localidad == "" )
	{
		error += '<p>Indica tu Localidad.</p>';
	}
	if ( error != "" )
	{
		mostrarError("error",error);
		return false;
	}else{
		return true;
	}
}