// JavaScript Document

// start validation form

function Reg_Validator(theForm)
{

  if (theForm.lastname.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.lastname.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
  var checkStr = theForm.lastname.value;
  var allValid = 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("Please enter only letter, whitespace and \"-\" characters in the \"Last Name\" field.");
    theForm.lastname.focus();
    return (false);
  }
  
  if (theForm.u_pass.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.u_pass.focus();
    return (false);
  }
  
  if (theForm.u_pass.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Password\" field.");
    theForm.u_pass.focus();
    return (false);
  }

  if (theForm.u_pass.value.length > 10)
  {
    alert("Please enter less than 10 characters in the \"Password\" field.");
    theForm.u_pass.focus();
    return (false);
  }
  
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  var checkStr = theForm.u_pass.value;
  var allValid = 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("Please enter only letters or numbers in the \"Password\" field.");
    theForm.u_pass.focus();
    return (false);
  }

if (theForm.u_name.value == "")
  {
    alert("Please enter a value for the \"Username\" field.");
    theForm.u_name.focus();
    return (false);
  }
  
  if (theForm.u_name.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Username\" field.");
    theForm.u_name.focus();
    return (false);
  }

  if (theForm.u_name.value.length > 10)
  {
    alert("Please enter less than 10 characters in the \"Username\" field.");
    theForm.u_name.focus();
    return (false);
  }
  
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  var checkStr = theForm.u_name.value;
  var allValid = 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("Please enter only letters or numbers in the \"Username\" field.");
    theForm.u_name.focus();
    return (false);
  }
  
  if (theForm.u_email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.u_email.focus();
    return (false);
  }
  
  if (theForm.terms.checked == false)
  {
    alert("You must agree to the Terms and Conditions.");
    theForm.terms.focus();
    return (false);
  }
  
  if (theForm.validator.value == "")
  {
    alert("Please enter a value for the \"Security Code\" field.");
    theForm.validator.focus();
    return (false);
  }
  
  return (true);
}
