function toggleMe(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block"
  } else {
    e.style.display="none"
  }
  return true;
}


function Form2_Validator(theForm)
{

  var alertsay = ""; // define for long lines
  // alertsay is not necessary for your code,
  // but I need to break my lines in multiple lines
  // so the code won't extend off the edge of the page
  
  
  


 // check if email field is blank
 if (theForm.f_email.value == "")
  {
    alert("Please enter a value for the \"Friend's Email\" field.");
    theForm.f_email.focus();
    return (false);
  }
  // test if valid email address, must have @ and .
  var checkEmail = "@.";
  var checkStr = theForm.f_email.value;
  var EmailValid = false;
  var EmailAt = false;
  var EmailPeriod = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkEmail.length;  j++)
    {
      if (ch == checkEmail.charAt(j) && ch == "@")
        EmailAt = true;
      if (ch == checkEmail.charAt(j) && ch == ".")
        EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
    if (EmailAt && EmailPeriod)
    {
		EmailValid = true
		break;
	}
  }
  if (!EmailValid)
  {
    alert("The \"Friend's Email\" field must contain an \"@\" and a \".\".");
    theForm.f_email.focus();
    return (false);
  }
  
    
  // check to see if the field is blank
  if (theForm.y_name.value == "")
  {
    alert("You must enter your name in the \"Your Name\" field.");
    theForm.y_name.focus();
    return (false);
  }

  // require at least 3 characters be entered
  if (theForm.y_name.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Your Name\" field.");
    theForm.y_name.focus();
    return (false);
  }

  // allow ONLY alphanumeric keys, no symbols or punctuation
  // this can be altered for any "checkOK" string you desire
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";
  var checkStr = theForm.y_name.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and numeric characters in the \"Your Name\" field.");
    theForm.y_name.focus();
    return (false);
  }


 // check if email field is blank
 if (theForm.y_email.value == "")
  {
    alert("Please enter a value for the \"Your Email\" field.");
    theForm.y_email.focus();
    return (false);
  }


  // test if valid email address, must have @ and .
  var checkEmail = "@.";
  var checkStr = theForm.y_email.value;
  var EmailValid = false;
  var EmailAt = false;
  var EmailPeriod = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkEmail.length;  j++)
    {
      if (ch == checkEmail.charAt(j) && ch == "@")
        EmailAt = true;
      if (ch == checkEmail.charAt(j) && ch == ".")
        EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
    if (EmailAt && EmailPeriod)
    {
		EmailValid = true
		break;
	}
  }
  if (!EmailValid)
  {
    alert("The \"Your Email\" field must contain an \"@\" and a \".\".");
    theForm.y_email.focus();
    return (false);
  }




  // require at least 3 characters be entered
  if (theForm.y_msg.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Message\" field.");
    theForm.y_msg.focus();
    return (false);
  }

  return (true);
  // replace the above with return(true); if you have a valid form to submit to
}
