function checkForm()
{
  if (document.contactUsForm.name.value == "")
  {
    alert ('Please enter your name.');
    document.contactUsForm.name.focus();
	return false;
  }
  else if (document.contactUsForm.email.value == "")
  {
    alert ('Please enter your email address.');
    document.contactUsForm.email.focus();
	return false;
  }
  else if (checkEmailAddress(document.contactUsForm.email.value)==false)
  {
    alert ('Please enter a valid email address.');
    document.contactUsForm.email.focus();
	return false;
  }
  else if (document.contactUsForm.message.value == "")
  {
    alert ('Please tell us how we can help you.');
    document.contactUsForm.message.focus();
	return false;
  }
  else
  {
    return true;
  }
}



function checkEmailAddress(emailAddress)
{
  var allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.@-_";
  var emailLength = emailAddress.length;
  var atSignPosition = 0;
  var finalDotPosition = 0;
  var numberOfDots = 0;
  var numberOfAtSigns = 0;

  if (emailLength < 5)
  {
    return false;
  }

  for (i = 0; i < emailLength ;i ++)
  {
    if (allowed.indexOf(emailAddress.charAt(i))<0)
    {
      return (false);
    }
    if ((emailAddress.charAt(i)) == "@")
    {
      numberOfAtSigns ++;
      atSignPosition = i;
    }
    else
    {
      if ((emailAddress.charAt(i)) == ".")
      {
        numberOfDots ++;
        finalDotPosition = i;
      }
    }
  }
  if (numberOfDots == 0)
  {
    return (false);
  }
  if (numberOfAtSigns != 1)
  {
    return (false);
  }
  if (atSignPosition > finalDotPosition)
  {
    return (false);
  }
  if (finalDotPosition == (emailLength-1))
  {
    return (false);
  }
  return (true);
}