$(document).ready(function () {
  $('#questionForm').live('submit', sendQuestion);
});


function sendQuestion()
{
  var serialized;
  serialized = $('#questionForm').serialize();
  $('#questionForm #question_button').after('<img src="'+HTTP_PATH+'images/common/ajax-loader.gif" id="ajax-loader-question"/>');
  $('#questionForm #question_button').hide();
  
  $.post(HTTP_PATH+'public_ajax.php?file=classes/class.question.php&class=cQuestion&method=send_AJAX', serialized, function (data) {
    try
    {
      eval('data='+data);
      if (data.status == 'ok')
      {
        $('#questionForm').hide('slow');
        $('#questionForm textarea').val('');
        $('#questionForm').parent().find('h3').after(data.content);
      }
      else
      {
        $('#questionForm').parent().find('h3').after(data.content);
      }
    }
    catch (e) {
     alert(data);
    }
  });
  return false;
}

function showQuestionForm()
{
  $('#questionForm #ajax-loader-question').hide();
  $('#questionForm #question_button').show();
  $('#questionForm').show('slow');
  $('#question-answer').hide();
  return false;
}
