{* Smarty *}

{literal}
<script type="text/javascript">
//<![CDATA[
$(function () {
	$("#DemandsUsersFrm")
		.jstree({
			"plugins" : [ "themes", "json_data", "ui", "crrm", "dnd", "types", "hotkeys"],
      "themes" : {
        "theme" : "classic",
        "icons" : false
      },
			"json_data" : {
				"ajax" : {
          "url" : "{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/StructureOrganizationSelect.ajax.php{literal}",
					"data" : function (n) {
						return {
							"operation" : "get_children",
							"id" : n.attr ? n.attr("id").replace("node_","") : 0
						};
					}
				}
			},
			"types" : {
				"max_depth" : -2,
				"max_children" : -2,
				"valid_children" : [ "default" ],
				"types" : {
					"default" : {
						"valid_children" : "default",
						"icon" : {
							"image" : "{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToJquery}/jsTree/_demo/file.png{literal}"
						}
					},
					"folder" : {
						"valid_children" : [ "default", "folder" ],
						"icon" : {
							"image" : "{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToJquery}/jsTree/_demo/folder.png{literal}"
						}
					},
					"drive" : {
						"valid_children" : [ "default", "folder" ],
						"icon" : {
							"image" : "{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToJquery}/jsTree/_demo/root.png{literal}"
						},
						"start_drag" : false,
						"move_node" : false,
						"delete_node" : false,
						"remove" : false
					}
				}
			},
			"core" : {
				"initially_open" : [ "node_1" ],
        "strings" : {
          "loading" : "Загрузка ...",
          "new_node" : "Новый элемент"
        }
			}
		})
		.bind("select_node.jstree", function (e, data) {
			data.rslt.obj.each(function () {
				$.ajax({
					async : false,
					type: "GET",
					url : "{/literal}{$MS_SP->Sp_PathTop}{$MS_SP->Sp_PathToSite}/AjaxServer/DemandsUsersStepOne.ajax.php{literal}",
					data : {
						"UrlId" : this.id.replace("node_","")
					},
					success : function (answ) {
            $("#StructureSvt").html(answ);
					}
				});
			});
		})
});

$(function(){  
  $('.TagChooseDepartment').tooltip({
    items: "*",
    content: function() {
      return $(this).children(".DivChooseTooltip").html();
    }
  });
});
//]]>
</script>
{/literal}

<div style="padding-top: 5px; padding-bottom: 5px;" class="TagChooseDepartment">
  <div style="float: left;" class="ui-widget-content ui-corner-all">
    <div class="DivChooseTooltip" style="display: none;"><span class="ui-icon ui-icon-help" style="float:left; margin:0 7px 7px 0;"></span>Для оформления заявки выберите подразделение <br />нажав на его наименование.<br />Используйте + для просмотра вложенных подразделений!</div>
    <h3 class="ui-widget-header ui-corner-all">Структура предприятия</h3>
    <div id="DemandsUsersFrm" style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;"></div>
  </div>
  <div style="float: left; padding-left: 5px;" id="StructureSvt"></div>
</div>
<div style="clear: both;"></div>