// JavaScript Document
function validador(theForm)
{

  if (theForm.nombre.value == "")
  {
    alert("Ingrese correctamente sus  \"Nombres\" .");
    theForm.nombre.focus();
    return (false);
  }

  if (theForm.nombre.value.length < 4)
  {
    alert("Por favor ingrese sus  \"Nombres\" .");
    theForm.nombre.focus();
    return (false);
  }

  if (theForm.nombre.value.length > 100)
  {
    alert("Por favor no ingrese más de 100 caracteres para\"Nombres\" .");
    theForm.nombre.focus();
    return (false);
  }

  if (theForm.apellido.value == "")
  {
    alert("Ingrese correctamente sus  \"Apellidos\" .");
    theForm.apellido.focus();
    return (false);
  }

  if (theForm.apellido.value.length < 4)
  {
    alert("Por favor ingrese sus  \"Apellidos\" .");
    theForm.apellido.focus();
    return (false);
  }

  if (theForm.apellido.value.length > 100)
  {
    alert("Por favor no ingrese más de 100 caracteres para\"Apellidos\" .");
    theForm.apellido.focus();
    return (false);
  }
  
  if (theForm.pais.value == "")
  {
    alert("Ingrese correctamente su  \"Pais\" .");
    theForm.pais.focus();
    return (false);
  }
  
  if (theForm.email.value == "")
  {
    alert("Ingrese su  \"Email\" .");
    theForm.email.focus();
    return (false);
  }
 if (theForm.email.value.indexOf('@', 0) == -1 || theForm.email.value.indexOf('.', 0) == -1){ 
 	alert("Dirección de e-mail inválida"); theForm.email.focus(); return (false); 
 }

  if (theForm.email.value.length < 5)
  {
    alert("Ingrese a lo menos 5 caracteres para  \"Email\" .");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length > 100)
  {
    alert(" NO puede exceder de 100 caracteres \"Email\" .");
    theForm.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@._-";
  var checkStr = theForm.email.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Ingrese Letras y Números \"@._-\" y arroba como caracteres para \"Email\" .");
    theForm.email.focus();
    return (false);
  }

if (theForm.telefono.value == "")
  {
    alert("Ingrese con codigo de area inclusive\"Telefono\" .");
    theForm.telefono.focus();
    return (false);
  }
if (theForm.telefono.value.length < 5)
  {
    alert("Número telefónico inexistente, por favor ingrese uno correcto-Ingrese con código de ciudad luego guión ej:52-856210\"Telefono\" .");
    theForm.telefono.focus();
    return (false);
  }

  if (theForm.telefono.value.length > 15)
  {
    alert("Número de teléfono demasiado largo, revise si está correcto \"Telefono\" .");
    theForm.fono.focus();
    return (false);
  }

if (theForm.comentarios.value.length < 3)
  {
    alert("Ingrese el  \"Comentario\" .");
    theForm.comentarios.focus();
    return (false);
 }
  else if (confirm("Gracias por contactar a POSICIONAMIENTO.CL. ¿Está seguro/a que TODOS los datos son correctos? de ser así pulse ACEPTAR, de lo contrario CANCELAR")) {	
		document.theForm.submit();
	}	  
	return false;
}
