//  Function for validation of Realname, Email, Subject and Message fields

function Request_Form_Validator(theForm)
{

//  Realname

  if (theForm.realname.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.realname.focus();
    return (false);
  }

  if (theForm.realname.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"Name\" field.");
    theForm.realname.focus();
    return (false);
  }

	theForm.my_name.value = theForm.realname.value;

//  Email address

  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 8)
  {
    alert("Please enter at least 8 characters in the \"Email address\" field.");
    theForm.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@-._";
  var checkStr = theForm.email.value;
  var allValid = true;
  var validGroups = 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, digit and \"@-._\" characters in the \"Email address\" field.");
    theForm.email.focus();
    return (false);
  }

  var checkAt = "@";
  var atValid = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == checkAt) atValid = true;
  }
  if (!atValid)  
  {
    alert("Please enter a valid email address in the \"Email address\" field.");
    theForm.email.focus();
    return (false);
  }
  
	theForm.email_address.value = theForm.email.value;

//  Subject

  if (theForm.subject.value == "")
  {
    alert("Please enter a value for the \"Subject\" field.");
    theForm.subject.focus();
    return (false);
  }

//  Message

  if (theForm.Message.value == "")
  {
    alert("Please enter a value for the \"Message\" field.");
    theForm.Message.focus();
    return (false);
  }
    
  return (true);
}

