// JavaScript Document

function contact_validator(theForm)
{
	if (theForm.name.value == "")
	{
		alert("Please fill in your NAME.");
		theForm.name.focus();
		return (false);
	}
	
	if (theForm.tel.value == "")
	{
		alert("Please fill in Contact No.");
		theForm.tel.focus();
		return (false);
	}
	
	var chkOK = "0123456789-.,";
    var chkStr = theForm.tel.value;
    var allValid = true;
    var validGroups = true;
    var decPoints = 0;
    var allNum = "";
    for (i = 0;  i < chkStr.length;  i++)
    {
      ch = chkStr.charAt(i);
      for (j = 0;  j < chkOK.length;  j++)
        if (ch == chkOK.charAt(j))
          break;
      if (j == chkOK.length)
      {
        allValid = false;
        break;
      }
      if (ch == ".")
      {
        allNum += ".";
        decPoints++;
      }
      else if (ch == "," && decPoints != 0)
      {
        validGroups = false;
        break;
      }
      else if (ch != ",")
        allNum += ch;
    }
	
    if (!allValid)
    {
      alert("Please enter only digit characters in the \"Contact No\" field.");
      theForm.tel.focus();
      return (false);
    }

    if (decPoints > 1 || !validGroups)
    {
      alert("Please enter a valid contact no. in the \"Contact No\" field.");
      theForm.tel.focus();
      return (false);
    }
	
		if (theForm.address.value == "")
	{
		alert("Please fill in your ADDRESS.");
		theForm.address.focus();
		return (false);
	}
	
	if (theForm.email.value == "")
	{
		alert("Please fill in your EMAIL.");
		theForm.email.focus();
		return (false);
	}
	
	if (theForm.comments.value == "")
	{
		alert("Please fill in your ENQUIRY.");
		theForm.comments.focus();
		return (false);
	}
	
	
	return (true);
	
}