function validar_datos()
{   			
  var nombre = document.registro.NOMBRE.value;
  var pass1 = document.registro.password.value;
  var pass2 = document.registro.password2.value;
  var nif = document.registro.nif.value;
  var cp = document.registro.cpostal.value;
  var direc = document.registro.direccion.value;
  var ciudad = document.registro.ciudad.value;
  var provincia = document.registro.provincia.value;
  var pais = document.registro.pais.value;
  var email = document.registro.email.value;
  var tlf = document.registro.telefono.value;
  var errores = "Datos incorrectos: ";			
  var numeros = "0123456789 ";			
  
  if(nombre.length < 3)
    errores = errores + "Nombre, ";
  
  if(String(pass1) != String(pass2) || pass1.length < 4)
    errores = errores + "Password, ";
   	
  if(nif.length != 9)
    errores = errores + "Nif, ";
  
  if(cp.length < 5)
    errores = errores + "C.P, ";
   	
  if(direc.length < 5)
    errores = errores + "Direcci&oacute;n, ";
  
  if(ciudad.length < 3)
    errores = errores + "Ciudad, ";
  
  if(provincia < 1)
    errores = errores + "Provincia, ";
  
  if(pais < 1)
    errores = errores + "Pais, ";
   	
  email = isEmail(email);
  if(!email)
    errores = errores + "Email, ";
  
  for (j=0;j<tlf.length;j++)
  {
    if(numeros.indexOf(tlf.charAt(j)) == -1 || tlf.length < 8)
    {
	  errores = errores + "Telefono";
	  break;
    }
  }

  if (errores != "Datos incorrectos: ")
    alert(errores);
  else
    document.registro.submit();
}
		
function isEmail(str)
{
  var supported = 0;
  if (window.RegExp)
  {
    var tempStr = "a";
	var tempReg = new RegExp(tempStr);
	if (tempReg.test(tempStr))
	supported = 1;
  }

  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			
  return (!r1.test(str) && r2.test(str));
}		
