function isEmail(eobj) 
{
  if ((eobj.value.length < 6 || eobj.value.length > 50 || eobj.value.indexOf('@') < 1 || eobj.value.indexOf('.') < 1))
	{
	  return (false);
	}
  else 
	  if (!syntax_check(eobj,1))
	{
	  return (false);
	}
  else
	return (true);
}


function syntax_check(obj,syntax) {
  var checkOK = new Array();
	checkOK[0] = " 0123456789-()"
	checkOK[1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
	checkOK[2] = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.#/\,";
	checkOK[3] = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.";
	checkOK[4] = "0123456789";

  var checkStr = obj.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK[syntax].length;  j++)
	  if (ch == checkOK[syntax].charAt(j))
		break;
	if (j == checkOK[syntax].length)
	{
	  allValid = false;
	  break;
	}
	allNum += ch;
  }
  if (!allValid) return (false) 
	else return (true);
}

function Form_Validator(theForm)
	{

	  if (theForm.r_full_name.value == "")
	  {
		alert("Please enter a value for the \"Full Name\" field.");
		theForm.r_full_name.focus();
		return (false);
	  }

	  if (theForm.r_full_name.value.length < 5)
	  {
		alert("Please enter at least 5 characters in the \"Full Name\" field.");
		theForm.r_full_name.focus();
		return (false);
	  }

	  if (theForm.r_full_name.value.length > 50)
	  {
		alert("Please enter at most 50 characters in the \"Full Name\" field.");
		theForm.r_full_name.focus();
		return (false);
	  }
	
	if (!isEmail(theForm.r_email))
	  {
		alert("Please enter your email address in a valid format: user_name@your.domain");
		theForm.r_email.focus();
		return (false);
	  }

	if (theForm.r_order.value != '')
	  if (!syntax_check(theForm.r_order,4))
	  {
		alert("Order number cannot have letters or special characters.");
		theForm.r_order.focus();
		return (false);
	  }

	  if (theForm.r_memo.value == "")
	  {
		alert("Please enter your question in the \"Question\" field.");
		theForm.r_memo.focus();
		return (false);
	  }

	  if (theForm.r_memo.value.length < 5)
	  {
		alert("Please enter at least 5 characters in the \"Question\" field.");
		theForm.r_memo.focus();
		return (false);
	  }

	  if (theForm.r_memo.value.length > 9999)
	  {
		alert("Please enter at most 9999 characters in the \"Question\" field.");
		theForm.r_memo.focus();
		return (false);
	  }
	  return (true);
	}