function CheckEmail(email){
  var at="@"
  var dot="."
  var lat=email.indexOf(at)
  var lstr=email.length
  var ldot=email.indexOf(dot)

  if (email.indexOf("\'")!=-1){
    return false}

  if (email.indexOf("\"")!=-1){
    return false}

  if (email.indexOf(at)==-1){
    return false}
  
  if (email.indexOf(at)==-1 || email.indexOf(at)==0 || email.indexOf(at)==lstr - 1){
    return false}
  
  if (email.indexOf(dot)==-1 || email.indexOf(dot)==0 || email.indexOf(dot)==lstr - 1){
    return false}
  
  if (email.indexOf(at,(lat+1))!=-1){
    return false}
  
  if (email.substring(lat-1,lat)==dot || email.substring(lat+1,lat+2)==dot){
    return false}
  
  if (email.indexOf(dot,(lat+2))==-1){
    return false}
		  
  if (email.indexOf(" ")!=-1){
    return false}
  
  return true}

function ValidateTAF(theForm){
  if ((theForm.youremail.value == "") || (theForm.youremail.value == null) || (CheckEmail(theForm.youremail.value) == false)){
    alert("Please enter a valid email address.")
    theForm.youremail.focus()
    return false;}

  if ((theForm.friendsemail.value == "") || (theForm.friendsemail.value == null) || (CheckEmail(theForm.friendsemail.value) == false)){
    alert("Please enter your friend's valid email address.")
    theForm.friendsemail.focus()
    return false;}}

