// JavaScript Document

function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


function validate_form(thisform)
{
with (thisform)
  {
	if (pur_name.value == "" )
    {
        alert ( "Please fill in the 'Name of Organization' box." );
		pur_name.focus();
        return false;
    }
	if (realname.value == "" )
    {
        alert ( "Please fill in the 'Contact Person' box." );
		realname.focus();
        return false;
    }
	if (IsNumeric(phone.value) == false )
    {
        alert ( "Please fill valid phone number in the 'Phone' box." );
		phone.focus();
        return false;
    }
	if (validate_email(email,"Not a valid e-mail address!")==false)
	{
		email.focus();
		return false;
	}
	}
}
