{* Smarty *}

{literal}
<script type="text/javascript">
//<![CDATA[

$(function() {
  AltButtons();
});

$(function() {
  $("input[name='organiz_name']").css("width","400px");
  $("input[name='organiz_tel']").css("width","400px");
  $("input[name='organiz_fax']").css("width","400px");
  $("input[name='organiz_person']").css("width","400px");
  $("input[name='organiz_persontel']").css("width","400px");
  $("textarea").css("width","400px");
  $("textarea").css("height","40px");
});

function showResponseFormOrganizAdd(responseText){
  if(typeof(responseText['error'])=='undefined'){
    //$("#flexOrganiz").flexReload();
    $("#GridOrganiz").trigger("reloadGrid");
    $("#OrganizEditFrm").dialog("destroy");
    DialogStandartMessageOpen("message", responseText['message']);
  }
  else{
    DialogStandartMessageOpen("error", responseText['error']);
  }
}

$(function(){
  var options = {
    success: showResponseFormOrganizAdd,
    timeout: 3000
  };
  $("#FormOrganizAdd").validate({
    submitHandler: function(form) {
      $(form).ajaxSubmit(options);
    },
    ignore: "",
    rules : {
      "organiz_name" : {required : true}
    },
    errorPlacement: function(error, element) {
      var er = element.attr("name");
      error.appendTo($("label[for='" + er + "']").next() );
    }
  });
});
//]]>
</script>
{/literal}

<form action="{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/OrganizSave.ajax.php" method="post" name="FormOrganizAdd" id="FormOrganizAdd">
  <input id="organiz_id" name="organiz_id" type="hidden" value="{if isset($ArrOrganiz.organiz_id)}{$ArrOrganiz.organiz_id}{/if}" />
  <table width="100%">
    <tr>
      <td><label for="organiz_name">Наименование <span class="ui-state-error">* </span>:&nbsp;</label><span></span></td>
      <td><textarea cols="50" rows="2" id="organiz_name" name="organiz_name">{if isset($ArrOrganiz.organiz_name)}{$ArrOrganiz.organiz_name}{/if}</textarea></td>
    </tr>
    <tr>
      <td><label for="organiz_note">Описание :&nbsp;</label><span></span></td>
      <td><textarea cols="50" rows="2" id="organiz_note" name="organiz_note">{if isset($ArrOrganiz.organiz_note)}{$ArrOrganiz.organiz_note}{/if}</textarea></td>
    </tr>
    <tr>
      <td><label for="organiz_address">Адрес :&nbsp;</label><span></span></td>
      <td><textarea cols="50" rows="2" id="organiz_address" name="organiz_address">{if isset($ArrOrganiz.organiz_address)}{$ArrOrganiz.organiz_address}{/if}</textarea></td>
    </tr>
    <tr>
      <td><label for="organiz_tel">Телефон :&nbsp;</label><span></span></td>
      <td><input type="text" id="organiz_tel" name="organiz_tel" value="{if isset($ArrOrganiz.organiz_tel)}{$ArrOrganiz.organiz_tel}{/if}" /></td>
    </tr>
    <tr>
      <td><label for="organiz_fax">Факс :&nbsp;</label><span></span></td>
      <td><input type="text" id="organiz_fax" name="organiz_fax" value="{if isset($ArrOrganiz.organiz_fax)}{$ArrOrganiz.organiz_fax}{/if}" /></td>
    </tr>
    <tr>
      <td><label for="organiz_person">Контактное лицо :&nbsp;</label><span></span></td>
      <td><input type="text" id="organiz_person" name="organiz_person" value="{if isset($ArrOrganiz.organiz_person)}{$ArrOrganiz.organiz_person}{/if}" /></td>
    </tr>
    <tr>
      <td><label for="organiz_persontel">Телефон контактного лица :&nbsp;</label><span></span></td>
      <td><input type="text" id="organiz_persontel" name="organiz_persontel" value="{if isset($ArrOrganiz.organiz_persontel)}{$ArrOrganiz.organiz_persontel}{/if}" /></td>
    </tr>
    <tr>
      <td colspan="2">
        <span class="ui-state-error"> * </span>поля обязательные для заполнения
      </td>
    </tr>
    <tr>
      <td colspan="2" class="MsFormSubmit"><input class="AltButtons" name="FormSubmit" value="сохранить" type="submit" /></td>
    </tr>
  </table>
</form>