function feedback_submit() {
   var form_sent = function(answer) {
      var upload_start = function() {
         $('._busy').show();
      }
      var upload_end = function() {
         $('._busy').hide();
         if (window.uf.ok) {
            $('._feedback ._answer').html(window.uf.info).removeClass('_error').addClass('_success').show();
         } else {
            $('._feedback ._answer').html(window.uf.info).addClass('_error').show();
            $('._feedback button, ._feedback select, ._feedback textarea, ._feedback input:not(input[type=file])').removeAttr('disabled');
            $('._feedback input[type=file]').val('');
         }
      }
      if (answer.ok) {
         $('._feedback select, ._feedback textarea, ._feedback input:not(input[type=file])').attr('disabled', 'disabled');
         var form_id = 'f' + Math.floor(Math.random() * 100000);
         f.attr('id', form_id).prepend('<input type="hidden" name="hash" value="' + answer.hash + '" /><input type="hidden" name="MAX_FILE_SIZE" value="5000000">');
         $$f({
            formid : form_id,
            url : '/uf/',
            onstart : upload_start,
            onsend : upload_end
         });
      } else {
         $('._feedback ._answer').html(answer.info).addClass('_error').show();
         $('._feedback ._captcha').attr('src', '/code/' + Math.random());
         $('._feedback button').removeAttr('disabled');
      }
   }
   f = $(this);
   $('._feedback button').attr('disabled', 'disabled');
   $.ajax({
      url : '/ajax/feedback',
      data : f.serializeArray(),
      dataType : 'json',
      type : 'POST',
      cache : false,
      success : form_sent
   });
   return false;
}

var files = {
   num: 0,
   max: 10,
   oid: '_files',
   field: '<a onclick="return files.dec(this)" href="#" title="Удалить поле">[X]</a> <input type="file" name="userfile[]" style="width: 630px;">'
};
files.inc = function () {
   if (this.num >= this.max){
      alert("Вы добавили максимальное количество полей");
   } else {
      var input = document.createElement('p');
      input.innerHTML = this.field;
      document.getElementById(this.oid).appendChild(input);
      this.num++;
   }
   return false;
}
files.dec = function (a) {
   var obj = a.parentNode;
   obj.parentNode.removeChild(obj);
   this.num--;
   return false;
}
