function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function ValidateFields(contact)
{

  if (contact.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    contact.name.focus();
    return (false);
  }

  if (contact.municipality.value == "")
  {
    alert("Please enter a value for the \"Municipality\" field.");
    contact.municipality.focus();
    return (false);
  }
  
  if (contact.email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    contact.email.focus();
    return (false);
  }

  if (contact.email.value.length < 6)
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    contact.email.focus();
    return (false);
  }
  
  if (!isEmailAddr(contact.email.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    contact.email.focus();
    return (false);
  }
   
  return (true);
}

