function mailChk(theForm)
{

  if (theForm.eMail.value == "")
  {
    alert("Please enter a value for the \"mail\" field.");
    theForm.eMail.focus();
    return (false);
  }
  return (true);
}


function formChk(theForm)
{

  if (theForm.Name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.Company.focus();
    return (false);
  }

  if (theForm.Street.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.Street.focus();
    return (false);
  }

  if (theForm.City.value == "")
  {
    alert("Please enter a value for 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);
  }

  if (theForm.ZipCode1.value == "")
  {
    alert("Please enter a value for the \"Zip\" field.");
    theForm.ZipCode1.focus();
    return (false);
  }
  theForm2 = theForm.ZipCode1;
  var chrResult = chrChk(theForm2);
  if (!chrResult)
  {
    alert("Please enter a value for the \"Zip\" field in a half-size.");
    theForm2.focus();
    return (false);
  }

  if (theForm.Country.value == "")
  {
    alert("Please enter a value for the \"Country\" field.");
    theForm.Country.focus();
    return (false);
  }

  if (theForm.Tel.value == "")
  {
    alert("Please enter a value for the \"tel\" field.");
    theForm.Tel.focus();
    return (false);
  }

  if (theForm.eMail.value == "")
  {
    alert("Please enter a value for the \"mail\" field.");
    theForm.eMail.focus();
    return (false);
  }

  //ml = /.+@.+\.com$|.+@.+\.ne\.jp$|.+@.+\.co\.jp$/;
  ml = /.+@.+\..+/;
  mf = theForm.eMail.value;
  if (!mf.match(ml))
  {
    alert("Please check a value for the \"mail\" field.");
    theForm.eMail.focus();
    return (false);
  }
  
  if (theForm.MAG[0].checked)
  {
	if (theForm.MagMail.value == "")
	{
	    alert("Please enter a value for the \"mail address for distribution\" field.");
    	theForm.MagMail.focus();
    	return (false);
	}else{
	  ml = /.+@.+\..+/;
	  mf = theForm.MagMail.value;
	  if (!mf.match(ml))
	  {
	    alert("Please check a value for the \"mail address for distribution\" field.");
	    theForm.MagMail.focus();
	    return (false);
	  }
	}
  }

  return (true);
}


function chrChk(theForm)
{
  var checkOK  = "0123456789";
  checkOK = checkOK + "abcdefghijklmnopqrstuvwxyz";
  checkOK = checkOK + "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var checkStr = theForm.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)
  {
    return (false);
  }
  return (true);
} 
