function submitForm(obj, mode, uri_postfix) {
  var form = $(obj).parents('form');
  sheet('show');
  var path = form.attr('action');
  if (typeof(uri_postfix) != 'undefined') {
    form.attr('action', path + uri_postfix);
  }
  form.ajaxSubmit(function(answer) {
    if (answer) {
      submitFormError(answer);
      sheet('hide');
    } else {
      if (typeof(mode) == 'function') {
        mode();
      } else {
        switch (mode) {
          case 0:
          break;
          case 1:
            document.location.reload();
          break;
          default:
            document.location = mode;
          break;
        }
      }
    }
  });
  form.attr('action', path);
  return false;
}

function sheet(action) {
  switch (action) {
    case 'show':
      $("#sheet, #sheet_loading").show();
    break;
    case 'hide':
      $("#sheet, #sheet_loading").hide();
    break;
  }
}
