
var obj_form_qonline;

connectionAjax=false;


function submit_qonline()
  {
   if (connectionAjax)
     {
      return;
     }
   
   obj_form_qonline=document.forms.forma_question_online;
   
   qonline_name_user=obj_form_qonline.qonline_name_user.value;
   qonline_email_user=obj_form_qonline.qonline_email_user.value;
   qonline_text_question=obj_form_qonline.qonline_text_question.value;
   //url_site=obj_url_site.value;
   if (qonline_name_user=="")
     {
      alert("Введите свое имя!");
      return;
     }
   if (qonline_email_user=="")
     {
      alert("Не указан E-mail!");
      return;
     }
   re=/^(.+)@(.+)$/gi;
   if (!qonline_email_user.match(re))
     {
      alert("Неверный формат E-mail!");
      return;
     }
   if (qonline_text_question=="")
     {
      alert("Не указан текст сообщения!");
      return;
     }
   
   //var url_ajax=dir_modul_qonline+"/a_php/save_question.php";
   var url_ajax=dir_http+"/moduls/qonline/a_php/save_question.php";
   var post_data="name="+encodeURIComponent(qonline_name_user)+"&email="+encodeURIComponent(qonline_email_user);
   post_data+="&text="+encodeURIComponent(qonline_text_question);
   //alert(post_data);
   //loadHTTP(url_ajax,qonline_obr_submit,post_data);
   HTTPload.open("post",url_ajax,true);
   HTTPload.onreadystatechange=qonline_obr_submit;
   HTTPload.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
   
   HTTPload.send(post_data);
   connectionAjax=true;
   document.getElementById("qonline_alert_to_user").style.display="block";
   
  }

function qonline_obr_submit()
  {
   
   if (HTTPload.readyState != 4)
     {
      return (false);
     }
   
   document.getElementById("qonline_alert_to_user").style.display="none";
   
   connectionAjax=false;
   
   if (HTTPload.status == 200)
        {
         
         rezultAjax=HTTPload.responseText;//XML;
         
        }
       else
         {
          
          alert ("Произошла ошибка "+HTTPload.status);
          //удалить следующую строку
          rezultAjax=HTTPload.responseText;//XML;
          //удалить следующую строку
          alert (rezultAjax);
          return ;
         }
   
   
   
   textJoin=rezultAjax;
   //operLoad=false;
   //alert (textJoin);
   
   answer=eval('('+textJoin+')');
   if (answer.error.code==1)
     {
      alert (answer.error.text);
      
      //obj_infoTest.innerHTML="";
      return;
     }
   
   document.getElementById("qonline_block_to_form").innerHTML="Ваше сообщение принято! В ближайшее время Вам на указанный E-mail будет отправлен ответ.";//ваша заявка принята.
   
   
   
   
   
  }
  

  

  

