/**
 * Отправка нового вопроса
 * @return
 */
function sendFaq()
{

   question = document.getElementById('form-question').value;
   fio = document.getElementById('form-fio').value;
   phone = document.getElementById('form-phone').value;
   email = document.getElementById('form-email').value;
   captcha = document.getElementById('form-captcha').value;
   
   if (question == '') {
      alert('Не заполнено поле с вопросом');
      document.getElementById('form-question').focus();
      return false;
   }
   if (fio == '') {
	      alert('Не заполнено ФИО');
	      document.getElementById('form-fio').focus();
	      return false;
   }
   if (phone == '') {
	   alert('Не введен контактный телефон');
	   document.getElementById('form-phone').focus();
	   return false;
   }
   if (captcha == '') {
      alert('Не введен код проверки');
      document.getElementById('form-captcha').focus();
      return false;
   }

   
    $.ajax({
        url: 'type-sendQuestion.html',
        data: {
            fio: fio,
            phone: phone,
            question: question,
            email: email,
            code: captcha
            },
        cache : false,
        type: 'POST',
        dataType : "json",
        success: function (data, textStatus) { // вешаем свой обработчик на функцию success
          
            if (data.error)
            {
            	if (data.error == 'empty_fields')
            	{
            		alert('Не все обязательные поля заполнены.');
            		return;
            	}
            	if (data.error == 'captcha')
            	{
            		alert('Неверный код проверки.');
            		document.getElementById('form-captcha').focus();
            		return;
            	}
            	alert(data.error);
            	return;
            }
	        msg = 'Ваша вопрос принят. После обработки Вашего вопроса нашим сотрудником, Вы получите ответ.';
	        alert(msg);
	        document.getElementById('question').style.display='none';
	        
	        document.getElementById('form-question').value = '';
	        document.getElementById('form-fio').value = '';
	        document.getElementById('form-phone').value = '';
	        document.getElementById('form-email').value = '';
	        document.getElementById('form-captcha').value = '';

        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        	  // typically only one of textStatus or errorThrown 
        	  // will have info
        	  alert('ERROR: ' + textStatus); // the options for this ajax request
        	}

        
    });
   return true;
}