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 contact_form_validator(contact_form)
  {
  if (contact_form.from_name.value == "")
    {
    alert("يجب أن تذكر إسمك");
    contact_form.from_name.focus();
    return (false);
    }
  if (contact_form.from_email.value == "")
    {
    alert("يجب أن تكتب بريدك الإلكتروني");
    contact_form.from_email.focus();
    return (false);
    }
  if (!isEmailAddr(contact_form.from_email.value))
    {
    alert("yourname@yourdomain.com: الرجاء التأكد من طريقة كتابة البريد الإلكتروني، يجب أن يكون على شكل");
    contact_form.from_email.focus();
    return (false);
    }
  if (contact_form.from_email.value.length < 3)
    {
    alert("يجب أن يتكون البريد الإلكتروني على الأقل من 3 أحرف");
    contact_form.from_email.focus();
    return (false);
    }
  if (contact_form.from_email.value.substring(0,1) == " ")
    {
    alert("لا يجب أن يبدأ بريك الإلكتروني بمسافة خالية");
    contact_form.from_email.focus();
    return (false);
    }
  if (contact_form.confirm_from_email.value == "")
    {
    alert("يجب عليك تكرار البريد الإلكتروني");
    contact_form.confirm_from_email.focus();
    return (false);
    }
  if (contact_form.from_email.value != contact_form.confirm_from_email.value)
    {
    alert("تأكد من البريد الإلكتروني، لأنهما غير متطابقان");
    contact_form.confirm_from_email.focus();
    return (false);
    }
  if (contact_form.from_country.value == "")
    {
    alert("يجب أن تذكر دولتك");
    contact_form.from_country.focus();
    return (false);
    }
  if (contact_form.email_subject.value == "")
    {
    alert("يجب أن تكتب عنوان الرسالة");
    contact_form.email_subject.focus();
    return (false);
    }
  if (contact_form.email_message.value == "")
    {
    alert("يجب أن تذكر رسالتك");
    contact_form.email_message.focus();
    return (false);
    }
  return (true);
}
