function popupMsg(msg) {
  alert(msg);
}

function validate(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;
  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("Please enter only letters in the \"Last Name\" field.");
    theForm.lastname.focus();
    return (false);
  }

  if (theForm.address.value == "")
  {
    alert("Please enter a value for the \"Street Address\" field.");
    theForm.address.focus();
    return (false);
  }

  if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.city.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. \t\r\n\f";
  var checkStr = theForm.city.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("Please enter only letter and \".\" characters in the \"City\" field.");
    theForm.city.focus();
    return (false);
  }

  if (theForm.state.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.state.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. \t\r\n\f";
  var checkStr = theForm.state.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("Please enter only letter and \".\" characters in the \"State\" field.");
    theForm.state.focus();
    return (false);
  }

  if (theForm.Country.value == "")
  {
    alert("Please enter a value for the \"Country\" field.");
    theForm.Country.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. \t\r\n\f";
  var checkStr = theForm.Country.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("Please enter only letter and \".\" characters in the \"Country\" field.");
    theForm.Country.focus();
    return (false);
  }

  if (theForm.postal.value == "")
  {
    alert("Please enter a value for the \"Zip/Postal Code\" field.");
    theForm.postal.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.phone.focus();
    return (false);
  }

  if (theForm.tract_1.value == "")
  {
    alert("Please enter a value for the \"Tract_1\" field.");
    theForm.tract_1.focus();
    return (false);
  }

  if (theForm.tract_1.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Tract_1\" field.");
    theForm.tract_1.focus();
    return (false);
  }

  if (theForm.tract_1.value.length > 4)
  {
    alert("Please enter at most 4 characters in the \"Tract_1\" field.");
    theForm.tract_1.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.tract_1.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  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;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Tract_1\" field.");
    theForm.tract_1.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "101" && prsVal <= "9000"))
  {
    alert("Please enter a value greater than or equal to \"101\" and less than or equal to \"9000\" in the \"Tract_1\" field.");
    theForm.tract_1.focus();
    return (false);
  }

  if (theForm.qty_1.value == "")
  {
    alert("Please enter a value for the \"Qty_1\" field.");
    theForm.qty_1.focus();
    return (false);
  }

  if (theForm.qty_1.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Qty_1\" field.");
    theForm.qty_1.focus();
    return (false);
  }

  if (theForm.qty_1.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Qty_1\" field.");
    theForm.qty_1.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.qty_1.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  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;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Qty_1\" field.");
    theForm.qty_1.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
    alert("Please enter a value greater than or equal to \"1\" in the \"Qty_1\" field.");
    theForm.qty_1.focus();
    return (false);
  }

  popupMsg('Your order has been submitted. . .\r\nPlease Note: Due to an increase in order volume, we are currently experiencing a longer delay in shipping your order. Please allow 2-3 weeks for shipping. If you need your order sooner, please call us with your order at 513-494-1075.')

  return (true);
}
