Merged updates from PyAMS_skin package
authorThierry Florac <thierry.florac@onf.fr>
Mon, 04 Jun 2018 12:32:38 +0200
changeset 210 a4497eed4ff7
parent 209 1bde2a1c1902
child 211 dd2e258340e8
Merged updates from PyAMS_skin package
src/ztfy/myams/resources/js/ext/bootstrap-treeview.js
src/ztfy/myams/resources/js/ext/bootstrap-treeview.min.js
src/ztfy/myams/resources/js/ext/jquery-dndupload.js
src/ztfy/myams/resources/js/ext/jquery-dndupload.min.js
src/ztfy/myams/resources/js/ext/jquery-scrollto-2.1.2.js
src/ztfy/myams/resources/js/ext/jquery-scrollto-2.1.2.min.js
src/ztfy/myams/resources/js/ext/jquery-select2-3.5.2.js
src/ztfy/myams/resources/js/ext/jquery-select2-3.5.2.min.js
src/ztfy/myams/resources/js/ext/jquery-select2-3.5.4.js
src/ztfy/myams/resources/js/ext/jquery-select2-3.5.4.min.js
src/ztfy/myams/resources/js/ext/js-cookie.js
src/ztfy/myams/resources/js/ext/js-cookie.min.js
src/ztfy/myams/resources/js/myams.js
src/ztfy/myams/resources/js/myams.min.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/bootstrap-treeview.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,1260 @@
+/* =========================================================
+ * bootstrap-treeview.js v1.3.0-b1-tf
+ * =========================================================
+ * Copyright 2013 Jonathan Miles
+ * Project URL : http://www.jondmiles.com/bootstrap-treeview
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================= */
+
+(function ($, window, document, undefined) {
+
+	/*global jQuery, console*/
+
+	'use strict';
+
+	var pluginName = 'treeview';
+
+	var _default = {};
+
+	_default.settings = {
+
+		injectStyle: true,
+
+		levels: 2,
+
+		expandIcon: 'glyphicon glyphicon-plus',
+		collapseIcon: 'glyphicon glyphicon-minus',
+		emptyIcon: 'glyphicon',
+		nodeIcon: '',
+		selectedIcon: '',
+		checkedIcon: 'glyphicon glyphicon-check',
+		uncheckedIcon: 'glyphicon glyphicon-unchecked',
+
+		color: undefined, // '#000000',
+		backColor: undefined, // '#FFFFFF',
+		borderColor: undefined, // '#dddddd',
+		onhoverColor: '#F5F5F5',
+		selectedColor: '#FFFFFF',
+		selectedBackColor: '#428bca',
+		unselectableBackColor: undefined, //'#FFFFFF',
+		searchResultColor: '#D9534F',
+		searchResultBackColor: undefined, //'#FFFFFF',
+
+		enableLinks: false,
+		highlightSelected: true,
+		highlightSearchResults: true,
+		showBorder: true,
+		showIcon: true,
+		showCheckbox: false,
+		showTags: false,
+		toggleUnselectable: true,
+		multiSelect: false,
+
+		// Event handlers
+		onNodeChecked: undefined,
+		onNodeCollapsed: undefined,
+		onNodeDisabled: undefined,
+		onNodeEnabled: undefined,
+		onNodeExpanded: undefined,
+		onNodeSelected: undefined,
+		onNodeUnchecked: undefined,
+		onNodeUnselected: undefined,
+		onSearchComplete: undefined,
+		onSearchCleared: undefined
+	};
+
+	_default.options = {
+		silent: false,
+		ignoreChildren: false
+	};
+
+	_default.searchOptions = {
+		ignoreCase: true,
+		exactMatch: false,
+		revealResults: true
+	};
+
+	var Tree = function (element, options) {
+
+		this.$element = $(element);
+		this.elementId = element.id;
+		this.styleId = this.elementId + '-style';
+
+		this.init(options);
+
+		return {
+
+			// Options (public access)
+			options: this.options,
+
+			// Initialize / destroy methods
+			init: $.proxy(this.init, this),
+			remove: $.proxy(this.remove, this),
+
+			// Get methods
+			getNode: $.proxy(this.getNode, this),
+			getParent: $.proxy(this.getParent, this),
+			getSiblings: $.proxy(this.getSiblings, this),
+			getSelected: $.proxy(this.getSelected, this),
+			getUnselected: $.proxy(this.getUnselected, this),
+			getExpanded: $.proxy(this.getExpanded, this),
+			getCollapsed: $.proxy(this.getCollapsed, this),
+			getChecked: $.proxy(this.getChecked, this),
+			getUnchecked: $.proxy(this.getUnchecked, this),
+			getDisabled: $.proxy(this.getDisabled, this),
+			getEnabled: $.proxy(this.getEnabled, this),
+
+			// Select methods
+			selectNode: $.proxy(this.selectNode, this),
+			unselectNode: $.proxy(this.unselectNode, this),
+			toggleNodeSelected: $.proxy(this.toggleNodeSelected, this),
+
+			// Expand / collapse methods
+			collapseAll: $.proxy(this.collapseAll, this),
+			collapseNode: $.proxy(this.collapseNode, this),
+			expandAll: $.proxy(this.expandAll, this),
+			expandNode: $.proxy(this.expandNode, this),
+			toggleNodeExpanded: $.proxy(this.toggleNodeExpanded, this),
+			revealNode: $.proxy(this.revealNode, this),
+
+			// Expand / collapse methods
+			checkAll: $.proxy(this.checkAll, this),
+			checkNode: $.proxy(this.checkNode, this),
+			uncheckAll: $.proxy(this.uncheckAll, this),
+			uncheckNode: $.proxy(this.uncheckNode, this),
+			toggleNodeChecked: $.proxy(this.toggleNodeChecked, this),
+
+			// Disable / enable methods
+			disableAll: $.proxy(this.disableAll, this),
+			disableNode: $.proxy(this.disableNode, this),
+			enableAll: $.proxy(this.enableAll, this),
+			enableNode: $.proxy(this.enableNode, this),
+			toggleNodeDisabled: $.proxy(this.toggleNodeDisabled, this),
+
+			// Search methods
+			search: $.proxy(this.search, this),
+			clearSearch: $.proxy(this.clearSearch, this)
+		};
+	};
+
+	Tree.prototype.init = function (options) {
+
+		this.tree = [];
+		this.nodes = [];
+
+		if (options.data) {
+			if (typeof options.data === 'string') {
+				options.data = $.parseJSON(options.data);
+			}
+			this.tree = $.extend(true, [], options.data);
+			delete options.data;
+		}
+		this.options = $.extend({}, _default.settings, options);
+
+		this.destroy();
+		this.subscribeEvents();
+		this.setInitialStates({ nodes: this.tree }, 0);
+		this.render();
+	};
+
+	Tree.prototype.remove = function () {
+		this.destroy();
+		$.removeData(this, pluginName);
+		$('#' + this.styleId).remove();
+	};
+
+	Tree.prototype.destroy = function () {
+
+		if (!this.initialized) return;
+
+		this.$wrapper.remove();
+		this.$wrapper = null;
+
+		// Switch off events
+		this.unsubscribeEvents();
+
+		// Reset this.initialized flag
+		this.initialized = false;
+	};
+
+	Tree.prototype.unsubscribeEvents = function () {
+
+		this.$element.off('click');
+		this.$element.off('nodeChecked');
+		this.$element.off('nodeCollapsed');
+		this.$element.off('nodeDisabled');
+		this.$element.off('nodeEnabled');
+		this.$element.off('nodeExpanded');
+		this.$element.off('nodeSelected');
+		this.$element.off('nodeUnchecked');
+		this.$element.off('nodeUnselected');
+		this.$element.off('searchComplete');
+		this.$element.off('searchCleared');
+	};
+
+	Tree.prototype.subscribeEvents = function () {
+
+		this.unsubscribeEvents();
+
+		this.$element.on('click', $.proxy(this.clickHandler, this));
+
+		if (typeof (this.options.onNodeChecked) === 'function') {
+			this.$element.on('nodeChecked', this.options.onNodeChecked);
+		}
+
+		if (typeof (this.options.onNodeCollapsed) === 'function') {
+			this.$element.on('nodeCollapsed', this.options.onNodeCollapsed);
+		}
+
+		if (typeof (this.options.onNodeDisabled) === 'function') {
+			this.$element.on('nodeDisabled', this.options.onNodeDisabled);
+		}
+
+		if (typeof (this.options.onNodeEnabled) === 'function') {
+			this.$element.on('nodeEnabled', this.options.onNodeEnabled);
+		}
+
+		if (typeof (this.options.onNodeExpanded) === 'function') {
+			this.$element.on('nodeExpanded', this.options.onNodeExpanded);
+		}
+
+		if (typeof (this.options.onNodeSelected) === 'function') {
+			this.$element.on('nodeSelected', this.options.onNodeSelected);
+		}
+
+		if (typeof (this.options.onNodeUnchecked) === 'function') {
+			this.$element.on('nodeUnchecked', this.options.onNodeUnchecked);
+		}
+
+		if (typeof (this.options.onNodeUnselected) === 'function') {
+			this.$element.on('nodeUnselected', this.options.onNodeUnselected);
+		}
+
+		if (typeof (this.options.onSearchComplete) === 'function') {
+			this.$element.on('searchComplete', this.options.onSearchComplete);
+		}
+
+		if (typeof (this.options.onSearchCleared) === 'function') {
+			this.$element.on('searchCleared', this.options.onSearchCleared);
+		}
+	};
+
+	/*
+		Recurse the tree structure and ensure all nodes have
+		valid initial states.  User defined states will be preserved.
+		For performance we also take this opportunity to
+		index nodes in a flattened structure
+	*/
+	Tree.prototype.setInitialStates = function (node, level) {
+
+		if (!node.nodes) return;
+		level += 1;
+
+		var parent = node;
+		var _this = this;
+		$.each(node.nodes, function checkStates(index, node) {
+
+			// nodeId : unique, incremental identifier
+			node.nodeId = _this.nodes.length;
+
+			// parentId : transversing up the tree
+			node.parentId = parent.nodeId;
+
+			// if not provided set selectable default value
+			if (!node.hasOwnProperty('selectable')) {
+				node.selectable = true;
+			}
+
+			// where provided we should preserve states
+			node.state = node.state || {};
+
+			// set checked state; unless set always false
+			if (!node.state.hasOwnProperty('checked')) {
+				node.state.checked = false;
+			}
+
+			// set enabled state; unless set always false
+			if (!node.state.hasOwnProperty('disabled')) {
+				node.state.disabled = false;
+			}
+
+			// set expanded state; if not provided based on levels
+			if (!node.state.hasOwnProperty('expanded')) {
+				if (!node.state.disabled &&
+						(level < _this.options.levels) &&
+						(node.nodes && node.nodes.length > 0)) {
+					node.state.expanded = true;
+				}
+				else {
+					node.state.expanded = false;
+				}
+			}
+
+			// set selected state; unless set always false
+			if (!node.state.hasOwnProperty('selected')) {
+				node.state.selected = false;
+			}
+
+			// index nodes in a flattened structure for use later
+			_this.nodes.push(node);
+
+			// recurse child nodes and transverse the tree
+			if (node.nodes) {
+				_this.setInitialStates(node, level);
+			}
+		});
+	};
+
+	Tree.prototype.clickHandler = function (event) {
+
+		if (!this.options.enableLinks) event.preventDefault();
+
+		var target = $(event.target);
+		var node = this.findNode(target);
+		if (!node || node.state.disabled) return;
+		
+		var classList = target.attr('class') ? target.attr('class').split(' ') : [];
+		if ((classList.indexOf('expand-icon') !== -1)) {
+
+			this.toggleExpandedState(node, _default.options);
+			this.render();
+		}
+		else if ((classList.indexOf('check-icon') !== -1)) {
+			
+			this.toggleCheckedState(node, _default.options);
+			this.render();
+		}
+		else {
+			
+			if (node.selectable) {
+				this.toggleSelectedState(node, _default.options);
+			} else if (this.options.toggleUnselectable) {
+				this.toggleExpandedState(node, _default.options);
+			}
+
+			this.render();
+		}
+	};
+
+	// Looks up the DOM for the closest parent list item to retrieve the
+	// data attribute nodeid, which is used to lookup the node in the flattened structure.
+	Tree.prototype.findNode = function (target) {
+
+		var nodeId = target.closest('li.list-group-item').attr('data-nodeid');
+		var node = this.nodes[nodeId];
+
+		if (!node) {
+			console.log('Error: node does not exist');
+		}
+		return node;
+	};
+
+	Tree.prototype.toggleExpandedState = function (node, options) {
+		if (!node) return;
+		this.setExpandedState(node, !node.state.expanded, options);
+	};
+
+	Tree.prototype.setExpandedState = function (node, state, options) {
+
+		if (state === node.state.expanded) return;
+
+		if (state && node.nodes) {
+
+			// Expand a node
+			node.state.expanded = true;
+			if (!options.silent) {
+				this.$element.trigger('nodeExpanded', $.extend(true, {}, node));
+			}
+		}
+		else if (!state) {
+
+			// Collapse a node
+			node.state.expanded = false;
+			if (!options.silent) {
+				this.$element.trigger('nodeCollapsed', $.extend(true, {}, node));
+			}
+
+			// Collapse child nodes
+			if (node.nodes && !options.ignoreChildren) {
+				$.each(node.nodes, $.proxy(function (index, node) {
+					this.setExpandedState(node, false, options);
+				}, this));
+			}
+		}
+	};
+
+	Tree.prototype.toggleSelectedState = function (node, options) {
+		if (!node) return;
+		this.setSelectedState(node, !node.state.selected, options);
+	};
+
+	Tree.prototype.setSelectedState = function (node, state, options) {
+
+		if (state === node.state.selected) return;
+
+		if (state) {
+
+			// If multiSelect false, unselect previously selected
+			if (!this.options.multiSelect) {
+				$.each(this.findNodes('true', 'g', 'state.selected'), $.proxy(function (index, node) {
+					this.setSelectedState(node, false, options);
+				}, this));
+			}
+
+			// Continue selecting node
+			node.state.selected = true;
+			if (!options.silent) {
+				this.$element.trigger('nodeSelected', $.extend(true, {}, node));
+			}
+		}
+		else {
+
+			// Unselect node
+			node.state.selected = false;
+			if (!options.silent) {
+				this.$element.trigger('nodeUnselected', $.extend(true, {}, node));
+			}
+		}
+	};
+
+	Tree.prototype.toggleCheckedState = function (node, options) {
+		if (!node) return;
+		this.setCheckedState(node, !node.state.checked, options);
+	};
+
+	Tree.prototype.setCheckedState = function (node, state, options) {
+
+		if (state === node.state.checked) return;
+
+		if (state) {
+
+			// Check node
+			node.state.checked = true;
+
+			if (!options.silent) {
+				this.$element.trigger('nodeChecked', $.extend(true, {}, node));
+			}
+		}
+		else {
+
+			// Uncheck node
+			node.state.checked = false;
+			if (!options.silent) {
+				this.$element.trigger('nodeUnchecked', $.extend(true, {}, node));
+			}
+		}
+	};
+
+	Tree.prototype.setDisabledState = function (node, state, options) {
+
+		if (state === node.state.disabled) return;
+
+		if (state) {
+
+			// Disable node
+			node.state.disabled = true;
+
+			// Disable all other states
+			this.setExpandedState(node, false, options);
+			this.setSelectedState(node, false, options);
+			this.setCheckedState(node, false, options);
+
+			if (!options.silent) {
+				this.$element.trigger('nodeDisabled', $.extend(true, {}, node));
+			}
+		}
+		else {
+
+			// Enabled node
+			node.state.disabled = false;
+			if (!options.silent) {
+				this.$element.trigger('nodeEnabled', $.extend(true, {}, node));
+			}
+		}
+	};
+
+	Tree.prototype.render = function () {
+
+		if (!this.initialized) {
+
+			// Setup first time only components
+			this.$element.addClass(pluginName);
+			this.$wrapper = $(this.template.list);
+
+			this.injectStyle();
+
+			this.initialized = true;
+		}
+
+		this.$element.empty().append(this.$wrapper.empty());
+
+		// Build tree
+		this.buildTree(this.tree, 0);
+	};
+
+	// Starting from the root node, and recursing down the
+	// structure we build the tree one node at a time
+	Tree.prototype.buildTree = function (nodes, level) {
+
+		if (!nodes) return;
+		level += 1;
+
+		var _this = this;
+		$.each(nodes, function addNodes(id, node) {
+
+			var treeItem = $(_this.template.item)
+				.addClass('node-' + _this.elementId)
+				.addClass(node.state.checked ? 'node-checked' : '')
+				.addClass(node.state.disabled ? 'node-disabled': '')
+				.addClass(node.state.selected ? 'node-selected' : '')
+				.addClass(node.searchResult ? 'search-result' : '') 
+				.attr('data-nodeid', node.nodeId)
+				.attr('style', _this.buildStyleOverride(node));
+
+			// Add indent/spacer to mimic tree structure
+			for (var i = 0; i < (level - 1); i++) {
+				treeItem.append(_this.template.indent);
+			}
+
+			// Add expand, collapse or empty spacer icons
+			var classList = [];
+			if (node.nodes) {
+				classList.push('expand-icon');
+				if (node.state.expanded) {
+					classList.push(_this.options.collapseIcon);
+				}
+				else {
+					classList.push(_this.options.expandIcon);
+				}
+			}
+			else {
+				classList.push(_this.options.emptyIcon);
+			}
+
+			treeItem
+				.append($(_this.template.icon)
+					.addClass(classList.join(' '))
+				);
+
+
+			// Add node icon
+			if (_this.options.showIcon) {
+				
+				var classList = ['node-icon'];
+
+				classList.push(node.icon || _this.options.nodeIcon);
+				if (node.state.selected) {
+					classList.pop();
+					classList.push(node.selectedIcon || _this.options.selectedIcon || 
+									node.icon || _this.options.nodeIcon);
+				}
+
+				treeItem
+					.append($(_this.template.icon)
+						.addClass(classList.join(' '))
+					);
+			}
+
+			// Add check / unchecked icon
+			if (_this.options.showCheckbox) {
+
+				var classList = ['check-icon'];
+				if (node.state.checked) {
+					classList.push(_this.options.checkedIcon); 
+				}
+				else {
+					classList.push(_this.options.uncheckedIcon);
+				}
+
+				treeItem
+					.append($(_this.template.icon)
+						.addClass(classList.join(' '))
+					);
+			}
+
+			// Add text
+			if (_this.options.enableLinks) {
+				// Add hyperlink
+				treeItem
+					.append($(_this.template.link)
+						.attr('href', node.href)
+						.append(node.text)
+					);
+			}
+			else {
+				// otherwise just text
+				treeItem
+					.append(node.text);
+			}
+
+			// Add tags as badges
+			if (_this.options.showTags && node.tags) {
+				$.each(node.tags, function addTag(id, tag) {
+					treeItem
+						.append($(_this.template.badge)
+							.append(tag)
+						);
+				});
+			}
+
+			// Add item to the tree
+			_this.$wrapper.append(treeItem);
+
+			// Recursively add child ndoes
+			if (node.nodes && node.state.expanded && !node.state.disabled) {
+				return _this.buildTree(node.nodes, level);
+			}
+		});
+	};
+
+	// Define any node level style override for
+	// 1. selectedNode
+	// 2. node|data assigned color overrides
+	Tree.prototype.buildStyleOverride = function (node) {
+
+		if (node.state.disabled) return '';
+
+		var color = node.color;
+		var backColor = node.backColor;
+
+		if (!node.selectable) {
+			if (this.options.unselectableColor) {
+				color = this.options.unselectableColor;
+			}
+			if (this.options.unselectableBackColor) {
+				backColor = this.options.unselectableBackColor;
+			}
+		}
+
+		if (this.options.highlightSelected && node.state.selected) {
+			if (this.options.selectedColor) {
+				color = this.options.selectedColor;
+			}
+			if (this.options.selectedBackColor) {
+				backColor = this.options.selectedBackColor;
+			}
+		}
+
+		if (this.options.highlightSearchResults && node.searchResult && !node.state.disabled) {
+			if (this.options.searchResultColor) {
+				color = this.options.searchResultColor;
+			}
+			if (this.options.searchResultBackColor) {
+				backColor = this.options.searchResultBackColor;
+			}
+		}
+
+		return 'color:' + color +
+			';background-color:' + backColor + ';';
+	};
+
+	// Add inline style into head
+	Tree.prototype.injectStyle = function () {
+
+		if (this.options.injectStyle && !document.getElementById(this.styleId)) {
+			$('<style type="text/css" id="' + this.styleId + '"> ' + this.buildStyle() + ' </style>').appendTo('head');
+		}
+	};
+
+	// Construct trees style based on user options
+	Tree.prototype.buildStyle = function () {
+
+		var style = '.node-' + this.elementId + '{';
+
+		if (this.options.color) {
+			style += 'color:' + this.options.color + ';';
+		}
+
+		if (this.options.backColor) {
+			style += 'background-color:' + this.options.backColor + ';';
+		}
+
+		if (!this.options.showBorder) {
+			style += 'border:none;';
+		}
+		else if (this.options.borderColor) {
+			style += 'border:1px solid ' + this.options.borderColor + ';';
+		}
+		style += '}';
+
+		if (this.options.onhoverColor) {
+			style += '.node-' + this.elementId + ':not(.node-disabled):hover{' +
+				'background-color:' + this.options.onhoverColor + ';' +
+			'}';
+		}
+
+		return this.css + style;
+	};
+
+	Tree.prototype.template = {
+		list: '<ul class="list-group"></ul>',
+		item: '<li class="list-group-item"></li>',
+		indent: '<span class="indent"></span>',
+		icon: '<span class="icon"></span>',
+		link: '<a href="#" style="color:inherit;"></a>',
+		badge: '<span class="badge"></span>'
+	};
+
+	Tree.prototype.css = '.treeview .list-group-item{cursor:pointer}.treeview span.indent{margin-left:10px;margin-right:10px}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}'
+
+
+	/**
+		Returns a single node object that matches the given node id.
+		@param {Number} nodeId - A node's unique identifier
+		@return {Object} node - Matching node
+	*/
+	Tree.prototype.getNode = function (nodeId) {
+		return this.nodes[nodeId];
+	};
+
+	/**
+		Returns the parent node of a given node, if valid otherwise returns undefined.
+		@param {Object|Number} identifier - A valid node or node id
+		@returns {Object} node - The parent node
+	*/
+	Tree.prototype.getParent = function (identifier) {
+		var node = this.identifyNode(identifier);
+		return this.nodes[node.parentId];
+	};
+
+	/**
+		Returns an array of sibling nodes for a given node, if valid otherwise returns undefined.
+		@param {Object|Number} identifier - A valid node or node id
+		@returns {Array} nodes - Sibling nodes
+	*/
+	Tree.prototype.getSiblings = function (identifier) {
+		var node = this.identifyNode(identifier);
+		var parent = this.getParent(node);
+		var nodes = parent ? parent.nodes : this.tree;
+		return nodes.filter(function (obj) {
+				return obj.nodeId !== node.nodeId;
+			});
+	};
+
+	/**
+		Returns an array of selected nodes.
+		@returns {Array} nodes - Selected nodes
+	*/
+	Tree.prototype.getSelected = function () {
+		return this.findNodes('true', 'g', 'state.selected');
+	};
+
+	/**
+		Returns an array of unselected nodes.
+		@returns {Array} nodes - Unselected nodes
+	*/
+	Tree.prototype.getUnselected = function () {
+		return this.findNodes('false', 'g', 'state.selected');
+	};
+
+	/**
+		Returns an array of expanded nodes.
+		@returns {Array} nodes - Expanded nodes
+	*/
+	Tree.prototype.getExpanded = function () {
+		return this.findNodes('true', 'g', 'state.expanded');
+	};
+
+	/**
+		Returns an array of collapsed nodes.
+		@returns {Array} nodes - Collapsed nodes
+	*/
+	Tree.prototype.getCollapsed = function () {
+		return this.findNodes('false', 'g', 'state.expanded');
+	};
+
+	/**
+		Returns an array of checked nodes.
+		@returns {Array} nodes - Checked nodes
+	*/
+	Tree.prototype.getChecked = function () {
+		return this.findNodes('true', 'g', 'state.checked');
+	};
+
+	/**
+		Returns an array of unchecked nodes.
+		@returns {Array} nodes - Unchecked nodes
+	*/
+	Tree.prototype.getUnchecked = function () {
+		return this.findNodes('false', 'g', 'state.checked');
+	};
+
+	/**
+		Returns an array of disabled nodes.
+		@returns {Array} nodes - Disabled nodes
+	*/
+	Tree.prototype.getDisabled = function () {
+		return this.findNodes('true', 'g', 'state.disabled');
+	};
+
+	/**
+		Returns an array of enabled nodes.
+		@returns {Array} nodes - Enabled nodes
+	*/
+	Tree.prototype.getEnabled = function () {
+		return this.findNodes('false', 'g', 'state.disabled');
+	};
+
+
+	/**
+		Set a node state to selected
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.selectNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setSelectedState(node, true, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Set a node state to unselected
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.unselectNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setSelectedState(node, false, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Toggles a node selected state; selecting if unselected, unselecting if selected.
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.toggleNodeSelected = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.toggleSelectedState(node, options);
+		}, this));
+
+		this.render();
+	};
+
+
+	/**
+		Collapse all tree nodes
+		@param {optional Object} options
+	*/
+	Tree.prototype.collapseAll = function (options) {
+		var identifiers = this.findNodes('true', 'g', 'state.expanded');
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setExpandedState(node, false, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Collapse a given tree node
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.collapseNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setExpandedState(node, false, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Expand all tree nodes
+		@param {optional Object} options
+	*/
+	Tree.prototype.expandAll = function (options) {
+		options = $.extend({}, _default.options, options);
+
+		if (options && options.levels) {
+			this.expandLevels(this.tree, options.levels, options);
+		}
+		else {
+			var identifiers = this.findNodes('false', 'g', 'state.expanded');
+			this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+				this.setExpandedState(node, true, options);
+			}, this));
+		}
+
+		this.render();
+	};
+
+	/**
+		Expand a given tree node
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.expandNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setExpandedState(node, true, options);
+			if (node.nodes && (options && options.levels)) {
+				this.expandLevels(node.nodes, options.levels-1, options);
+			}
+		}, this));
+
+		this.render();
+	};
+
+	Tree.prototype.expandLevels = function (nodes, level, options) {
+		options = $.extend({}, _default.options, options);
+
+		$.each(nodes, $.proxy(function (index, node) {
+			this.setExpandedState(node, (level > 0) ? true : false, options);
+			if (node.nodes) {
+				this.expandLevels(node.nodes, level-1, options);
+			}
+		}, this));
+	};
+
+	/**
+		Reveals a given tree node, expanding the tree from node to root.
+		@param {Object|Number|Array} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.revealNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			var parentNode = this.getParent(node);
+			while (parentNode) {
+				this.setExpandedState(parentNode, true, options);
+				parentNode = this.getParent(parentNode);
+			};
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Toggles a nodes expanded state; collapsing if expanded, expanding if collapsed.
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.toggleNodeExpanded = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.toggleExpandedState(node, options);
+		}, this));
+		
+		this.render();
+	};
+
+
+	/**
+		Check all tree nodes
+		@param {optional Object} options
+	*/
+	Tree.prototype.checkAll = function (options) {
+		var identifiers = this.findNodes('false', 'g', 'state.checked');
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setCheckedState(node, true, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Check a given tree node
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.checkNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setCheckedState(node, true, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Uncheck all tree nodes
+		@param {optional Object} options
+	*/
+	Tree.prototype.uncheckAll = function (options) {
+		var identifiers = this.findNodes('true', 'g', 'state.checked');
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setCheckedState(node, false, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Uncheck a given tree node
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.uncheckNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setCheckedState(node, false, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Toggles a nodes checked state; checking if unchecked, unchecking if checked.
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.toggleNodeChecked = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.toggleCheckedState(node, options);
+		}, this));
+
+		this.render();
+	};
+
+
+	/**
+		Disable all tree nodes
+		@param {optional Object} options
+	*/
+	Tree.prototype.disableAll = function (options) {
+		var identifiers = this.findNodes('false', 'g', 'state.disabled');
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setDisabledState(node, true, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Disable a given tree node
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.disableNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setDisabledState(node, true, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Enable all tree nodes
+		@param {optional Object} options
+	*/
+	Tree.prototype.enableAll = function (options) {
+		var identifiers = this.findNodes('true', 'g', 'state.disabled');
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setDisabledState(node, false, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Enable a given tree node
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.enableNode = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setDisabledState(node, false, options);
+		}, this));
+
+		this.render();
+	};
+
+	/**
+		Toggles a nodes disabled state; disabling is enabled, enabling if disabled.
+		@param {Object|Number} identifiers - A valid node, node id or array of node identifiers
+		@param {optional Object} options
+	*/
+	Tree.prototype.toggleNodeDisabled = function (identifiers, options) {
+		this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) {
+			this.setDisabledState(node, !node.state.disabled, options);
+		}, this));
+
+		this.render();
+	};
+
+
+	/**
+		Common code for processing multiple identifiers
+	*/
+	Tree.prototype.forEachIdentifier = function (identifiers, options, callback) {
+
+		options = $.extend({}, _default.options, options);
+
+		if (!(identifiers instanceof Array)) {
+			identifiers = [identifiers];
+		}
+
+		$.each(identifiers, $.proxy(function (index, identifier) {
+			callback(this.identifyNode(identifier), options);
+		}, this));	
+	};
+
+	/*
+		Identifies a node from either a node id or object
+	*/
+	Tree.prototype.identifyNode = function (identifier) {
+		return ((typeof identifier) === 'number') ?
+						this.nodes[identifier] :
+						identifier;
+	};
+
+	/**
+		Searches the tree for nodes (text) that match given criteria
+		@param {String} pattern - A given string to match against
+		@param {optional Object} options - Search criteria options
+		@return {Array} nodes - Matching nodes
+	*/
+	Tree.prototype.search = function (pattern, options) {
+		options = $.extend({}, _default.searchOptions, options);
+
+		this.clearSearch({ render: false });
+
+		var results = [];
+		if (pattern && pattern.length > 0) {
+
+			if (options.exactMatch) {
+				pattern = '^' + pattern + '$';
+			}
+
+			var modifier = 'g';
+			if (options.ignoreCase) {
+				modifier += 'i';
+			}
+
+			results = this.findNodes(pattern, modifier);
+
+			// Add searchResult property to all matching nodes
+			// This will be used to apply custom styles
+			// and when identifying result to be cleared
+			$.each(results, function (index, node) {
+				node.searchResult = true;
+			})
+		}
+
+		// If revealResults, then render is triggered from revealNode
+		// otherwise we just call render.
+		if (options.revealResults) {
+			this.revealNode(results);
+		}
+		else {
+			this.render();
+		}
+
+		this.$element.trigger('searchComplete', $.extend(true, {}, results));
+
+		return results;
+	};
+
+	/**
+		Clears previous search results
+	*/
+	Tree.prototype.clearSearch = function (options) {
+
+		options = $.extend({}, { render: true }, options);
+
+		var results = $.each(this.findNodes('true', 'g', 'searchResult'), function (index, node) {
+			node.searchResult = false;
+		});
+
+		if (options.render) {
+			this.render();	
+		}
+		
+		this.$element.trigger('searchCleared', $.extend(true, {}, results));
+	};
+
+	/**
+		Find nodes that match a given criteria
+		@param {String} pattern - A given string to match against
+		@param {optional String} modifier - Valid RegEx modifiers
+		@param {optional String} attribute - Attribute to compare pattern against
+		@return {Array} nodes - Nodes that match your criteria
+	*/
+	Tree.prototype.findNodes = function (pattern, modifier, attribute) {
+
+		modifier = modifier || 'g';
+		attribute = attribute || 'text';
+
+		var _this = this;
+		return $.grep(this.nodes, function (node) {
+			var val = _this.getNodeValue(node, attribute);
+			if (typeof val === 'string') {
+				return val.match(new RegExp(pattern, modifier));
+			}
+		});
+	};
+
+	/**
+		Recursive find for retrieving nested attributes values
+		All values are return as strings, unless invalid
+		@param {Object} obj - Typically a node, could be any object
+		@param {String} attr - Identifies an object property using dot notation
+		@return {String} value - Matching attributes string representation
+	*/
+	Tree.prototype.getNodeValue = function (obj, attr) {
+		var index = attr.indexOf('.');
+		if (index > 0) {
+			var _obj = obj[attr.substring(0, index)];
+			var _attr = attr.substring(index + 1, attr.length);
+			return this.getNodeValue(_obj, _attr);
+		}
+		else {
+			if (obj.hasOwnProperty(attr)) {
+				return obj[attr].toString();
+			}
+			else {
+				return undefined;
+			}
+		}
+	};
+
+	var logError = function (message) {
+		if (window.console) {
+			window.console.error(message);
+		}
+	};
+
+	// Prevent against multiple instantiations,
+	// handle updates and method calls
+	$.fn[pluginName] = function (options, args) {
+
+		var result;
+
+		this.each(function () {
+			var _this = $.data(this, pluginName);
+			if (typeof options === 'string') {
+				if (!_this) {
+					logError('Not initialized, can not call method : ' + options);
+				}
+				else if (!$.isFunction(_this[options]) || options.charAt(0) === '_') {
+					logError('No such method : ' + options);
+				}
+				else {
+					if (!(args instanceof Array)) {
+						args = [ args ];
+					}
+					result = _this[options].apply(_this, args);
+				}
+			}
+			else if (typeof options === 'boolean') {
+				result = _this;
+			}
+			else {
+				$.data(this, pluginName, new Tree(this, $.extend(true, {}, options)));
+			}
+		});
+
+		return result || this;
+	};
+
+})(jQuery, window, document);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/bootstrap-treeview.min.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,1 @@
+!function(e,t,o,s){"use strict";var n={};n.settings={injectStyle:!0,levels:2,expandIcon:"glyphicon glyphicon-plus",collapseIcon:"glyphicon glyphicon-minus",emptyIcon:"glyphicon",nodeIcon:"",selectedIcon:"",checkedIcon:"glyphicon glyphicon-check",uncheckedIcon:"glyphicon glyphicon-unchecked",color:void 0,backColor:void 0,borderColor:void 0,onhoverColor:"#F5F5F5",selectedColor:"#FFFFFF",selectedBackColor:"#428bca",unselectableBackColor:void 0,searchResultColor:"#D9534F",searchResultBackColor:void 0,enableLinks:!1,highlightSelected:!0,highlightSearchResults:!0,showBorder:!0,showIcon:!0,showCheckbox:!1,showTags:!1,toggleUnselectable:!0,multiSelect:!1,onNodeChecked:void 0,onNodeCollapsed:void 0,onNodeDisabled:void 0,onNodeEnabled:void 0,onNodeExpanded:void 0,onNodeSelected:void 0,onNodeUnchecked:void 0,onNodeUnselected:void 0,onSearchComplete:void 0,onSearchCleared:void 0},n.options={silent:!1,ignoreChildren:!1},n.searchOptions={ignoreCase:!0,exactMatch:!1,revealResults:!0};var i=function(t,o){return this.$element=e(t),this.elementId=t.id,this.styleId=this.elementId+"-style",this.init(o),{options:this.options,init:e.proxy(this.init,this),remove:e.proxy(this.remove,this),getNode:e.proxy(this.getNode,this),getParent:e.proxy(this.getParent,this),getSiblings:e.proxy(this.getSiblings,this),getSelected:e.proxy(this.getSelected,this),getUnselected:e.proxy(this.getUnselected,this),getExpanded:e.proxy(this.getExpanded,this),getCollapsed:e.proxy(this.getCollapsed,this),getChecked:e.proxy(this.getChecked,this),getUnchecked:e.proxy(this.getUnchecked,this),getDisabled:e.proxy(this.getDisabled,this),getEnabled:e.proxy(this.getEnabled,this),selectNode:e.proxy(this.selectNode,this),unselectNode:e.proxy(this.unselectNode,this),toggleNodeSelected:e.proxy(this.toggleNodeSelected,this),collapseAll:e.proxy(this.collapseAll,this),collapseNode:e.proxy(this.collapseNode,this),expandAll:e.proxy(this.expandAll,this),expandNode:e.proxy(this.expandNode,this),toggleNodeExpanded:e.proxy(this.toggleNodeExpanded,this),revealNode:e.proxy(this.revealNode,this),checkAll:e.proxy(this.checkAll,this),checkNode:e.proxy(this.checkNode,this),uncheckAll:e.proxy(this.uncheckAll,this),uncheckNode:e.proxy(this.uncheckNode,this),toggleNodeChecked:e.proxy(this.toggleNodeChecked,this),disableAll:e.proxy(this.disableAll,this),disableNode:e.proxy(this.disableNode,this),enableAll:e.proxy(this.enableAll,this),enableNode:e.proxy(this.enableNode,this),toggleNodeDisabled:e.proxy(this.toggleNodeDisabled,this),search:e.proxy(this.search,this),clearSearch:e.proxy(this.clearSearch,this)}};i.prototype.init=function(t){this.tree=[],this.nodes=[],t.data&&("string"==typeof t.data&&(t.data=e.parseJSON(t.data)),this.tree=e.extend(!0,[],t.data),delete t.data),this.options=e.extend({},n.settings,t),this.destroy(),this.subscribeEvents(),this.setInitialStates({nodes:this.tree},0),this.render()},i.prototype.remove=function(){this.destroy(),e.removeData(this,"treeview"),e("#"+this.styleId).remove()},i.prototype.destroy=function(){this.initialized&&(this.$wrapper.remove(),this.$wrapper=null,this.unsubscribeEvents(),this.initialized=!1)},i.prototype.unsubscribeEvents=function(){this.$element.off("click"),this.$element.off("nodeChecked"),this.$element.off("nodeCollapsed"),this.$element.off("nodeDisabled"),this.$element.off("nodeEnabled"),this.$element.off("nodeExpanded"),this.$element.off("nodeSelected"),this.$element.off("nodeUnchecked"),this.$element.off("nodeUnselected"),this.$element.off("searchComplete"),this.$element.off("searchCleared")},i.prototype.subscribeEvents=function(){this.unsubscribeEvents(),this.$element.on("click",e.proxy(this.clickHandler,this)),"function"==typeof this.options.onNodeChecked&&this.$element.on("nodeChecked",this.options.onNodeChecked),"function"==typeof this.options.onNodeCollapsed&&this.$element.on("nodeCollapsed",this.options.onNodeCollapsed),"function"==typeof this.options.onNodeDisabled&&this.$element.on("nodeDisabled",this.options.onNodeDisabled),"function"==typeof this.options.onNodeEnabled&&this.$element.on("nodeEnabled",this.options.onNodeEnabled),"function"==typeof this.options.onNodeExpanded&&this.$element.on("nodeExpanded",this.options.onNodeExpanded),"function"==typeof this.options.onNodeSelected&&this.$element.on("nodeSelected",this.options.onNodeSelected),"function"==typeof this.options.onNodeUnchecked&&this.$element.on("nodeUnchecked",this.options.onNodeUnchecked),"function"==typeof this.options.onNodeUnselected&&this.$element.on("nodeUnselected",this.options.onNodeUnselected),"function"==typeof this.options.onSearchComplete&&this.$element.on("searchComplete",this.options.onSearchComplete),"function"==typeof this.options.onSearchCleared&&this.$element.on("searchCleared",this.options.onSearchCleared)},i.prototype.setInitialStates=function(t,o){if(t.nodes){o+=1;var s=t,n=this;e.each(t.nodes,function(e,t){t.nodeId=n.nodes.length,t.parentId=s.nodeId,t.hasOwnProperty("selectable")||(t.selectable=!0),t.state=t.state||{},t.state.hasOwnProperty("checked")||(t.state.checked=!1),t.state.hasOwnProperty("disabled")||(t.state.disabled=!1),t.state.hasOwnProperty("expanded")||(!t.state.disabled&&o<n.options.levels&&t.nodes&&t.nodes.length>0?t.state.expanded=!0:t.state.expanded=!1),t.state.hasOwnProperty("selected")||(t.state.selected=!1),n.nodes.push(t),t.nodes&&n.setInitialStates(t,o)})}},i.prototype.clickHandler=function(t){this.options.enableLinks||t.preventDefault();var o=e(t.target),s=this.findNode(o);if(s&&!s.state.disabled){var i=o.attr("class")?o.attr("class").split(" "):[];-1!==i.indexOf("expand-icon")?(this.toggleExpandedState(s,n.options),this.render()):-1!==i.indexOf("check-icon")?(this.toggleCheckedState(s,n.options),this.render()):(s.selectable?this.toggleSelectedState(s,n.options):this.options.toggleUnselectable&&this.toggleExpandedState(s,n.options),this.render())}},i.prototype.findNode=function(e){var t=e.closest("li.list-group-item").attr("data-nodeid"),o=this.nodes[t];return o||console.log("Error: node does not exist"),o},i.prototype.toggleExpandedState=function(e,t){e&&this.setExpandedState(e,!e.state.expanded,t)},i.prototype.setExpandedState=function(t,o,s){o!==t.state.expanded&&(o&&t.nodes?(t.state.expanded=!0,s.silent||this.$element.trigger("nodeExpanded",e.extend(!0,{},t))):o||(t.state.expanded=!1,s.silent||this.$element.trigger("nodeCollapsed",e.extend(!0,{},t)),t.nodes&&!s.ignoreChildren&&e.each(t.nodes,e.proxy(function(e,t){this.setExpandedState(t,!1,s)},this))))},i.prototype.toggleSelectedState=function(e,t){e&&this.setSelectedState(e,!e.state.selected,t)},i.prototype.setSelectedState=function(t,o,s){o!==t.state.selected&&(o?(this.options.multiSelect||e.each(this.findNodes("true","g","state.selected"),e.proxy(function(e,t){this.setSelectedState(t,!1,s)},this)),t.state.selected=!0,s.silent||this.$element.trigger("nodeSelected",e.extend(!0,{},t))):(t.state.selected=!1,s.silent||this.$element.trigger("nodeUnselected",e.extend(!0,{},t))))},i.prototype.toggleCheckedState=function(e,t){e&&this.setCheckedState(e,!e.state.checked,t)},i.prototype.setCheckedState=function(t,o,s){o!==t.state.checked&&(o?(t.state.checked=!0,s.silent||this.$element.trigger("nodeChecked",e.extend(!0,{},t))):(t.state.checked=!1,s.silent||this.$element.trigger("nodeUnchecked",e.extend(!0,{},t))))},i.prototype.setDisabledState=function(t,o,s){o!==t.state.disabled&&(o?(t.state.disabled=!0,this.setExpandedState(t,!1,s),this.setSelectedState(t,!1,s),this.setCheckedState(t,!1,s),s.silent||this.$element.trigger("nodeDisabled",e.extend(!0,{},t))):(t.state.disabled=!1,s.silent||this.$element.trigger("nodeEnabled",e.extend(!0,{},t))))},i.prototype.render=function(){this.initialized||(this.$element.addClass("treeview"),this.$wrapper=e(this.template.list),this.injectStyle(),this.initialized=!0),this.$element.empty().append(this.$wrapper.empty()),this.buildTree(this.tree,0)},i.prototype.buildTree=function(t,o){if(t){o+=1;var s=this;e.each(t,function(t,n){for(var i=e(s.template.item).addClass("node-"+s.elementId).addClass(n.state.checked?"node-checked":"").addClass(n.state.disabled?"node-disabled":"").addClass(n.state.selected?"node-selected":"").addClass(n.searchResult?"search-result":"").attr("data-nodeid",n.nodeId).attr("style",s.buildStyleOverride(n)),d=0;d<o-1;d++)i.append(s.template.indent);r=[];if(n.nodes?(r.push("expand-icon"),n.state.expanded?r.push(s.options.collapseIcon):r.push(s.options.expandIcon)):r.push(s.options.emptyIcon),i.append(e(s.template.icon).addClass(r.join(" "))),s.options.showIcon&&((r=["node-icon"]).push(n.icon||s.options.nodeIcon),n.state.selected&&(r.pop(),r.push(n.selectedIcon||s.options.selectedIcon||n.icon||s.options.nodeIcon)),i.append(e(s.template.icon).addClass(r.join(" ")))),s.options.showCheckbox){var r=["check-icon"];n.state.checked?r.push(s.options.checkedIcon):r.push(s.options.uncheckedIcon),i.append(e(s.template.icon).addClass(r.join(" ")))}if(s.options.enableLinks?i.append(e(s.template.link).attr("href",n.href).append(n.text)):i.append(n.text),s.options.showTags&&n.tags&&e.each(n.tags,function(t,o){i.append(e(s.template.badge).append(o))}),s.$wrapper.append(i),n.nodes&&n.state.expanded&&!n.state.disabled)return s.buildTree(n.nodes,o)})}},i.prototype.buildStyleOverride=function(e){if(e.state.disabled)return"";var t=e.color,o=e.backColor;return e.selectable||(this.options.unselectableColor&&(t=this.options.unselectableColor),this.options.unselectableBackColor&&(o=this.options.unselectableBackColor)),this.options.highlightSelected&&e.state.selected&&(this.options.selectedColor&&(t=this.options.selectedColor),this.options.selectedBackColor&&(o=this.options.selectedBackColor)),this.options.highlightSearchResults&&e.searchResult&&!e.state.disabled&&(this.options.searchResultColor&&(t=this.options.searchResultColor),this.options.searchResultBackColor&&(o=this.options.searchResultBackColor)),"color:"+t+";background-color:"+o+";"},i.prototype.injectStyle=function(){this.options.injectStyle&&!o.getElementById(this.styleId)&&e('<style type="text/css" id="'+this.styleId+'"> '+this.buildStyle()+" </style>").appendTo("head")},i.prototype.buildStyle=function(){var e=".node-"+this.elementId+"{";return this.options.color&&(e+="color:"+this.options.color+";"),this.options.backColor&&(e+="background-color:"+this.options.backColor+";"),this.options.showBorder?this.options.borderColor&&(e+="border:1px solid "+this.options.borderColor+";"):e+="border:none;",e+="}",this.options.onhoverColor&&(e+=".node-"+this.elementId+":not(.node-disabled):hover{background-color:"+this.options.onhoverColor+";}"),this.css+e},i.prototype.template={list:'<ul class="list-group"></ul>',item:'<li class="list-group-item"></li>',indent:'<span class="indent"></span>',icon:'<span class="icon"></span>',link:'<a href="#" style="color:inherit;"></a>',badge:'<span class="badge"></span>'},i.prototype.css=".treeview .list-group-item{cursor:pointer}.treeview span.indent{margin-left:10px;margin-right:10px}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}",i.prototype.getNode=function(e){return this.nodes[e]},i.prototype.getParent=function(e){var t=this.identifyNode(e);return this.nodes[t.parentId]},i.prototype.getSiblings=function(e){var t=this.identifyNode(e),o=this.getParent(t);return(o?o.nodes:this.tree).filter(function(e){return e.nodeId!==t.nodeId})},i.prototype.getSelected=function(){return this.findNodes("true","g","state.selected")},i.prototype.getUnselected=function(){return this.findNodes("false","g","state.selected")},i.prototype.getExpanded=function(){return this.findNodes("true","g","state.expanded")},i.prototype.getCollapsed=function(){return this.findNodes("false","g","state.expanded")},i.prototype.getChecked=function(){return this.findNodes("true","g","state.checked")},i.prototype.getUnchecked=function(){return this.findNodes("false","g","state.checked")},i.prototype.getDisabled=function(){return this.findNodes("true","g","state.disabled")},i.prototype.getEnabled=function(){return this.findNodes("false","g","state.disabled")},i.prototype.selectNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setSelectedState(e,!0,t)},this)),this.render()},i.prototype.unselectNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setSelectedState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeSelected=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleSelectedState(e,t)},this)),this.render()},i.prototype.collapseAll=function(t){var o=this.findNodes("true","g","state.expanded");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setExpandedState(e,!1,t)},this)),this.render()},i.prototype.collapseNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setExpandedState(e,!1,t)},this)),this.render()},i.prototype.expandAll=function(t){if((t=e.extend({},n.options,t))&&t.levels)this.expandLevels(this.tree,t.levels,t);else{var o=this.findNodes("false","g","state.expanded");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setExpandedState(e,!0,t)},this))}this.render()},i.prototype.expandNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setExpandedState(e,!0,t),e.nodes&&t&&t.levels&&this.expandLevels(e.nodes,t.levels-1,t)},this)),this.render()},i.prototype.expandLevels=function(t,o,s){s=e.extend({},n.options,s),e.each(t,e.proxy(function(e,t){this.setExpandedState(t,o>0,s),t.nodes&&this.expandLevels(t.nodes,o-1,s)},this))},i.prototype.revealNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){for(var o=this.getParent(e);o;)this.setExpandedState(o,!0,t),o=this.getParent(o)},this)),this.render()},i.prototype.toggleNodeExpanded=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleExpandedState(e,t)},this)),this.render()},i.prototype.checkAll=function(t){var o=this.findNodes("false","g","state.checked");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setCheckedState(e,!0,t)},this)),this.render()},i.prototype.checkNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setCheckedState(e,!0,t)},this)),this.render()},i.prototype.uncheckAll=function(t){var o=this.findNodes("true","g","state.checked");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setCheckedState(e,!1,t)},this)),this.render()},i.prototype.uncheckNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setCheckedState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeChecked=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleCheckedState(e,t)},this)),this.render()},i.prototype.disableAll=function(t){var o=this.findNodes("false","g","state.disabled");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setDisabledState(e,!0,t)},this)),this.render()},i.prototype.disableNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!0,t)},this)),this.render()},i.prototype.enableAll=function(t){var o=this.findNodes("true","g","state.disabled");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setDisabledState(e,!1,t)},this)),this.render()},i.prototype.enableNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeDisabled=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!e.state.disabled,t)},this)),this.render()},i.prototype.forEachIdentifier=function(t,o,s){o=e.extend({},n.options,o),t instanceof Array||(t=[t]),e.each(t,e.proxy(function(e,t){s(this.identifyNode(t),o)},this))},i.prototype.identifyNode=function(e){return"number"==typeof e?this.nodes[e]:e},i.prototype.search=function(t,o){o=e.extend({},n.searchOptions,o),this.clearSearch({render:!1});var s=[];if(t&&t.length>0){o.exactMatch&&(t="^"+t+"$");var i="g";o.ignoreCase&&(i+="i"),s=this.findNodes(t,i),e.each(s,function(e,t){t.searchResult=!0})}return o.revealResults?this.revealNode(s):this.render(),this.$element.trigger("searchComplete",e.extend(!0,{},s)),s},i.prototype.clearSearch=function(t){t=e.extend({},{render:!0},t);var o=e.each(this.findNodes("true","g","searchResult"),function(e,t){t.searchResult=!1});t.render&&this.render(),this.$element.trigger("searchCleared",e.extend(!0,{},o))},i.prototype.findNodes=function(t,o,s){o=o||"g",s=s||"text";var n=this;return e.grep(this.nodes,function(e){var i=n.getNodeValue(e,s);if("string"==typeof i)return i.match(new RegExp(t,o))})},i.prototype.getNodeValue=function(e,t){var o=t.indexOf(".");if(o>0){var s=e[t.substring(0,o)],n=t.substring(o+1,t.length);return this.getNodeValue(s,n)}return e.hasOwnProperty(t)?e[t].toString():void 0};var d=function(e){t.console&&t.console.error(e)};e.fn.treeview=function(t,o){var s;return this.each(function(){var n=e.data(this,"treeview");"string"==typeof t?n?e.isFunction(n[t])&&"_"!==t.charAt(0)?(o instanceof Array||(o=[o]),s=n[t].apply(n,o)):d("No such method : "+t):d("Not initialized, can not call method : "+t):"boolean"==typeof t?s=n:e.data(this,"treeview",new i(this,e.extend(!0,{},t)))}),s||this}}(jQuery,window,document);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/jquery-dndupload.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,209 @@
+/* globals MyAMS */
+
+(function($, globals) {
+
+	'use strict';
+
+	$.dndupload = {
+		defaults: {
+			action: 'upload-files',
+			fieldname: 'files',
+			autosubmit: true
+		}
+	};
+
+	var ams = MyAMS;
+
+	var isAdvancedUpload = function() {
+		var div = document.createElement('div');
+		return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && ('FormData' in window) && ('FileReader' in window);
+	} ();
+
+	// Initialize upload form
+	function init(input, settings) {
+		$(input).each(function() {
+			var widget = $(this);
+			if (widget.data('ams-dndupload-initialiazed')) {
+				return;
+			}
+			settings = $.extend(true, {}, $.dndupload.defaults, settings);
+
+			var uploader = widget.get(0);
+			if (uploader.tagName !== 'FORM') {
+				widget.removeClass('dndupload')
+					  .html('<form action="{action}" method="POST" enctype="multipart/form-data" class="dndupload"></form>'.replace(/{action}/, settings.action));
+				widget = $('form', widget);
+			}
+			var template = '<div class="box__input">\n' +
+				'	<svg class="box__icon" xmlns="http://www.w3.org/2000/svg" width="50" height="43" viewBox="0 0 50 43">\n' +
+				'		<path d="M48.4 26.5c-.9 0-1.7.7-1.7 1.7v11.6h-43.3v-11.6c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v13.2c0 .9.7 1.7 1.7 1.7h46.7c.9 0 1.7-.7 1.7-1.7v-13.2c0-1-.7-1.7-1.7-1.7zm-24.5 6.1c.3.3.8.5 1.2.5.4 0 .9-.2 1.2-.5l10-11.6c.7-.7.7-1.7 0-2.4s-1.7-.7-2.4 0l-7.1 8.3v-25.3c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v25.3l-7.1-8.3c-.7-.7-1.7-.7-2.4 0s-.7 1.7 0 2.4l10 11.6z" />\n' +
+				'	</svg>\n' +
+				'	<input type="file" name="{label}" id="file" class="box__file" multiple="multiple"\n'.replace(/{label}/, settings.fieldname) +
+				'		   data-multiple-caption="{label}" />\n'.replace(/{label}/, ams.plugins.i18n.dndupload.FILES_SELECTED) +
+				'	<label for="file">\n' +
+				'		<strong>{label}</strong> {add}<br />\n'.replace(/{label}/, ams.plugins.i18n.dndupload.CHOOSE_FILE).replace(/{add}/, ams.plugins.i18n.dndupload.ADD_INFO) +
+				'		<span class="box__dragndrop">{label}</span></label>\n'.replace(/{label}/, ams.plugins.i18n.dndupload.DRAG_FILE) +
+				'	<button type="submit" class="box__button">{label}</button>\n'.replace(/{label}/, ams.plugins.i18n.dndupload.UPLOAD) +
+				'</div>\n' +
+				'<div class="box__uploading">{label}</div>\n'.replace(/{label}/, ams.plugins.i18n.dndupload.UPLOADING) +
+				'<div class="box__success">{label}\n'.replace(/{label}/, ams.plugins.i18n.dndupload.DONE) +
+				'	<a href=".?" class="box__restart" role="button">{label}</a>\n'.replace(/{label}/, ams.plugins.i18n.dndupload.UPLOAD_MORE) +
+				'</div>\n' +
+				'<div class="box__error">{label}<span></span>. \n'.replace(/{label}/, ams.plugins.i18n.dndupload.ERROR) +
+				'	<a href=".?" class="box__restart" role="button">{label}</a>\n'.replace(/{label}/, ams.plugins.i18n.dndupload.TRY_AGAIN) +
+				'</div>';
+			widget.html(template);
+
+			var form = widget,
+				input = form.find('input[type="file"]'),
+				label = form.find('label'),
+				error = form.find('.box__error span'),
+				restart = form.find('.box__restart'),
+				droppedFiles = false;
+
+			var showFiles = function(files) {
+				label.text(files.length > 1 ? (input.attr('data-multiple-caption') || '').replace(/{count}/, files.length) : files[0].name);
+			};
+
+			input.on('change', function(ev) {
+				showFiles(ev.target.files);
+				if (settings.autosubmit) {
+					form.trigger('submit');
+				}
+			});
+
+			if (isAdvancedUpload) {
+				form.addClass('has-advanced-upload')
+					.on('drag dragstart dragend dragover dragenter dragleave drop', function(ev) {
+						ev.preventDefault();
+						ev.stopPropagation();
+					})
+					.on('dragover dragenter', function() {
+						form.addClass('is-dragover');
+					})
+					.on('dragleave dragend drop', function() {
+						form.removeClass('is-dragover');
+					})
+					.on('drop', function(ev) {
+						droppedFiles = ev.originalEvent.dataTransfer.files;
+						showFiles(droppedFiles);
+						if (settings.autosubmit) {
+							form.trigger('submit');
+						}
+					});
+			}
+
+			form.on('submit', function(ev) {
+				if (form.hasClass('is-uploading')) {
+					return false;
+				}
+				form.addClass('is-uploading')
+					.removeClass('is-error');
+				if (isAdvancedUpload) {
+					ev.preventDefault();
+					var ajaxData = new FormData(form.get(0));
+					if (droppedFiles) {
+						$.each(droppedFiles, function(i, file) {
+							ajaxData.append(input.attr('name'), file);
+						});
+					}
+					$.ajax({
+						url: form.attr('action'),
+						type: form.attr('method'),
+						data: ajaxData,
+						dataType: 'json',
+						cache: false,
+						contentType: false,
+						processData: false,
+						success: function(data) {
+							if (typeof(data) === 'string') {
+								data = JSON.parse(data);
+							}
+							ams.ajax.handleJSON(data);
+						},
+						complete: function() {
+							form.removeClass('is-uploading');
+						}
+					});
+				} else {
+					var iframeName = 'uploadiframe_' + new Date().getTime(),
+						iframe = $('<iframe>').attr('name', iframeName)
+											  .attr('style', 'display: none')
+											  .appendTo($('body'));
+					form.attr('target', iframeName);
+					iframe.one('load', function() {
+						var data = JSON.parse(iframe.contents().find('body').text());
+						form.removeClass('is-uploading')
+							.addClass(data.success === true ? 'is-success' : 'is-error')
+							.removeAttr('target');
+						if (!data.success) {
+							error.text(data.error);
+						}
+						iframe.remove();
+					});
+				}
+			});
+
+			restart.on('click', function(ev) {
+				ev.preventDefault();
+				form.removeClass('is-error is-success');
+				input.trigger('click');
+			});
+
+			input.on('focus', function() {
+					input.addClass('has-focus');
+				}).on('blur', function() {
+					input.removeClass('has-focus');
+				});
+
+			$(uploader).removeClass('hidden');
+			widget.data('ams-dndupload-initialized', true);
+		});
+
+		return input;
+	}
+
+	function destroy(input) {
+
+	}
+
+	$.extend($.fn, {
+
+		dndupload: function(method, data) {
+
+			var input = $(this);
+
+			switch(method) {
+
+				case 'settings':
+					if (data === undefined) {
+						return input.data('dndupload-settings');
+					} else {
+						input.each(function() {
+							var settings = input.data('dndupload-settings') || {};
+							destroy($(this));
+							input.dndupload($.extend(true, settings, data));
+						});
+					}
+					return input;
+
+				case 'destroy':
+					input.each(function() {
+						destroy($(this));
+					});
+					return input;
+
+				default:
+					if (method !== 'create') {
+						data = method;
+					}
+					input.each(function() {
+						init($(this), data);
+					});
+					return input;
+			}
+		}
+
+	});
+
+})(jQuery, this);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/jquery-dndupload.min.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,1 @@
+!function(a,e){"use strict";function n(e,n){return a(e).each(function(){var e=a(this);if(!e.data("ams-dndupload-initialiazed")){n=a.extend(!0,{},a.dndupload.defaults,n);var t=e.get(0);"FORM"!==t.tagName&&(e.removeClass("dndupload").html('<form action="{action}" method="POST" enctype="multipart/form-data" class="dndupload"></form>'.replace(/{action}/,n.action)),e=a("form",e));var s='<div class="box__input">\n\t<svg class="box__icon" xmlns="http://www.w3.org/2000/svg" width="50" height="43" viewBox="0 0 50 43">\n\t\t<path d="M48.4 26.5c-.9 0-1.7.7-1.7 1.7v11.6h-43.3v-11.6c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v13.2c0 .9.7 1.7 1.7 1.7h46.7c.9 0 1.7-.7 1.7-1.7v-13.2c0-1-.7-1.7-1.7-1.7zm-24.5 6.1c.3.3.8.5 1.2.5.4 0 .9-.2 1.2-.5l10-11.6c.7-.7.7-1.7 0-2.4s-1.7-.7-2.4 0l-7.1 8.3v-25.3c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v25.3l-7.1-8.3c-.7-.7-1.7-.7-2.4 0s-.7 1.7 0 2.4l10 11.6z" />\n\t</svg>\n'+'\t<input type="file" name="{label}" id="file" class="box__file" multiple="multiple"\n'.replace(/{label}/,n.fieldname)+'\t\t   data-multiple-caption="{label}" />\n'.replace(/{label}/,l.plugins.i18n.dndupload.FILES_SELECTED)+'\t<label for="file">\n'+"\t\t<strong>{label}</strong> {add}<br />\n".replace(/{label}/,l.plugins.i18n.dndupload.CHOOSE_FILE).replace(/{add}/,l.plugins.i18n.dndupload.ADD_INFO)+'\t\t<span class="box__dragndrop">{label}</span></label>\n'.replace(/{label}/,l.plugins.i18n.dndupload.DRAG_FILE)+'\t<button type="submit" class="box__button">{label}</button>\n'.replace(/{label}/,l.plugins.i18n.dndupload.UPLOAD)+"</div>\n"+'<div class="box__uploading">{label}</div>\n'.replace(/{label}/,l.plugins.i18n.dndupload.UPLOADING)+'<div class="box__success">{label}\n'.replace(/{label}/,l.plugins.i18n.dndupload.DONE)+'\t<a href=".?" class="box__restart" role="button">{label}</a>\n'.replace(/{label}/,l.plugins.i18n.dndupload.UPLOAD_MORE)+"</div>\n"+'<div class="box__error">{label}<span></span>. \n'.replace(/{label}/,l.plugins.i18n.dndupload.ERROR)+'\t<a href=".?" class="box__restart" role="button">{label}</a>\n'.replace(/{label}/,l.plugins.i18n.dndupload.TRY_AGAIN)+"</div>";e.html(s);var i=e,o=i.find('input[type="file"]'),r=i.find("label"),u=i.find(".box__error span"),c=i.find(".box__restart"),p=!1,f=function(a){r.text(a.length>1?(o.attr("data-multiple-caption")||"").replace(/{count}/,a.length):a[0].name)};o.on("change",function(a){f(a.target.files),n.autosubmit&&i.trigger("submit")}),d&&i.addClass("has-advanced-upload").on("drag dragstart dragend dragover dragenter dragleave drop",function(a){a.preventDefault(),a.stopPropagation()}).on("dragover dragenter",function(){i.addClass("is-dragover")}).on("dragleave dragend drop",function(){i.removeClass("is-dragover")}).on("drop",function(a){p=a.originalEvent.dataTransfer.files,f(p),n.autosubmit&&i.trigger("submit")}),i.on("submit",function(e){if(i.hasClass("is-uploading"))return!1;if(i.addClass("is-uploading").removeClass("is-error"),d){e.preventDefault();var n=new FormData(i.get(0));p&&a.each(p,function(a,e){n.append(o.attr("name"),e)}),a.ajax({url:i.attr("action"),type:i.attr("method"),data:n,dataType:"json",cache:!1,contentType:!1,processData:!1,success:function(a){"string"==typeof a&&(a=JSON.parse(a)),l.ajax.handleJSON(a)},complete:function(){i.removeClass("is-uploading")}})}else{var t="uploadiframe_"+(new Date).getTime(),s=a("<iframe>").attr("name",t).attr("style","display: none").appendTo(a("body"));i.attr("target",t),s.one("load",function(){var a=JSON.parse(s.contents().find("body").text());i.removeClass("is-uploading").addClass(!0===a.success?"is-success":"is-error").removeAttr("target"),a.success||u.text(a.error),s.remove()})}}),c.on("click",function(a){a.preventDefault(),i.removeClass("is-error is-success"),o.trigger("click")}),o.on("focus",function(){o.addClass("has-focus")}).on("blur",function(){o.removeClass("has-focus")}),a(t).removeClass("hidden"),e.data("ams-dndupload-initialized",!0)}}),e}function t(a){}a.dndupload={defaults:{action:"upload-files",fieldname:"files",autosubmit:!0}};var l=MyAMS,d=function(){var a=document.createElement("div");return("draggable"in a||"ondragstart"in a&&"ondrop"in a)&&"FormData"in window&&"FileReader"in window}();a.extend(a.fn,{dndupload:function(e,l){var d=a(this);switch(e){case"settings":return void 0===l?d.data("dndupload-settings"):(d.each(function(){var e=d.data("dndupload-settings")||{};t(a(this)),d.dndupload(a.extend(!0,e,l))}),d);case"destroy":return d.each(function(){t(a(this))}),d;default:return"create"!==e&&(l=e),d.each(function(){n(a(this),l)}),d}}})}(jQuery);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/jquery-scrollto-2.1.2.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,210 @@
+/*!
+ * jQuery.scrollTo
+ * Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler
+ * Licensed under MIT
+ * https://github.com/flesler/jquery.scrollTo
+ * @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery
+ * @author Ariel Flesler
+ * @version 2.1.2
+ */
+;(function(factory) {
+	'use strict';
+	if (typeof define === 'function' && define.amd) {
+		// AMD
+		define(['jquery'], factory);
+	} else if (typeof module !== 'undefined' && module.exports) {
+		// CommonJS
+		module.exports = factory(require('jquery'));
+	} else {
+		// Global
+		factory(jQuery);
+	}
+})(function($) {
+	'use strict';
+
+	var $scrollTo = $.scrollTo = function(target, duration, settings) {
+		return $(window).scrollTo(target, duration, settings);
+	};
+
+	$scrollTo.defaults = {
+		axis:'xy',
+		duration: 0,
+		limit:true
+	};
+
+	function isWin(elem) {
+		return !elem.nodeName ||
+			$.inArray(elem.nodeName.toLowerCase(), ['iframe','#document','html','body']) !== -1;
+	}
+
+	$.fn.scrollTo = function(target, duration, settings) {
+		if (typeof duration === 'object') {
+			settings = duration;
+			duration = 0;
+		}
+		if (typeof settings === 'function') {
+			settings = { onAfter:settings };
+		}
+		if (target === 'max') {
+			target = 9e9;
+		}
+
+		settings = $.extend({}, $scrollTo.defaults, settings);
+		// Speed is still recognized for backwards compatibility
+		duration = duration || settings.duration;
+		// Make sure the settings are given right
+		var queue = settings.queue && settings.axis.length > 1;
+		if (queue) {
+			// Let's keep the overall duration
+			duration /= 2;
+		}
+		settings.offset = both(settings.offset);
+		settings.over = both(settings.over);
+
+		return this.each(function() {
+			// Null target yields nothing, just like jQuery does
+			if (target === null) return;
+
+			var win = isWin(this),
+				elem = win ? this.contentWindow || window : this,
+				$elem = $(elem),
+				targ = target,
+				attr = {},
+				toff;
+
+			switch (typeof targ) {
+				// A number will pass the regex
+				case 'number':
+				case 'string':
+					if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
+						targ = both(targ);
+						// We are done
+						break;
+					}
+					// Relative/Absolute selector
+					targ = win ? $(targ) : $(targ, elem);
+					/* falls through */
+				case 'object':
+					if (targ.length === 0) return;
+					// DOMElement / jQuery
+					if (targ.is || targ.style) {
+						// Get the real position of the target
+						toff = (targ = $(targ)).offset();
+					}
+			}
+
+			var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
+
+			$.each(settings.axis.split(''), function(i, axis) {
+				var Pos	= axis === 'x' ? 'Left' : 'Top',
+					pos = Pos.toLowerCase(),
+					key = 'scroll' + Pos,
+					prev = $elem[key](),
+					max = $scrollTo.max(elem, axis);
+
+				if (toff) {// jQuery / DOMElement
+					attr[key] = toff[pos] + (win ? 0 : prev - $elem.offset()[pos]);
+
+					// If it's a dom element, reduce the margin
+					if (settings.margin) {
+						attr[key] -= parseInt(targ.css('margin'+Pos), 10) || 0;
+						attr[key] -= parseInt(targ.css('border'+Pos+'Width'), 10) || 0;
+					}
+
+					attr[key] += offset[pos] || 0;
+
+					if (settings.over[pos]) {
+						// Scroll to a fraction of its width/height
+						attr[key] += targ[axis === 'x'?'width':'height']() * settings.over[pos];
+					}
+				} else {
+					var val = targ[pos];
+					// Handle percentage values
+					attr[key] = val.slice && val.slice(-1) === '%' ?
+						parseFloat(val) / 100 * max
+						: val;
+				}
+
+				// Number or 'number'
+				if (settings.limit && /^\d+$/.test(attr[key])) {
+					// Check the limits
+					attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
+				}
+
+				// Don't waste time animating, if there's no need.
+				if (!i && settings.axis.length > 1) {
+					if (prev === attr[key]) {
+						// No animation needed
+						attr = {};
+					} else if (queue) {
+						// Intermediate animation
+						animate(settings.onAfterFirst);
+						// Don't animate this axis again in the next iteration.
+						attr = {};
+					}
+				}
+			});
+
+			animate(settings.onAfter);
+
+			function animate(callback) {
+				var opts = $.extend({}, settings, {
+					// The queue setting conflicts with animate()
+					// Force it to always be true
+					queue: true,
+					duration: duration,
+					complete: callback && function() {
+						callback.call(elem, targ, settings);
+					}
+				});
+				$elem.animate(attr, opts);
+			}
+		});
+	};
+
+	// Max scrolling position, works on quirks mode
+	// It only fails (not too badly) on IE, quirks mode.
+	$scrollTo.max = function(elem, axis) {
+		var Dim = axis === 'x' ? 'Width' : 'Height',
+			scroll = 'scroll'+Dim;
+
+		if (!isWin(elem))
+			return elem[scroll] - $(elem)[Dim.toLowerCase()]();
+
+		var size = 'client' + Dim,
+			doc = elem.ownerDocument || elem.document,
+			html = doc.documentElement,
+			body = doc.body;
+
+		return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]);
+	};
+
+	function both(val) {
+		return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val };
+	}
+
+	// Add special hooks so that window scroll properties can be animated
+	$.Tween.propHooks.scrollLeft =
+	$.Tween.propHooks.scrollTop = {
+		get: function(t) {
+			return $(t.elem)[t.prop]();
+		},
+		set: function(t) {
+			var curr = this.get(t);
+			// If interrupt is true and user scrolled, stop animating
+			if (t.options.interrupt && t._last && t._last !== curr) {
+				return $(t.elem).stop();
+			}
+			var next = Math.round(t.now);
+			// Don't waste CPU
+			// Browsers don't render floating point scroll
+			if (curr !== next) {
+				$(t.elem)[t.prop](next);
+				t._last = this.get(t);
+			}
+		}
+	};
+
+	// AMD requirement
+	return $scrollTo;
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/jquery-scrollto-2.1.2.min.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,1 @@
+!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";function t(t){return!t.nodeName||-1!==e.inArray(t.nodeName.toLowerCase(),["iframe","#document","html","body"])}function o(t){return e.isFunction(t)||e.isPlainObject(t)?t:{top:t,left:t}}var n=e.scrollTo=function(t,o,n){return e(window).scrollTo(t,o,n)};return n.defaults={axis:"xy",duration:0,limit:!0},e.fn.scrollTo=function(r,i,s){"object"==typeof i&&(s=i,i=0),"function"==typeof s&&(s={onAfter:s}),"max"===r&&(r=9e9),s=e.extend({},n.defaults,s),i=i||s.duration;var a=s.queue&&s.axis.length>1;return a&&(i/=2),s.offset=o(s.offset),s.over=o(s.over),this.each(function(){function f(t){var o=e.extend({},s,{queue:!0,duration:i,complete:t&&function(){t.call(l,m,s)}});d.animate(p,o)}if(null!==r){var u,c=t(this),l=c?this.contentWindow||window:this,d=e(l),m=r,p={};switch(typeof m){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(m)){m=o(m);break}m=c?e(m):e(m,l);case"object":if(0===m.length)return;(m.is||m.style)&&(u=(m=e(m)).offset())}var h=e.isFunction(s.offset)&&s.offset(l,m)||s.offset;e.each(s.axis.split(""),function(e,t){var o="x"===t?"Left":"Top",r=o.toLowerCase(),i="scroll"+o,x=d[i](),v=n.max(l,t);if(u)p[i]=u[r]+(c?0:x-d.offset()[r]),s.margin&&(p[i]-=parseInt(m.css("margin"+o),10)||0,p[i]-=parseInt(m.css("border"+o+"Width"),10)||0),p[i]+=h[r]||0,s.over[r]&&(p[i]+=m["x"===t?"width":"height"]()*s.over[r]);else{var w=m[r];p[i]=w.slice&&"%"===w.slice(-1)?parseFloat(w)/100*v:w}s.limit&&/^\d+$/.test(p[i])&&(p[i]=p[i]<=0?0:Math.min(p[i],v)),!e&&s.axis.length>1&&(x===p[i]?p={}:a&&(f(s.onAfterFirst),p={}))}),f(s.onAfter)}})},n.max=function(o,n){var r="x"===n?"Width":"Height",i="scroll"+r;if(!t(o))return o[i]-e(o)[r.toLowerCase()]();var s="client"+r,a=o.ownerDocument||o.document,f=a.documentElement,u=a.body;return Math.max(f[i],u[i])-Math.min(f[s],u[s])},e.Tween.propHooks.scrollLeft=e.Tween.propHooks.scrollTop={get:function(t){return e(t.elem)[t.prop]()},set:function(t){var o=this.get(t);if(t.options.interrupt&&t._last&&t._last!==o)return e(t.elem).stop();var n=Math.round(t.now);o!==n&&(e(t.elem)[t.prop](n),t._last=this.get(t))}},n});
--- a/src/ztfy/myams/resources/js/ext/jquery-select2-3.5.2.js	Mon Jun 04 12:32:06 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3541 +0,0 @@
-/*
-Copyright 2012 Igor Vaynberg
-
-Version: 3.5.2 Timestamp: Sat Nov  1 14:43:36 EDT 2014
-
-This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
-General Public License version 2 (the "GPL License"). You may choose either license to govern your
-use of this software only upon the condition that you accept all of the terms of either the Apache
-License or the GPL License.
-
-You may obtain a copy of the Apache License and the GPL License at:
-
-    http://www.apache.org/licenses/LICENSE-2.0
-    http://www.gnu.org/licenses/gpl-2.0.html
-
-Unless required by applicable law or agreed to in writing, software distributed under the
-Apache License or the GPL License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the Apache License and the GPL License for
-the specific language governing permissions and limitations under the Apache License and the GPL License.
-*/
-(function ($) {
-    if(typeof $.fn.each2 == "undefined") {
-        $.extend($.fn, {
-            /*
-            * 4-10 times faster .each replacement
-            * use it carefully, as it overrides jQuery context of element on each iteration
-            */
-            each2 : function (c) {
-                var j = $([0]), i = -1, l = this.length;
-                while (
-                    ++i < l
-                    && (j.context = j[0] = this[i])
-                    && c.call(j[0], i, j) !== false //"this"=DOM, i=index, j=jQuery object
-                );
-                return this;
-            }
-        });
-    }
-})(jQuery);
-
-(function ($, undefined) {
-    "use strict";
-    /*global document, window, jQuery, console */
-
-    if (window.Select2 !== undefined) {
-        return;
-    }
-
-    var AbstractSelect2, SingleSelect2, MultiSelect2, nextUid, sizer,
-        lastMousePosition={x:0,y:0}, $document, scrollBarDimensions,
-
-    KEY = {
-        TAB: 9,
-        ENTER: 13,
-        ESC: 27,
-        SPACE: 32,
-        LEFT: 37,
-        UP: 38,
-        RIGHT: 39,
-        DOWN: 40,
-        SHIFT: 16,
-        CTRL: 17,
-        ALT: 18,
-        PAGE_UP: 33,
-        PAGE_DOWN: 34,
-        HOME: 36,
-        END: 35,
-        BACKSPACE: 8,
-        DELETE: 46,
-        isArrow: function (k) {
-            k = k.which ? k.which : k;
-            switch (k) {
-            case KEY.LEFT:
-            case KEY.RIGHT:
-            case KEY.UP:
-            case KEY.DOWN:
-                return true;
-            }
-            return false;
-        },
-        isControl: function (e) {
-            var k = e.which;
-            switch (k) {
-            case KEY.SHIFT:
-            case KEY.CTRL:
-            case KEY.ALT:
-                return true;
-            }
-
-            if (e.metaKey) return true;
-
-            return false;
-        },
-        isFunctionKey: function (k) {
-            k = k.which ? k.which : k;
-            return k >= 112 && k <= 123;
-        }
-    },
-    MEASURE_SCROLLBAR_TEMPLATE = "<div class='select2-measure-scrollbar'></div>",
-
-    DIACRITICS = {"\u24B6":"A","\uFF21":"A","\u00C0":"A","\u00C1":"A","\u00C2":"A","\u1EA6":"A","\u1EA4":"A","\u1EAA":"A","\u1EA8":"A","\u00C3":"A","\u0100":"A","\u0102":"A","\u1EB0":"A","\u1EAE":"A","\u1EB4":"A","\u1EB2":"A","\u0226":"A","\u01E0":"A","\u00C4":"A","\u01DE":"A","\u1EA2":"A","\u00C5":"A","\u01FA":"A","\u01CD":"A","\u0200":"A","\u0202":"A","\u1EA0":"A","\u1EAC":"A","\u1EB6":"A","\u1E00":"A","\u0104":"A","\u023A":"A","\u2C6F":"A","\uA732":"AA","\u00C6":"AE","\u01FC":"AE","\u01E2":"AE","\uA734":"AO","\uA736":"AU","\uA738":"AV","\uA73A":"AV","\uA73C":"AY","\u24B7":"B","\uFF22":"B","\u1E02":"B","\u1E04":"B","\u1E06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24B8":"C","\uFF23":"C","\u0106":"C","\u0108":"C","\u010A":"C","\u010C":"C","\u00C7":"C","\u1E08":"C","\u0187":"C","\u023B":"C","\uA73E":"C","\u24B9":"D","\uFF24":"D","\u1E0A":"D","\u010E":"D","\u1E0C":"D","\u1E10":"D","\u1E12":"D","\u1E0E":"D","\u0110":"D","\u018B":"D","\u018A":"D","\u0189":"D","\uA779":"D","\u01F1":"DZ","\u01C4":"DZ","\u01F2":"Dz","\u01C5":"Dz","\u24BA":"E","\uFF25":"E","\u00C8":"E","\u00C9":"E","\u00CA":"E","\u1EC0":"E","\u1EBE":"E","\u1EC4":"E","\u1EC2":"E","\u1EBC":"E","\u0112":"E","\u1E14":"E","\u1E16":"E","\u0114":"E","\u0116":"E","\u00CB":"E","\u1EBA":"E","\u011A":"E","\u0204":"E","\u0206":"E","\u1EB8":"E","\u1EC6":"E","\u0228":"E","\u1E1C":"E","\u0118":"E","\u1E18":"E","\u1E1A":"E","\u0190":"E","\u018E":"E","\u24BB":"F","\uFF26":"F","\u1E1E":"F","\u0191":"F","\uA77B":"F","\u24BC":"G","\uFF27":"G","\u01F4":"G","\u011C":"G","\u1E20":"G","\u011E":"G","\u0120":"G","\u01E6":"G","\u0122":"G","\u01E4":"G","\u0193":"G","\uA7A0":"G","\uA77D":"G","\uA77E":"G","\u24BD":"H","\uFF28":"H","\u0124":"H","\u1E22":"H","\u1E26":"H","\u021E":"H","\u1E24":"H","\u1E28":"H","\u1E2A":"H","\u0126":"H","\u2C67":"H","\u2C75":"H","\uA78D":"H","\u24BE":"I","\uFF29":"I","\u00CC":"I","\u00CD":"I","\u00CE":"I","\u0128":"I","\u012A":"I","\u012C":"I","\u0130":"I","\u00CF":"I","\u1E2E":"I","\u1EC8":"I","\u01CF":"I","\u0208":"I","\u020A":"I","\u1ECA":"I","\u012E":"I","\u1E2C":"I","\u0197":"I","\u24BF":"J","\uFF2A":"J","\u0134":"J","\u0248":"J","\u24C0":"K","\uFF2B":"K","\u1E30":"K","\u01E8":"K","\u1E32":"K","\u0136":"K","\u1E34":"K","\u0198":"K","\u2C69":"K","\uA740":"K","\uA742":"K","\uA744":"K","\uA7A2":"K","\u24C1":"L","\uFF2C":"L","\u013F":"L","\u0139":"L","\u013D":"L","\u1E36":"L","\u1E38":"L","\u013B":"L","\u1E3C":"L","\u1E3A":"L","\u0141":"L","\u023D":"L","\u2C62":"L","\u2C60":"L","\uA748":"L","\uA746":"L","\uA780":"L","\u01C7":"LJ","\u01C8":"Lj","\u24C2":"M","\uFF2D":"M","\u1E3E":"M","\u1E40":"M","\u1E42":"M","\u2C6E":"M","\u019C":"M","\u24C3":"N","\uFF2E":"N","\u01F8":"N","\u0143":"N","\u00D1":"N","\u1E44":"N","\u0147":"N","\u1E46":"N","\u0145":"N","\u1E4A":"N","\u1E48":"N","\u0220":"N","\u019D":"N","\uA790":"N","\uA7A4":"N","\u01CA":"NJ","\u01CB":"Nj","\u24C4":"O","\uFF2F":"O","\u00D2":"O","\u00D3":"O","\u00D4":"O","\u1ED2":"O","\u1ED0":"O","\u1ED6":"O","\u1ED4":"O","\u00D5":"O","\u1E4C":"O","\u022C":"O","\u1E4E":"O","\u014C":"O","\u1E50":"O","\u1E52":"O","\u014E":"O","\u022E":"O","\u0230":"O","\u00D6":"O","\u022A":"O","\u1ECE":"O","\u0150":"O","\u01D1":"O","\u020C":"O","\u020E":"O","\u01A0":"O","\u1EDC":"O","\u1EDA":"O","\u1EE0":"O","\u1EDE":"O","\u1EE2":"O","\u1ECC":"O","\u1ED8":"O","\u01EA":"O","\u01EC":"O","\u00D8":"O","\u01FE":"O","\u0186":"O","\u019F":"O","\uA74A":"O","\uA74C":"O","\u01A2":"OI","\uA74E":"OO","\u0222":"OU","\u24C5":"P","\uFF30":"P","\u1E54":"P","\u1E56":"P","\u01A4":"P","\u2C63":"P","\uA750":"P","\uA752":"P","\uA754":"P","\u24C6":"Q","\uFF31":"Q","\uA756":"Q","\uA758":"Q","\u024A":"Q","\u24C7":"R","\uFF32":"R","\u0154":"R","\u1E58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1E5A":"R","\u1E5C":"R","\u0156":"R","\u1E5E":"R","\u024C":"R","\u2C64":"R","\uA75A":"R","\uA7A6":"R","\uA782":"R","\u24C8":"S","\uFF33":"S","\u1E9E":"S","\u015A":"S","\u1E64":"S","\u015C":"S","\u1E60":"S","\u0160":"S","\u1E66":"S","\u1E62":"S","\u1E68":"S","\u0218":"S","\u015E":"S","\u2C7E":"S","\uA7A8":"S","\uA784":"S","\u24C9":"T","\uFF34":"T","\u1E6A":"T","\u0164":"T","\u1E6C":"T","\u021A":"T","\u0162":"T","\u1E70":"T","\u1E6E":"T","\u0166":"T","\u01AC":"T","\u01AE":"T","\u023E":"T","\uA786":"T","\uA728":"TZ","\u24CA":"U","\uFF35":"U","\u00D9":"U","\u00DA":"U","\u00DB":"U","\u0168":"U","\u1E78":"U","\u016A":"U","\u1E7A":"U","\u016C":"U","\u00DC":"U","\u01DB":"U","\u01D7":"U","\u01D5":"U","\u01D9":"U","\u1EE6":"U","\u016E":"U","\u0170":"U","\u01D3":"U","\u0214":"U","\u0216":"U","\u01AF":"U","\u1EEA":"U","\u1EE8":"U","\u1EEE":"U","\u1EEC":"U","\u1EF0":"U","\u1EE4":"U","\u1E72":"U","\u0172":"U","\u1E76":"U","\u1E74":"U","\u0244":"U","\u24CB":"V","\uFF36":"V","\u1E7C":"V","\u1E7E":"V","\u01B2":"V","\uA75E":"V","\u0245":"V","\uA760":"VY","\u24CC":"W","\uFF37":"W","\u1E80":"W","\u1E82":"W","\u0174":"W","\u1E86":"W","\u1E84":"W","\u1E88":"W","\u2C72":"W","\u24CD":"X","\uFF38":"X","\u1E8A":"X","\u1E8C":"X","\u24CE":"Y","\uFF39":"Y","\u1EF2":"Y","\u00DD":"Y","\u0176":"Y","\u1EF8":"Y","\u0232":"Y","\u1E8E":"Y","\u0178":"Y","\u1EF6":"Y","\u1EF4":"Y","\u01B3":"Y","\u024E":"Y","\u1EFE":"Y","\u24CF":"Z","\uFF3A":"Z","\u0179":"Z","\u1E90":"Z","\u017B":"Z","\u017D":"Z","\u1E92":"Z","\u1E94":"Z","\u01B5":"Z","\u0224":"Z","\u2C7F":"Z","\u2C6B":"Z","\uA762":"Z","\u24D0":"a","\uFF41":"a","\u1E9A":"a","\u00E0":"a","\u00E1":"a","\u00E2":"a","\u1EA7":"a","\u1EA5":"a","\u1EAB":"a","\u1EA9":"a","\u00E3":"a","\u0101":"a","\u0103":"a","\u1EB1":"a","\u1EAF":"a","\u1EB5":"a","\u1EB3":"a","\u0227":"a","\u01E1":"a","\u00E4":"a","\u01DF":"a","\u1EA3":"a","\u00E5":"a","\u01FB":"a","\u01CE":"a","\u0201":"a","\u0203":"a","\u1EA1":"a","\u1EAD":"a","\u1EB7":"a","\u1E01":"a","\u0105":"a","\u2C65":"a","\u0250":"a","\uA733":"aa","\u00E6":"ae","\u01FD":"ae","\u01E3":"ae","\uA735":"ao","\uA737":"au","\uA739":"av","\uA73B":"av","\uA73D":"ay","\u24D1":"b","\uFF42":"b","\u1E03":"b","\u1E05":"b","\u1E07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24D2":"c","\uFF43":"c","\u0107":"c","\u0109":"c","\u010B":"c","\u010D":"c","\u00E7":"c","\u1E09":"c","\u0188":"c","\u023C":"c","\uA73F":"c","\u2184":"c","\u24D3":"d","\uFF44":"d","\u1E0B":"d","\u010F":"d","\u1E0D":"d","\u1E11":"d","\u1E13":"d","\u1E0F":"d","\u0111":"d","\u018C":"d","\u0256":"d","\u0257":"d","\uA77A":"d","\u01F3":"dz","\u01C6":"dz","\u24D4":"e","\uFF45":"e","\u00E8":"e","\u00E9":"e","\u00EA":"e","\u1EC1":"e","\u1EBF":"e","\u1EC5":"e","\u1EC3":"e","\u1EBD":"e","\u0113":"e","\u1E15":"e","\u1E17":"e","\u0115":"e","\u0117":"e","\u00EB":"e","\u1EBB":"e","\u011B":"e","\u0205":"e","\u0207":"e","\u1EB9":"e","\u1EC7":"e","\u0229":"e","\u1E1D":"e","\u0119":"e","\u1E19":"e","\u1E1B":"e","\u0247":"e","\u025B":"e","\u01DD":"e","\u24D5":"f","\uFF46":"f","\u1E1F":"f","\u0192":"f","\uA77C":"f","\u24D6":"g","\uFF47":"g","\u01F5":"g","\u011D":"g","\u1E21":"g","\u011F":"g","\u0121":"g","\u01E7":"g","\u0123":"g","\u01E5":"g","\u0260":"g","\uA7A1":"g","\u1D79":"g","\uA77F":"g","\u24D7":"h","\uFF48":"h","\u0125":"h","\u1E23":"h","\u1E27":"h","\u021F":"h","\u1E25":"h","\u1E29":"h","\u1E2B":"h","\u1E96":"h","\u0127":"h","\u2C68":"h","\u2C76":"h","\u0265":"h","\u0195":"hv","\u24D8":"i","\uFF49":"i","\u00EC":"i","\u00ED":"i","\u00EE":"i","\u0129":"i","\u012B":"i","\u012D":"i","\u00EF":"i","\u1E2F":"i","\u1EC9":"i","\u01D0":"i","\u0209":"i","\u020B":"i","\u1ECB":"i","\u012F":"i","\u1E2D":"i","\u0268":"i","\u0131":"i","\u24D9":"j","\uFF4A":"j","\u0135":"j","\u01F0":"j","\u0249":"j","\u24DA":"k","\uFF4B":"k","\u1E31":"k","\u01E9":"k","\u1E33":"k","\u0137":"k","\u1E35":"k","\u0199":"k","\u2C6A":"k","\uA741":"k","\uA743":"k","\uA745":"k","\uA7A3":"k","\u24DB":"l","\uFF4C":"l","\u0140":"l","\u013A":"l","\u013E":"l","\u1E37":"l","\u1E39":"l","\u013C":"l","\u1E3D":"l","\u1E3B":"l","\u017F":"l","\u0142":"l","\u019A":"l","\u026B":"l","\u2C61":"l","\uA749":"l","\uA781":"l","\uA747":"l","\u01C9":"lj","\u24DC":"m","\uFF4D":"m","\u1E3F":"m","\u1E41":"m","\u1E43":"m","\u0271":"m","\u026F":"m","\u24DD":"n","\uFF4E":"n","\u01F9":"n","\u0144":"n","\u00F1":"n","\u1E45":"n","\u0148":"n","\u1E47":"n","\u0146":"n","\u1E4B":"n","\u1E49":"n","\u019E":"n","\u0272":"n","\u0149":"n","\uA791":"n","\uA7A5":"n","\u01CC":"nj","\u24DE":"o","\uFF4F":"o","\u00F2":"o","\u00F3":"o","\u00F4":"o","\u1ED3":"o","\u1ED1":"o","\u1ED7":"o","\u1ED5":"o","\u00F5":"o","\u1E4D":"o","\u022D":"o","\u1E4F":"o","\u014D":"o","\u1E51":"o","\u1E53":"o","\u014F":"o","\u022F":"o","\u0231":"o","\u00F6":"o","\u022B":"o","\u1ECF":"o","\u0151":"o","\u01D2":"o","\u020D":"o","\u020F":"o","\u01A1":"o","\u1EDD":"o","\u1EDB":"o","\u1EE1":"o","\u1EDF":"o","\u1EE3":"o","\u1ECD":"o","\u1ED9":"o","\u01EB":"o","\u01ED":"o","\u00F8":"o","\u01FF":"o","\u0254":"o","\uA74B":"o","\uA74D":"o","\u0275":"o","\u01A3":"oi","\u0223":"ou","\uA74F":"oo","\u24DF":"p","\uFF50":"p","\u1E55":"p","\u1E57":"p","\u01A5":"p","\u1D7D":"p","\uA751":"p","\uA753":"p","\uA755":"p","\u24E0":"q","\uFF51":"q","\u024B":"q","\uA757":"q","\uA759":"q","\u24E1":"r","\uFF52":"r","\u0155":"r","\u1E59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1E5B":"r","\u1E5D":"r","\u0157":"r","\u1E5F":"r","\u024D":"r","\u027D":"r","\uA75B":"r","\uA7A7":"r","\uA783":"r","\u24E2":"s","\uFF53":"s","\u00DF":"s","\u015B":"s","\u1E65":"s","\u015D":"s","\u1E61":"s","\u0161":"s","\u1E67":"s","\u1E63":"s","\u1E69":"s","\u0219":"s","\u015F":"s","\u023F":"s","\uA7A9":"s","\uA785":"s","\u1E9B":"s","\u24E3":"t","\uFF54":"t","\u1E6B":"t","\u1E97":"t","\u0165":"t","\u1E6D":"t","\u021B":"t","\u0163":"t","\u1E71":"t","\u1E6F":"t","\u0167":"t","\u01AD":"t","\u0288":"t","\u2C66":"t","\uA787":"t","\uA729":"tz","\u24E4":"u","\uFF55":"u","\u00F9":"u","\u00FA":"u","\u00FB":"u","\u0169":"u","\u1E79":"u","\u016B":"u","\u1E7B":"u","\u016D":"u","\u00FC":"u","\u01DC":"u","\u01D8":"u","\u01D6":"u","\u01DA":"u","\u1EE7":"u","\u016F":"u","\u0171":"u","\u01D4":"u","\u0215":"u","\u0217":"u","\u01B0":"u","\u1EEB":"u","\u1EE9":"u","\u1EEF":"u","\u1EED":"u","\u1EF1":"u","\u1EE5":"u","\u1E73":"u","\u0173":"u","\u1E77":"u","\u1E75":"u","\u0289":"u","\u24E5":"v","\uFF56":"v","\u1E7D":"v","\u1E7F":"v","\u028B":"v","\uA75F":"v","\u028C":"v","\uA761":"vy","\u24E6":"w","\uFF57":"w","\u1E81":"w","\u1E83":"w","\u0175":"w","\u1E87":"w","\u1E85":"w","\u1E98":"w","\u1E89":"w","\u2C73":"w","\u24E7":"x","\uFF58":"x","\u1E8B":"x","\u1E8D":"x","\u24E8":"y","\uFF59":"y","\u1EF3":"y","\u00FD":"y","\u0177":"y","\u1EF9":"y","\u0233":"y","\u1E8F":"y","\u00FF":"y","\u1EF7":"y","\u1E99":"y","\u1EF5":"y","\u01B4":"y","\u024F":"y","\u1EFF":"y","\u24E9":"z","\uFF5A":"z","\u017A":"z","\u1E91":"z","\u017C":"z","\u017E":"z","\u1E93":"z","\u1E95":"z","\u01B6":"z","\u0225":"z","\u0240":"z","\u2C6C":"z","\uA763":"z","\u0386":"\u0391","\u0388":"\u0395","\u0389":"\u0397","\u038A":"\u0399","\u03AA":"\u0399","\u038C":"\u039F","\u038E":"\u03A5","\u03AB":"\u03A5","\u038F":"\u03A9","\u03AC":"\u03B1","\u03AD":"\u03B5","\u03AE":"\u03B7","\u03AF":"\u03B9","\u03CA":"\u03B9","\u0390":"\u03B9","\u03CC":"\u03BF","\u03CD":"\u03C5","\u03CB":"\u03C5","\u03B0":"\u03C5","\u03C9":"\u03C9","\u03C2":"\u03C3"};
-
-    $document = $(document);
-
-    nextUid=(function() { var counter=1; return function() { return counter++; }; }());
-
-
-    function reinsertElement(element) {
-        var placeholder = $(document.createTextNode(''));
-
-        element.before(placeholder);
-        placeholder.before(element);
-        placeholder.remove();
-    }
-
-    function stripDiacritics(str) {
-        // Used 'uni range + named function' from http://jsperf.com/diacritics/18
-        function match(a) {
-            return DIACRITICS[a] || a;
-        }
-
-        return str.replace(/[^\u0000-\u007E]/g, match);
-    }
-
-    function indexOf(value, array) {
-        var i = 0, l = array.length;
-        for (; i < l; i = i + 1) {
-            if (equal(value, array[i])) return i;
-        }
-        return -1;
-    }
-
-    function measureScrollbar () {
-        var $template = $( MEASURE_SCROLLBAR_TEMPLATE );
-        $template.appendTo(document.body);
-
-        var dim = {
-            width: $template.width() - $template[0].clientWidth,
-            height: $template.height() - $template[0].clientHeight
-        };
-        $template.remove();
-
-        return dim;
-    }
-
-    /**
-     * Compares equality of a and b
-     * @param a
-     * @param b
-     */
-    function equal(a, b) {
-        if (a === b) return true;
-        if (a === undefined || b === undefined) return false;
-        if (a === null || b === null) return false;
-        // Check whether 'a' or 'b' is a string (primitive or object).
-        // The concatenation of an empty string (+'') converts its argument to a string's primitive.
-        if (a.constructor === String) return a+'' === b+''; // a+'' - in case 'a' is a String object
-        if (b.constructor === String) return b+'' === a+''; // b+'' - in case 'b' is a String object
-        return false;
-    }
-
-    /**
-     * Splits the string into an array of values, transforming each value. An empty array is returned for nulls or empty
-     * strings
-     * @param string
-     * @param separator
-     */
-    function splitVal(string, separator, transform) {
-        var val, i, l;
-        if (string === null || string.length < 1) return [];
-        val = string.split(separator);
-        for (i = 0, l = val.length; i < l; i = i + 1) val[i] = transform(val[i]);
-        return val;
-    }
-
-    function getSideBorderPadding(element) {
-        return element.outerWidth(false) - element.width();
-    }
-
-    function installKeyUpChangeEvent(element) {
-        var key="keyup-change-value";
-        element.on("keydown", function () {
-            if ($.data(element, key) === undefined) {
-                $.data(element, key, element.val());
-            }
-        });
-        element.on("keyup", function () {
-            var val= $.data(element, key);
-            if (val !== undefined && element.val() !== val) {
-                $.removeData(element, key);
-                element.trigger("keyup-change");
-            }
-        });
-    }
-
-
-    /**
-     * filters mouse events so an event is fired only if the mouse moved.
-     *
-     * filters out mouse events that occur when mouse is stationary but
-     * the elements under the pointer are scrolled.
-     */
-    function installFilteredMouseMove(element) {
-        element.on("mousemove", function (e) {
-            var lastpos = lastMousePosition;
-            if (lastpos === undefined || lastpos.x !== e.pageX || lastpos.y !== e.pageY) {
-                $(e.target).trigger("mousemove-filtered", e);
-            }
-        });
-    }
-
-    /**
-     * Debounces a function. Returns a function that calls the original fn function only if no invocations have been made
-     * within the last quietMillis milliseconds.
-     *
-     * @param quietMillis number of milliseconds to wait before invoking fn
-     * @param fn function to be debounced
-     * @param ctx object to be used as this reference within fn
-     * @return debounced version of fn
-     */
-    function debounce(quietMillis, fn, ctx) {
-        ctx = ctx || undefined;
-        var timeout;
-        return function () {
-            var args = arguments;
-            window.clearTimeout(timeout);
-            timeout = window.setTimeout(function() {
-                fn.apply(ctx, args);
-            }, quietMillis);
-        };
-    }
-
-    function installDebouncedScroll(threshold, element) {
-        var notify = debounce(threshold, function (e) { element.trigger("scroll-debounced", e);});
-        element.on("scroll", function (e) {
-            if (indexOf(e.target, element.get()) >= 0) notify(e);
-        });
-    }
-
-    function focus($el) {
-        if ($el[0] === document.activeElement) return;
-
-        /* set the focus in a 0 timeout - that way the focus is set after the processing
-            of the current event has finished - which seems like the only reliable way
-            to set focus */
-        window.setTimeout(function() {
-            var el=$el[0], pos=$el.val().length, range;
-
-            $el.focus();
-
-            /* make sure el received focus so we do not error out when trying to manipulate the caret.
-                sometimes modals or others listeners may steal it after its set */
-            var isVisible = (el.offsetWidth > 0 || el.offsetHeight > 0);
-            if (isVisible && el === document.activeElement) {
-
-                /* after the focus is set move the caret to the end, necessary when we val()
-                    just before setting focus */
-                if(el.setSelectionRange)
-                {
-                    el.setSelectionRange(pos, pos);
-                }
-                else if (el.createTextRange) {
-                    range = el.createTextRange();
-                    range.collapse(false);
-                    range.select();
-                }
-            }
-        }, 0);
-    }
-
-    function getCursorInfo(el) {
-        el = $(el)[0];
-        var offset = 0;
-        var length = 0;
-        if ('selectionStart' in el) {
-            offset = el.selectionStart;
-            length = el.selectionEnd - offset;
-        } else if ('selection' in document) {
-            el.focus();
-            var sel = document.selection.createRange();
-            length = document.selection.createRange().text.length;
-            sel.moveStart('character', -el.value.length);
-            offset = sel.text.length - length;
-        }
-        return { offset: offset, length: length };
-    }
-
-    function killEvent(event) {
-        event.preventDefault();
-        event.stopPropagation();
-    }
-    function killEventImmediately(event) {
-        event.preventDefault();
-        event.stopImmediatePropagation();
-    }
-
-    function measureTextWidth(e) {
-        if (!sizer){
-            var style = e[0].currentStyle || window.getComputedStyle(e[0], null);
-            sizer = $(document.createElement("div")).css({
-                position: "absolute",
-                left: "-10000px",
-                top: "-10000px",
-                display: "none",
-                fontSize: style.fontSize,
-                fontFamily: style.fontFamily,
-                fontStyle: style.fontStyle,
-                fontWeight: style.fontWeight,
-                letterSpacing: style.letterSpacing,
-                textTransform: style.textTransform,
-                whiteSpace: "nowrap"
-            });
-            sizer.attr("class","select2-sizer");
-            $(document.body).append(sizer);
-        }
-        sizer.text(e.val());
-        return sizer.width();
-    }
-
-    function syncCssClasses(dest, src, adapter) {
-        var classes, replacements = [], adapted;
-
-        classes = $.trim(dest.attr("class"));
-
-        if (classes) {
-            classes = '' + classes; // for IE which returns object
-
-            $(classes.split(/\s+/)).each2(function() {
-                if (this.indexOf("select2-") === 0) {
-                    replacements.push(this);
-                }
-            });
-        }
-
-        classes = $.trim(src.attr("class"));
-
-        if (classes) {
-            classes = '' + classes; // for IE which returns object
-
-            $(classes.split(/\s+/)).each2(function() {
-                if (this.indexOf("select2-") !== 0) {
-                    adapted = adapter(this);
-
-                    if (adapted) {
-                        replacements.push(adapted);
-                    }
-                }
-            });
-        }
-
-        dest.attr("class", replacements.join(" "));
-    }
-
-
-    function markMatch(text, term, markup, escapeMarkup) {
-        var match=stripDiacritics(text.toUpperCase()).indexOf(stripDiacritics(term.toUpperCase())),
-            tl=term.length;
-
-        if (match<0) {
-            markup.push(escapeMarkup(text));
-            return;
-        }
-
-        markup.push(escapeMarkup(text.substring(0, match)));
-        markup.push("<span class='select2-match'>");
-        markup.push(escapeMarkup(text.substring(match, match + tl)));
-        markup.push("</span>");
-        markup.push(escapeMarkup(text.substring(match + tl, text.length)));
-    }
-
-    function defaultEscapeMarkup(markup) {
-        var replace_map = {
-            '\\': '&#92;',
-            '&': '&amp;',
-            '<': '&lt;',
-            '>': '&gt;',
-            '"': '&quot;',
-            "'": '&#39;',
-            "/": '&#47;'
-        };
-
-        return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
-            return replace_map[match];
-        });
-    }
-
-    /**
-     * Produces an ajax-based query function
-     *
-     * @param options object containing configuration parameters
-     * @param options.params parameter map for the transport ajax call, can contain such options as cache, jsonpCallback, etc. see $.ajax
-     * @param options.transport function that will be used to execute the ajax request. must be compatible with parameters supported by $.ajax
-     * @param options.url url for the data
-     * @param options.data a function(searchTerm, pageNumber, context) that should return an object containing query string parameters for the above url.
-     * @param options.dataType request data type: ajax, jsonp, other datatypes supported by jQuery's $.ajax function or the transport function if specified
-     * @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often
-     * @param options.results a function(remoteData, pageNumber, query) that converts data returned form the remote request to the format expected by Select2.
-     *      The expected format is an object containing the following keys:
-     *      results array of objects that will be used as choices
-     *      more (optional) boolean indicating whether there are more results available
-     *      Example: {results:[{id:1, text:'Red'},{id:2, text:'Blue'}], more:true}
-     */
-    function ajax(options) {
-        var timeout, // current scheduled but not yet executed request
-            handler = null,
-            quietMillis = options.quietMillis || 100,
-            ajaxUrl = options.url,
-            self = this;
-
-        return function (query) {
-            window.clearTimeout(timeout);
-            timeout = window.setTimeout(function () {
-                var data = options.data, // ajax data function
-                    url = ajaxUrl, // ajax url string or function
-                    transport = options.transport || $.fn.select2.ajaxDefaults.transport,
-                    // deprecated - to be removed in 4.0  - use params instead
-                    deprecated = {
-                        type: options.type || 'GET', // set type of request (GET or POST)
-                        cache: options.cache || false,
-                        jsonpCallback: options.jsonpCallback||undefined,
-                        dataType: options.dataType||"json"
-                    },
-                    params = $.extend({}, $.fn.select2.ajaxDefaults.params, deprecated);
-
-                data = data ? data.call(self, query.term, query.page, query.context) : null;
-                url = (typeof url === 'function') ? url.call(self, query.term, query.page, query.context) : url;
-
-                if (handler && typeof handler.abort === "function") { handler.abort(); }
-
-                if (options.params) {
-                    if ($.isFunction(options.params)) {
-                        $.extend(params, options.params.call(self));
-                    } else {
-                        $.extend(params, options.params);
-                    }
-                }
-
-                $.extend(params, {
-                    url: url,
-                    dataType: options.dataType,
-                    data: data,
-                    success: function (data) {
-                        // TODO - replace query.page with query so users have access to term, page, etc.
-                        // added query as third paramter to keep backwards compatibility
-                        var results = options.results(data, query.page, query);
-                        query.callback(results);
-                    },
-                    error: function(jqXHR, textStatus, errorThrown){
-                        var results = {
-                            hasError: true,
-                            jqXHR: jqXHR,
-                            textStatus: textStatus,
-                            errorThrown: errorThrown
-                        };
-
-                        query.callback(results);
-                    }
-                });
-                handler = transport.call(self, params);
-            }, quietMillis);
-        };
-    }
-
-    /**
-     * Produces a query function that works with a local array
-     *
-     * @param options object containing configuration parameters. The options parameter can either be an array or an
-     * object.
-     *
-     * If the array form is used it is assumed that it contains objects with 'id' and 'text' keys.
-     *
-     * If the object form is used it is assumed that it contains 'data' and 'text' keys. The 'data' key should contain
-     * an array of objects that will be used as choices. These objects must contain at least an 'id' key. The 'text'
-     * key can either be a String in which case it is expected that each element in the 'data' array has a key with the
-     * value of 'text' which will be used to match choices. Alternatively, text can be a function(item) that can extract
-     * the text.
-     */
-    function local(options) {
-        var data = options, // data elements
-            dataText,
-            tmp,
-            text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
-
-         if ($.isArray(data)) {
-            tmp = data;
-            data = { results: tmp };
-        }
-
-         if ($.isFunction(data) === false) {
-            tmp = data;
-            data = function() { return tmp; };
-        }
-
-        var dataItem = data();
-        if (dataItem.text) {
-            text = dataItem.text;
-            // if text is not a function we assume it to be a key name
-            if (!$.isFunction(text)) {
-                dataText = dataItem.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available
-                text = function (item) { return item[dataText]; };
-            }
-        }
-
-        return function (query) {
-            var t = query.term, filtered = { results: [] }, process;
-            if (t === "") {
-                query.callback(data());
-                return;
-            }
-
-            process = function(datum, collection) {
-                var group, attr;
-                datum = datum[0];
-                if (datum.children) {
-                    group = {};
-                    for (attr in datum) {
-                        if (datum.hasOwnProperty(attr)) group[attr]=datum[attr];
-                    }
-                    group.children=[];
-                    $(datum.children).each2(function(i, childDatum) { process(childDatum, group.children); });
-                    if (group.children.length || query.matcher(t, text(group), datum)) {
-                        collection.push(group);
-                    }
-                } else {
-                    if (query.matcher(t, text(datum), datum)) {
-                        collection.push(datum);
-                    }
-                }
-            };
-
-            $(data().results).each2(function(i, datum) { process(datum, filtered.results); });
-            query.callback(filtered);
-        };
-    }
-
-    // TODO javadoc
-    function tags(data) {
-        var isFunc = $.isFunction(data);
-        return function (query) {
-            var t = query.term, filtered = {results: []};
-            var result = isFunc ? data(query) : data;
-            if ($.isArray(result)) {
-                $(result).each(function () {
-                    var isObject = this.text !== undefined,
-                        text = isObject ? this.text : this;
-                    if (t === "" || query.matcher(t, text)) {
-                        filtered.results.push(isObject ? this : {id: this, text: this});
-                    }
-                });
-                query.callback(filtered);
-            }
-        };
-    }
-
-    /**
-     * Checks if the formatter function should be used.
-     *
-     * Throws an error if it is not a function. Returns true if it should be used,
-     * false if no formatting should be performed.
-     *
-     * @param formatter
-     */
-    function checkFormatter(formatter, formatterName) {
-        if ($.isFunction(formatter)) return true;
-        if (!formatter) return false;
-        if (typeof(formatter) === 'string') return true;
-        throw new Error(formatterName +" must be a string, function, or falsy value");
-    }
-
-  /**
-   * Returns a given value
-   * If given a function, returns its output
-   *
-   * @param val string|function
-   * @param context value of "this" to be passed to function
-   * @returns {*}
-   */
-    function evaluate(val, context) {
-        if ($.isFunction(val)) {
-            var args = Array.prototype.slice.call(arguments, 2);
-            return val.apply(context, args);
-        }
-        return val;
-    }
-
-    function countResults(results) {
-        var count = 0;
-        $.each(results, function(i, item) {
-            if (item.children) {
-                count += countResults(item.children);
-            } else {
-                count++;
-            }
-        });
-        return count;
-    }
-
-    /**
-     * Default tokenizer. This function uses breaks the input on substring match of any string from the
-     * opts.tokenSeparators array and uses opts.createSearchChoice to create the choice object. Both of those
-     * two options have to be defined in order for the tokenizer to work.
-     *
-     * @param input text user has typed so far or pasted into the search field
-     * @param selection currently selected choices
-     * @param selectCallback function(choice) callback tho add the choice to selection
-     * @param opts select2's opts
-     * @return undefined/null to leave the current input unchanged, or a string to change the input to the returned value
-     */
-    function defaultTokenizer(input, selection, selectCallback, opts) {
-        var original = input, // store the original so we can compare and know if we need to tell the search to update its text
-            dupe = false, // check for whether a token we extracted represents a duplicate selected choice
-            token, // token
-            index, // position at which the separator was found
-            i, l, // looping variables
-            separator; // the matched separator
-
-        if (!opts.createSearchChoice || !opts.tokenSeparators || opts.tokenSeparators.length < 1) return undefined;
-
-        while (true) {
-            index = -1;
-
-            for (i = 0, l = opts.tokenSeparators.length; i < l; i++) {
-                separator = opts.tokenSeparators[i];
-                index = input.indexOf(separator);
-                if (index >= 0) break;
-            }
-
-            if (index < 0) break; // did not find any token separator in the input string, bail
-
-            token = input.substring(0, index);
-            input = input.substring(index + separator.length);
-
-            if (token.length > 0) {
-                token = opts.createSearchChoice.call(this, token, selection);
-                if (token !== undefined && token !== null && opts.id(token) !== undefined && opts.id(token) !== null) {
-                    dupe = false;
-                    for (i = 0, l = selection.length; i < l; i++) {
-                        if (equal(opts.id(token), opts.id(selection[i]))) {
-                            dupe = true; break;
-                        }
-                    }
-
-                    if (!dupe) selectCallback(token);
-                }
-            }
-        }
-
-        if (original!==input) return input;
-    }
-
-    function cleanupJQueryElements() {
-        var self = this;
-
-        $.each(arguments, function (i, element) {
-            self[element].remove();
-            self[element] = null;
-        });
-    }
-
-    /**
-     * Creates a new class
-     *
-     * @param superClass
-     * @param methods
-     */
-    function clazz(SuperClass, methods) {
-        var constructor = function () {};
-        constructor.prototype = new SuperClass;
-        constructor.prototype.constructor = constructor;
-        constructor.prototype.parent = SuperClass.prototype;
-        constructor.prototype = $.extend(constructor.prototype, methods);
-        return constructor;
-    }
-
-    AbstractSelect2 = clazz(Object, {
-
-        // abstract
-        bind: function (func) {
-            var self = this;
-            return function () {
-                func.apply(self, arguments);
-            };
-        },
-
-        // abstract
-        init: function (opts) {
-            var results, search, resultsSelector = ".select2-results";
-
-            // prepare options
-            this.opts = opts = this.prepareOpts(opts);
-
-            this.id=opts.id;
-
-            // destroy if called on an existing component
-            if (opts.element.data("select2") !== undefined &&
-                opts.element.data("select2") !== null) {
-                opts.element.data("select2").destroy();
-            }
-
-            this.container = this.createContainer();
-
-            this.liveRegion = $('.select2-hidden-accessible');
-            if (this.liveRegion.length == 0) {
-                this.liveRegion = $("<span>", {
-                        role: "status",
-                        "aria-live": "polite"
-                    })
-                    .addClass("select2-hidden-accessible")
-                    .appendTo(document.body);
-            }
-
-            this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid());
-            this.containerEventName= this.containerId
-                .replace(/([.])/g, '_')
-                .replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
-            this.container.attr("id", this.containerId);
-
-            this.container.attr("title", opts.element.attr("title"));
-
-            this.body = $(document.body);
-
-            syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
-
-            this.container.attr("style", opts.element.attr("style"));
-            this.container.css(evaluate(opts.containerCss, this.opts.element));
-            this.container.addClass(evaluate(opts.containerCssClass, this.opts.element));
-
-            this.elementTabIndex = this.opts.element.attr("tabindex");
-
-            // swap container for the element
-            this.opts.element
-                .data("select2", this)
-                .attr("tabindex", "-1")
-                .before(this.container)
-                .on("click.select2", killEvent); // do not leak click events
-
-            this.container.data("select2", this);
-
-            this.dropdown = this.container.find(".select2-drop");
-
-            syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
-
-            this.dropdown.addClass(evaluate(opts.dropdownCssClass, this.opts.element));
-            this.dropdown.data("select2", this);
-            this.dropdown.on("click", killEvent);
-
-            this.results = results = this.container.find(resultsSelector);
-            this.search = search = this.container.find("input.select2-input");
-
-            this.queryCount = 0;
-            this.resultsPage = 0;
-            this.context = null;
-
-            // initialize the container
-            this.initContainer();
-
-            this.container.on("click", killEvent);
-
-            installFilteredMouseMove(this.results);
-
-            this.dropdown.on("mousemove-filtered", resultsSelector, this.bind(this.highlightUnderEvent));
-            this.dropdown.on("touchstart touchmove touchend", resultsSelector, this.bind(function (event) {
-                this._touchEvent = true;
-                this.highlightUnderEvent(event);
-            }));
-            this.dropdown.on("touchmove", resultsSelector, this.bind(this.touchMoved));
-            this.dropdown.on("touchstart touchend", resultsSelector, this.bind(this.clearTouchMoved));
-
-            // Waiting for a click event on touch devices to select option and hide dropdown
-            // otherwise click will be triggered on an underlying element
-            this.dropdown.on('click', this.bind(function (event) {
-                if (this._touchEvent) {
-                    this._touchEvent = false;
-                    this.selectHighlighted();
-                }
-            }));
-
-            installDebouncedScroll(80, this.results);
-            this.dropdown.on("scroll-debounced", resultsSelector, this.bind(this.loadMoreIfNeeded));
-
-            // do not propagate change event from the search field out of the component
-            $(this.container).on("change", ".select2-input", function(e) {e.stopPropagation();});
-            $(this.dropdown).on("change", ".select2-input", function(e) {e.stopPropagation();});
-
-            // if jquery.mousewheel plugin is installed we can prevent out-of-bounds scrolling of results via mousewheel
-            if ($.fn.mousewheel) {
-                results.mousewheel(function (e, delta, deltaX, deltaY) {
-                    var top = results.scrollTop();
-                    if (deltaY > 0 && top - deltaY <= 0) {
-                        results.scrollTop(0);
-                        killEvent(e);
-                    } else if (deltaY < 0 && results.get(0).scrollHeight - results.scrollTop() + deltaY <= results.height()) {
-                        results.scrollTop(results.get(0).scrollHeight - results.height());
-                        killEvent(e);
-                    }
-                });
-            }
-
-            installKeyUpChangeEvent(search);
-            search.on("keyup-change input paste", this.bind(this.updateResults));
-            search.on("focus", function () { search.addClass("select2-focused"); });
-            search.on("blur", function () { search.removeClass("select2-focused");});
-
-            this.dropdown.on("mouseup", resultsSelector, this.bind(function (e) {
-                if ($(e.target).closest(".select2-result-selectable").length > 0) {
-                    this.highlightUnderEvent(e);
-                    this.selectHighlighted(e);
-                }
-            }));
-
-            // trap all mouse events from leaving the dropdown. sometimes there may be a modal that is listening
-            // for mouse events outside of itself so it can close itself. since the dropdown is now outside the select2's
-            // dom it will trigger the popup close, which is not what we want
-            // focusin can cause focus wars between modals and select2 since the dropdown is outside the modal.
-            this.dropdown.on("click mouseup mousedown touchstart touchend focusin", function (e) { e.stopPropagation(); });
-
-            this.nextSearchTerm = undefined;
-
-            if ($.isFunction(this.opts.initSelection)) {
-                // initialize selection based on the current value of the source element
-                this.initSelection();
-
-                // if the user has provided a function that can set selection based on the value of the source element
-                // we monitor the change event on the element and trigger it, allowing for two way synchronization
-                this.monitorSource();
-            }
-
-            if (opts.maximumInputLength !== null) {
-                this.search.attr("maxlength", opts.maximumInputLength);
-            }
-
-            var disabled = opts.element.prop("disabled");
-            if (disabled === undefined) disabled = false;
-            this.enable(!disabled);
-
-            var readonly = opts.element.prop("readonly");
-            if (readonly === undefined) readonly = false;
-            this.readonly(readonly);
-
-            // Calculate size of scrollbar
-            scrollBarDimensions = scrollBarDimensions || measureScrollbar();
-
-            this.autofocus = opts.element.prop("autofocus");
-            opts.element.prop("autofocus", false);
-            if (this.autofocus) this.focus();
-
-            this.search.attr("placeholder", opts.searchInputPlaceholder);
-        },
-
-        // abstract
-        destroy: function () {
-            var element=this.opts.element, select2 = element.data("select2"), self = this;
-
-            this.close();
-
-            if (element.length && element[0].detachEvent && self._sync) {
-                element.each(function () {
-                    if (self._sync) {
-                        this.detachEvent("onpropertychange", self._sync);
-                    }
-                });
-            }
-            if (this.propertyObserver) {
-                this.propertyObserver.disconnect();
-                this.propertyObserver = null;
-            }
-            this._sync = null;
-
-            if (select2 !== undefined) {
-                select2.container.remove();
-                select2.liveRegion.remove();
-                select2.dropdown.remove();
-                element
-                    .show()
-                    .removeData("select2")
-                    .off(".select2")
-                    .prop("autofocus", this.autofocus || false);
-                if (this.elementTabIndex) {
-                    element.attr({tabindex: this.elementTabIndex});
-                } else {
-                    element.removeAttr("tabindex");
-                }
-                element.show();
-            }
-
-            cleanupJQueryElements.call(this,
-                "container",
-                "liveRegion",
-                "dropdown",
-                "results",
-                "search"
-            );
-        },
-
-        // abstract
-        optionToData: function(element) {
-            if (element.is("option")) {
-                return {
-                    id:element.prop("value"),
-                    text:element.text(),
-                    element: element.get(),
-                    css: element.attr("class"),
-                    disabled: element.prop("disabled"),
-                    locked: equal(element.attr("locked"), "locked") || equal(element.data("locked"), true)
-                };
-            } else if (element.is("optgroup")) {
-                return {
-                    text:element.attr("label"),
-                    children:[],
-                    element: element.get(),
-                    css: element.attr("class")
-                };
-            }
-        },
-
-        // abstract
-        prepareOpts: function (opts) {
-            var element, select, idKey, ajaxUrl, self = this;
-
-            element = opts.element;
-
-            if (element.get(0).tagName.toLowerCase() === "select") {
-                this.select = select = opts.element;
-            }
-
-            if (select) {
-                // these options are not allowed when attached to a select because they are picked up off the element itself
-                $.each(["id", "multiple", "ajax", "query", "createSearchChoice", "initSelection", "data", "tags"], function () {
-                    if (this in opts) {
-                        throw new Error("Option '" + this + "' is not allowed for Select2 when attached to a <select> element.");
-                    }
-                });
-            }
-
-            opts = $.extend({}, {
-                populateResults: function(container, results, query) {
-                    var populate, id=this.opts.id, liveRegion=this.liveRegion;
-
-                    populate=function(results, container, depth) {
-
-                        var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted;
-
-                        results = opts.sortResults(results, container, query);
-
-                        // collect the created nodes for bulk append
-                        var nodes = [];
-                        for (i = 0, l = results.length; i < l; i = i + 1) {
-
-                            result=results[i];
-
-                            disabled = (result.disabled === true);
-                            selectable = (!disabled) && (id(result) !== undefined);
-
-                            compound=result.children && result.children.length > 0;
-
-                            node=$("<li></li>");
-                            node.addClass("select2-results-dept-"+depth);
-                            node.addClass("select2-result");
-                            node.addClass(selectable ? "select2-result-selectable" : "select2-result-unselectable");
-                            if (disabled) { node.addClass("select2-disabled"); }
-                            if (compound) { node.addClass("select2-result-with-children"); }
-                            node.addClass(self.opts.formatResultCssClass(result));
-                            node.attr("role", "presentation");
-
-                            label=$(document.createElement("div"));
-                            label.addClass("select2-result-label");
-                            label.attr("id", "select2-result-label-" + nextUid());
-                            label.attr("role", "option");
-
-                            formatted=opts.formatResult(result, label, query, self.opts.escapeMarkup);
-                            if (formatted!==undefined) {
-                                label.html(formatted);
-                                node.append(label);
-                            }
-
-
-                            if (compound) {
-
-                                innerContainer=$("<ul></ul>");
-                                innerContainer.addClass("select2-result-sub");
-                                populate(result.children, innerContainer, depth+1);
-                                node.append(innerContainer);
-                            }
-
-                            node.data("select2-data", result);
-                            nodes.push(node[0]);
-                        }
-
-                        // bulk append the created nodes
-                        container.append(nodes);
-                        liveRegion.text(opts.formatMatches(results.length));
-                    };
-
-                    populate(results, container, 0);
-                }
-            }, $.fn.select2.defaults, opts);
-
-            if (typeof(opts.id) !== "function") {
-                idKey = opts.id;
-                opts.id = function (e) { return e[idKey]; };
-            }
-
-            if ($.isArray(opts.element.data("select2Tags"))) {
-                if ("tags" in opts) {
-                    throw "tags specified as both an attribute 'data-select2-tags' and in options of Select2 " + opts.element.attr("id");
-                }
-                opts.tags=opts.element.data("select2Tags");
-            }
-
-            if (select) {
-                opts.query = this.bind(function (query) {
-                    var data = { results: [], more: false },
-                        term = query.term,
-                        children, placeholderOption, process;
-
-                    process=function(element, collection) {
-                        var group;
-                        if (element.is("option")) {
-                            if (query.matcher(term, element.text(), element)) {
-                                collection.push(self.optionToData(element));
-                            }
-                        } else if (element.is("optgroup")) {
-                            group=self.optionToData(element);
-                            element.children().each2(function(i, elm) { process(elm, group.children); });
-                            if (group.children.length>0) {
-                                collection.push(group);
-                            }
-                        }
-                    };
-
-                    children=element.children();
-
-                    // ignore the placeholder option if there is one
-                    if (this.getPlaceholder() !== undefined && children.length > 0) {
-                        placeholderOption = this.getPlaceholderOption();
-                        if (placeholderOption) {
-                            children=children.not(placeholderOption);
-                        }
-                    }
-
-                    children.each2(function(i, elm) { process(elm, data.results); });
-
-                    query.callback(data);
-                });
-                // this is needed because inside val() we construct choices from options and their id is hardcoded
-                opts.id=function(e) { return e.id; };
-            } else {
-                if (!("query" in opts)) {
-
-                    if ("ajax" in opts) {
-                        ajaxUrl = opts.element.data("ajax-url");
-                        if (ajaxUrl && ajaxUrl.length > 0) {
-                            opts.ajax.url = ajaxUrl;
-                        }
-                        opts.query = ajax.call(opts.element, opts.ajax);
-                    } else if ("data" in opts) {
-                        opts.query = local(opts.data);
-                    } else if ("tags" in opts) {
-                        opts.query = tags(opts.tags);
-                        if (opts.createSearchChoice === undefined) {
-                            opts.createSearchChoice = function (term) { return {id: $.trim(term), text: $.trim(term)}; };
-                        }
-                        if (opts.initSelection === undefined) {
-                            opts.initSelection = function (element, callback) {
-                                var data = [];
-                                $(splitVal(element.val(), opts.separator, opts.transformVal)).each(function () {
-                                    var obj = { id: this, text: this },
-                                        tags = opts.tags;
-                                    if ($.isFunction(tags)) tags=tags();
-                                    $(tags).each(function() { if (equal(this.id, obj.id)) { obj = this; return false; } });
-                                    data.push(obj);
-                                });
-
-                                callback(data);
-                            };
-                        }
-                    }
-                }
-            }
-            if (typeof(opts.query) !== "function") {
-                throw "query function not defined for Select2 " + opts.element.attr("id");
-            }
-
-            if (opts.createSearchChoicePosition === 'top') {
-                opts.createSearchChoicePosition = function(list, item) { list.unshift(item); };
-            }
-            else if (opts.createSearchChoicePosition === 'bottom') {
-                opts.createSearchChoicePosition = function(list, item) { list.push(item); };
-            }
-            else if (typeof(opts.createSearchChoicePosition) !== "function")  {
-                throw "invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";
-            }
-
-            return opts;
-        },
-
-        /**
-         * Monitor the original element for changes and update select2 accordingly
-         */
-        // abstract
-        monitorSource: function () {
-            var el = this.opts.element, observer, self = this;
-
-            el.on("change.select2", this.bind(function (e) {
-                if (this.opts.element.data("select2-change-triggered") !== true) {
-                    this.initSelection();
-                }
-            }));
-
-            this._sync = this.bind(function () {
-
-                // sync enabled state
-                var disabled = el.prop("disabled");
-                if (disabled === undefined) disabled = false;
-                this.enable(!disabled);
-
-                var readonly = el.prop("readonly");
-                if (readonly === undefined) readonly = false;
-                this.readonly(readonly);
-
-                if (this.container) {
-                    syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
-                    this.container.addClass(evaluate(this.opts.containerCssClass, this.opts.element));
-                }
-
-                if (this.dropdown) {
-                    syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
-                    this.dropdown.addClass(evaluate(this.opts.dropdownCssClass, this.opts.element));
-                }
-
-            });
-
-            // IE8-10 (IE9/10 won't fire propertyChange via attachEventListener)
-            if (el.length && el[0].attachEvent) {
-                el.each(function() {
-                    this.attachEvent("onpropertychange", self._sync);
-                });
-            }
-
-            // safari, chrome, firefox, IE11
-            observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver;
-            if (observer !== undefined) {
-                if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
-                this.propertyObserver = new observer(function (mutations) {
-                    $.each(mutations, self._sync);
-                });
-                this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
-            }
-        },
-
-        // abstract
-        triggerSelect: function(data) {
-            var evt = $.Event("select2-selecting", { val: this.id(data), object: data, choice: data });
-            this.opts.element.trigger(evt);
-            return !evt.isDefaultPrevented();
-        },
-
-        /**
-         * Triggers the change event on the source element
-         */
-        // abstract
-        triggerChange: function (details) {
-
-            details = details || {};
-            details= $.extend({}, details, { type: "change", val: this.val() });
-            // prevents recursive triggering
-            this.opts.element.data("select2-change-triggered", true);
-            this.opts.element.trigger(details);
-            this.opts.element.data("select2-change-triggered", false);
-
-            // some validation frameworks ignore the change event and listen instead to keyup, click for selects
-            // so here we trigger the click event manually
-            this.opts.element.click();
-
-            // ValidationEngine ignores the change event and listens instead to blur
-            // so here we trigger the blur event manually if so desired
-            if (this.opts.blurOnChange)
-                this.opts.element.blur();
-        },
-
-        //abstract
-        isInterfaceEnabled: function()
-        {
-            return this.enabledInterface === true;
-        },
-
-        // abstract
-        enableInterface: function() {
-            var enabled = this._enabled && !this._readonly,
-                disabled = !enabled;
-
-            if (enabled === this.enabledInterface) return false;
-
-            this.container.toggleClass("select2-container-disabled", disabled);
-            this.close();
-            this.enabledInterface = enabled;
-
-            return true;
-        },
-
-        // abstract
-        enable: function(enabled) {
-            if (enabled === undefined) enabled = true;
-            if (this._enabled === enabled) return;
-            this._enabled = enabled;
-
-            this.opts.element.prop("disabled", !enabled);
-            this.enableInterface();
-        },
-
-        // abstract
-        disable: function() {
-            this.enable(false);
-        },
-
-        // abstract
-        readonly: function(enabled) {
-            if (enabled === undefined) enabled = false;
-            if (this._readonly === enabled) return;
-            this._readonly = enabled;
-
-            this.opts.element.prop("readonly", enabled);
-            this.enableInterface();
-        },
-
-        // abstract
-        opened: function () {
-            return (this.container) ? this.container.hasClass("select2-dropdown-open") : false;
-        },
-
-        // abstract
-        positionDropdown: function() {
-            var $dropdown = this.dropdown,
-                container = this.container,
-                offset = container.offset(),
-                height = container.outerHeight(false),
-                width = container.outerWidth(false),
-                dropHeight = $dropdown.outerHeight(false),
-                $window = $(window),
-                windowWidth = $window.width(),
-                windowHeight = $window.height(),
-                viewPortRight = $window.scrollLeft() + windowWidth,
-                viewportBottom = $window.scrollTop() + windowHeight,
-                dropTop = offset.top + height,
-                dropLeft = offset.left,
-                enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
-                enoughRoomAbove = (offset.top - dropHeight) >= $window.scrollTop(),
-                dropWidth = $dropdown.outerWidth(false),
-                enoughRoomOnRight = function() {
-                    return dropLeft + dropWidth <= viewPortRight;
-                },
-                enoughRoomOnLeft = function() {
-                    return offset.left + viewPortRight + container.outerWidth(false)  > dropWidth;
-                },
-                aboveNow = $dropdown.hasClass("select2-drop-above"),
-                bodyOffset,
-                above,
-                changeDirection,
-                css,
-                resultsListNode;
-
-            // always prefer the current above/below alignment, unless there is not enough room
-            if (aboveNow) {
-                above = true;
-                if (!enoughRoomAbove && enoughRoomBelow) {
-                    changeDirection = true;
-                    above = false;
-                }
-            } else {
-                above = false;
-                if (!enoughRoomBelow && enoughRoomAbove) {
-                    changeDirection = true;
-                    above = true;
-                }
-            }
-
-            //if we are changing direction we need to get positions when dropdown is hidden;
-            if (changeDirection) {
-                $dropdown.hide();
-                offset = this.container.offset();
-                height = this.container.outerHeight(false);
-                width = this.container.outerWidth(false);
-                dropHeight = $dropdown.outerHeight(false);
-                viewPortRight = $window.scrollLeft() + windowWidth;
-                viewportBottom = $window.scrollTop() + windowHeight;
-                dropTop = offset.top + height;
-                dropLeft = offset.left;
-                dropWidth = $dropdown.outerWidth(false);
-                $dropdown.show();
-
-                // fix so the cursor does not move to the left within the search-textbox in IE
-                this.focusSearch();
-            }
-
-            if (this.opts.dropdownAutoWidth) {
-                resultsListNode = $('.select2-results', $dropdown)[0];
-                $dropdown.addClass('select2-drop-auto-width');
-                $dropdown.css('width', '');
-                // Add scrollbar width to dropdown if vertical scrollbar is present
-                dropWidth = $dropdown.outerWidth(false) + (resultsListNode.scrollHeight === resultsListNode.clientHeight ? 0 : scrollBarDimensions.width);
-                dropWidth > width ? width = dropWidth : dropWidth = width;
-                dropHeight = $dropdown.outerHeight(false);
-            }
-            else {
-                this.container.removeClass('select2-drop-auto-width');
-            }
-
-            //console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
-            //console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body.scrollTop(), "enough?", enoughRoomAbove);
-
-            // fix positioning when body has an offset and is not position: static
-            if (this.body.css('position') !== 'static') {
-                bodyOffset = this.body.offset();
-                dropTop -= bodyOffset.top;
-                dropLeft -= bodyOffset.left;
-            }
-
-            if (!enoughRoomOnRight() && enoughRoomOnLeft()) {
-                dropLeft = offset.left + this.container.outerWidth(false) - dropWidth;
-            }
-
-            css =  {
-                left: dropLeft,
-                width: width
-            };
-
-            if (above) {
-                css.top = offset.top - dropHeight;
-                css.bottom = 'auto';
-                this.container.addClass("select2-drop-above");
-                $dropdown.addClass("select2-drop-above");
-            }
-            else {
-                css.top = dropTop;
-                css.bottom = 'auto';
-                this.container.removeClass("select2-drop-above");
-                $dropdown.removeClass("select2-drop-above");
-            }
-            css = $.extend(css, evaluate(this.opts.dropdownCss, this.opts.element));
-
-            $dropdown.css(css);
-        },
-
-        // abstract
-        shouldOpen: function() {
-            var event;
-
-            if (this.opened()) return false;
-
-            if (this._enabled === false || this._readonly === true) return false;
-
-            event = $.Event("select2-opening");
-            this.opts.element.trigger(event);
-            return !event.isDefaultPrevented();
-        },
-
-        // abstract
-        clearDropdownAlignmentPreference: function() {
-            // clear the classes used to figure out the preference of where the dropdown should be opened
-            this.container.removeClass("select2-drop-above");
-            this.dropdown.removeClass("select2-drop-above");
-        },
-
-        /**
-         * Opens the dropdown
-         *
-         * @return {Boolean} whether or not dropdown was opened. This method will return false if, for example,
-         * the dropdown is already open, or if the 'open' event listener on the element called preventDefault().
-         */
-        // abstract
-        open: function () {
-
-            if (!this.shouldOpen()) return false;
-
-            this.opening();
-
-            // Only bind the document mousemove when the dropdown is visible
-            $document.on("mousemove.select2Event", function (e) {
-                lastMousePosition.x = e.pageX;
-                lastMousePosition.y = e.pageY;
-            });
-
-            return true;
-        },
-
-        /**
-         * Performs the opening of the dropdown
-         */
-        // abstract
-        opening: function() {
-            var cid = this.containerEventName,
-                scroll = "scroll." + cid,
-                resize = "resize."+cid,
-                orient = "orientationchange."+cid,
-                mask;
-
-            this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
-
-            this.clearDropdownAlignmentPreference();
-
-            if(this.dropdown[0] !== this.body.children().last()[0]) {
-                this.dropdown.detach().appendTo(this.body);
-            }
-
-            // create the dropdown mask if doesn't already exist
-            mask = $("#select2-drop-mask");
-            if (mask.length === 0) {
-                mask = $(document.createElement("div"));
-                mask.attr("id","select2-drop-mask").attr("class","select2-drop-mask");
-                mask.hide();
-                mask.appendTo(this.body);
-                mask.on("mousedown touchstart click", function (e) {
-                    // Prevent IE from generating a click event on the body
-                    reinsertElement(mask);
-
-                    var dropdown = $("#select2-drop"), self;
-                    if (dropdown.length > 0) {
-                        self=dropdown.data("select2");
-                        if (self.opts.selectOnBlur) {
-                            self.selectHighlighted({noFocus: true});
-                        }
-                        self.close();
-                        e.preventDefault();
-                        e.stopPropagation();
-                    }
-                });
-            }
-
-            // ensure the mask is always right before the dropdown
-            if (this.dropdown.prev()[0] !== mask[0]) {
-                this.dropdown.before(mask);
-            }
-
-            // move the global id to the correct dropdown
-            $("#select2-drop").removeAttr("id");
-            this.dropdown.attr("id", "select2-drop");
-
-            // show the elements
-            mask.show();
-
-            this.positionDropdown();
-            this.dropdown.show();
-            this.positionDropdown();
-
-            this.dropdown.addClass("select2-drop-active");
-
-            // attach listeners to events that can change the position of the container and thus require
-            // the position of the dropdown to be updated as well so it does not come unglued from the container
-            var that = this;
-            this.container.parents().add(window).each(function () {
-                $(this).on(resize+" "+scroll+" "+orient, function (e) {
-                    if (that.opened()) that.positionDropdown();
-                });
-            });
-
-
-        },
-
-        // abstract
-        close: function () {
-            if (!this.opened()) return;
-
-            var cid = this.containerEventName,
-                scroll = "scroll." + cid,
-                resize = "resize."+cid,
-                orient = "orientationchange."+cid;
-
-            // unbind event listeners
-            this.container.parents().add(window).each(function () { $(this).off(scroll).off(resize).off(orient); });
-
-            this.clearDropdownAlignmentPreference();
-
-            $("#select2-drop-mask").hide();
-            this.dropdown.removeAttr("id"); // only the active dropdown has the select2-drop id
-            this.dropdown.hide();
-            this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");
-            this.results.empty();
-
-            // Now that the dropdown is closed, unbind the global document mousemove event
-            $document.off("mousemove.select2Event");
-
-            this.clearSearch();
-            this.search.removeClass("select2-active");
-            this.opts.element.trigger($.Event("select2-close"));
-        },
-
-        /**
-         * Opens control, sets input value, and updates results.
-         */
-        // abstract
-        externalSearch: function (term) {
-            this.open();
-            this.search.val(term);
-            this.updateResults(false);
-        },
-
-        // abstract
-        clearSearch: function () {
-
-        },
-
-        //abstract
-        getMaximumSelectionSize: function() {
-            return evaluate(this.opts.maximumSelectionSize, this.opts.element);
-        },
-
-        // abstract
-        ensureHighlightVisible: function () {
-            var results = this.results, children, index, child, hb, rb, y, more, topOffset;
-
-            index = this.highlight();
-
-            if (index < 0) return;
-
-            if (index == 0) {
-
-                // if the first element is highlighted scroll all the way to the top,
-                // that way any unselectable headers above it will also be scrolled
-                // into view
-
-                results.scrollTop(0);
-                return;
-            }
-
-            children = this.findHighlightableChoices().find('.select2-result-label');
-
-            child = $(children[index]);
-
-            topOffset = (child.offset() || {}).top || 0;
-
-            hb = topOffset + child.outerHeight(true);
-
-            // if this is the last child lets also make sure select2-more-results is visible
-            if (index === children.length - 1) {
-                more = results.find("li.select2-more-results");
-                if (more.length > 0) {
-                    hb = more.offset().top + more.outerHeight(true);
-                }
-            }
-
-            rb = results.offset().top + results.outerHeight(false);
-            if (hb > rb) {
-                results.scrollTop(results.scrollTop() + (hb - rb));
-            }
-            y = topOffset - results.offset().top;
-
-            // make sure the top of the element is visible
-            if (y < 0 && child.css('display') != 'none' ) {
-                results.scrollTop(results.scrollTop() + y); // y is negative
-            }
-        },
-
-        // abstract
-        findHighlightableChoices: function() {
-            return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)");
-        },
-
-        // abstract
-        moveHighlight: function (delta) {
-            var choices = this.findHighlightableChoices(),
-                index = this.highlight();
-
-            while (index > -1 && index < choices.length) {
-                index += delta;
-                var choice = $(choices[index]);
-                if (choice.hasClass("select2-result-selectable") && !choice.hasClass("select2-disabled") && !choice.hasClass("select2-selected")) {
-                    this.highlight(index);
-                    break;
-                }
-            }
-        },
-
-        // abstract
-        highlight: function (index) {
-            var choices = this.findHighlightableChoices(),
-                choice,
-                data;
-
-            if (arguments.length === 0) {
-                return indexOf(choices.filter(".select2-highlighted")[0], choices.get());
-            }
-
-            if (index >= choices.length) index = choices.length - 1;
-            if (index < 0) index = 0;
-
-            this.removeHighlight();
-
-            choice = $(choices[index]);
-            choice.addClass("select2-highlighted");
-
-            // ensure assistive technology can determine the active choice
-            this.search.attr("aria-activedescendant", choice.find(".select2-result-label").attr("id"));
-
-            this.ensureHighlightVisible();
-
-            this.liveRegion.text(choice.text());
-
-            data = choice.data("select2-data");
-            if (data) {
-                this.opts.element.trigger({ type: "select2-highlight", val: this.id(data), choice: data });
-            }
-        },
-
-        removeHighlight: function() {
-            this.results.find(".select2-highlighted").removeClass("select2-highlighted");
-        },
-
-        touchMoved: function() {
-            this._touchMoved = true;
-        },
-
-        clearTouchMoved: function() {
-          this._touchMoved = false;
-        },
-
-        // abstract
-        countSelectableResults: function() {
-            return this.findHighlightableChoices().length;
-        },
-
-        // abstract
-        highlightUnderEvent: function (event) {
-            var el = $(event.target).closest(".select2-result-selectable");
-            if (el.length > 0 && !el.is(".select2-highlighted")) {
-                var choices = this.findHighlightableChoices();
-                this.highlight(choices.index(el));
-            } else if (el.length == 0) {
-                // if we are over an unselectable item remove all highlights
-                this.removeHighlight();
-            }
-        },
-
-        // abstract
-        loadMoreIfNeeded: function () {
-            var results = this.results,
-                more = results.find("li.select2-more-results"),
-                below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
-                page = this.resultsPage + 1,
-                self=this,
-                term=this.search.val(),
-                context=this.context;
-
-            if (more.length === 0) return;
-            below = more.offset().top - results.offset().top - results.height();
-
-            if (below <= this.opts.loadMorePadding) {
-                more.addClass("select2-active");
-                this.opts.query({
-                        element: this.opts.element,
-                        term: term,
-                        page: page,
-                        context: context,
-                        matcher: this.opts.matcher,
-                        callback: this.bind(function (data) {
-
-                    // ignore a response if the select2 has been closed before it was received
-                    if (!self.opened()) return;
-
-
-                    self.opts.populateResults.call(this, results, data.results, {term: term, page: page, context:context});
-                    self.postprocessResults(data, false, false);
-
-                    if (data.more===true) {
-                        more.detach().appendTo(results).html(self.opts.escapeMarkup(evaluate(self.opts.formatLoadMore, self.opts.element, page+1)));
-                        window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10);
-                    } else {
-                        more.remove();
-                    }
-                    self.positionDropdown();
-                    self.resultsPage = page;
-                    self.context = data.context;
-                    this.opts.element.trigger({ type: "select2-loaded", items: data });
-                })});
-            }
-        },
-
-        /**
-         * Default tokenizer function which does nothing
-         */
-        tokenize: function() {
-
-        },
-
-        /**
-         * @param initial whether or not this is the call to this method right after the dropdown has been opened
-         */
-        // abstract
-        updateResults: function (initial) {
-            var search = this.search,
-                results = this.results,
-                opts = this.opts,
-                data,
-                self = this,
-                input,
-                term = search.val(),
-                lastTerm = $.data(this.container, "select2-last-term"),
-                // sequence number used to drop out-of-order responses
-                queryNumber;
-
-            // prevent duplicate queries against the same term
-            if (initial !== true && lastTerm && equal(term, lastTerm)) return;
-
-            $.data(this.container, "select2-last-term", term);
-
-            // if the search is currently hidden we do not alter the results
-            if (initial !== true && (this.showSearchInput === false || !this.opened())) {
-                return;
-            }
-
-            function postRender() {
-                search.removeClass("select2-active");
-                self.positionDropdown();
-                if (results.find('.select2-no-results,.select2-selection-limit,.select2-searching').length) {
-                    self.liveRegion.text(results.text());
-                }
-                else {
-                    self.liveRegion.text(self.opts.formatMatches(results.find('.select2-result-selectable:not(".select2-selected")').length));
-                }
-            }
-
-            function render(html) {
-                results.html(html);
-                postRender();
-            }
-
-            queryNumber = ++this.queryCount;
-
-            var maxSelSize = this.getMaximumSelectionSize();
-            if (maxSelSize >=1) {
-                data = this.data();
-                if ($.isArray(data) && data.length >= maxSelSize && checkFormatter(opts.formatSelectionTooBig, "formatSelectionTooBig")) {
-                    render("<li class='select2-selection-limit'>" + evaluate(opts.formatSelectionTooBig, opts.element, maxSelSize) + "</li>");
-                    return;
-                }
-            }
-
-            if (search.val().length < opts.minimumInputLength) {
-                if (checkFormatter(opts.formatInputTooShort, "formatInputTooShort")) {
-                    render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooShort, opts.element, search.val(), opts.minimumInputLength) + "</li>");
-                } else {
-                    render("");
-                }
-                if (initial && this.showSearch) this.showSearch(true);
-                return;
-            }
-
-            if (opts.maximumInputLength && search.val().length > opts.maximumInputLength) {
-                if (checkFormatter(opts.formatInputTooLong, "formatInputTooLong")) {
-                    render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooLong, opts.element, search.val(), opts.maximumInputLength) + "</li>");
-                } else {
-                    render("");
-                }
-                return;
-            }
-
-            if (opts.formatSearching && this.findHighlightableChoices().length === 0) {
-                render("<li class='select2-searching'>" + evaluate(opts.formatSearching, opts.element) + "</li>");
-            }
-
-            search.addClass("select2-active");
-
-            this.removeHighlight();
-
-            // give the tokenizer a chance to pre-process the input
-            input = this.tokenize();
-            if (input != undefined && input != null) {
-                search.val(input);
-            }
-
-            this.resultsPage = 1;
-
-            opts.query({
-                element: opts.element,
-                    term: search.val(),
-                    page: this.resultsPage,
-                    context: null,
-                    matcher: opts.matcher,
-                    callback: this.bind(function (data) {
-                var def; // default choice
-
-                // ignore old responses
-                if (queryNumber != this.queryCount) {
-                  return;
-                }
-
-                // ignore a response if the select2 has been closed before it was received
-                if (!this.opened()) {
-                    this.search.removeClass("select2-active");
-                    return;
-                }
-
-                // handle ajax error
-                if(data.hasError !== undefined && checkFormatter(opts.formatAjaxError, "formatAjaxError")) {
-                    render("<li class='select2-ajax-error'>" + evaluate(opts.formatAjaxError, opts.element, data.jqXHR, data.textStatus, data.errorThrown) + "</li>");
-                    return;
-                }
-
-                // save context, if any
-                this.context = (data.context===undefined) ? null : data.context;
-                // create a default choice and prepend it to the list
-                if (this.opts.createSearchChoice && search.val() !== "") {
-                    def = this.opts.createSearchChoice.call(self, search.val(), data.results);
-                    if (def !== undefined && def !== null && self.id(def) !== undefined && self.id(def) !== null) {
-                        if ($(data.results).filter(
-                            function () {
-                                return equal(self.id(this), self.id(def));
-                            }).length === 0) {
-                            this.opts.createSearchChoicePosition(data.results, def);
-                        }
-                    }
-                }
-
-                if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) {
-                    render("<li class='select2-no-results'>" + evaluate(opts.formatNoMatches, opts.element, search.val()) + "</li>");
-                    return;
-                }
-
-                results.empty();
-                self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null});
-
-                if (data.more === true && checkFormatter(opts.formatLoadMore, "formatLoadMore")) {
-                    results.append("<li class='select2-more-results'>" + opts.escapeMarkup(evaluate(opts.formatLoadMore, opts.element, this.resultsPage)) + "</li>");
-                    window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10);
-                }
-
-                this.postprocessResults(data, initial);
-
-                postRender();
-
-                this.opts.element.trigger({ type: "select2-loaded", items: data });
-            })});
-        },
-
-        // abstract
-        cancel: function () {
-            this.close();
-        },
-
-        // abstract
-        blur: function () {
-            // if selectOnBlur == true, select the currently highlighted option
-            if (this.opts.selectOnBlur)
-                this.selectHighlighted({noFocus: true});
-
-            this.close();
-            this.container.removeClass("select2-container-active");
-            // synonymous to .is(':focus'), which is available in jquery >= 1.6
-            if (this.search[0] === document.activeElement) { this.search.blur(); }
-            this.clearSearch();
-            this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
-        },
-
-        // abstract
-        focusSearch: function () {
-            focus(this.search);
-        },
-
-        // abstract
-        selectHighlighted: function (options) {
-            if (this._touchMoved) {
-              this.clearTouchMoved();
-              return;
-            }
-            var index=this.highlight(),
-                highlighted=this.results.find(".select2-highlighted"),
-                data = highlighted.closest('.select2-result').data("select2-data");
-
-            if (data) {
-                this.highlight(index);
-                this.onSelect(data, options);
-            } else if (options && options.noFocus) {
-                this.close();
-            }
-        },
-
-        // abstract
-        getPlaceholder: function () {
-            var placeholderOption;
-            return this.opts.element.attr("placeholder") ||
-                this.opts.element.attr("data-placeholder") || // jquery 1.4 compat
-                this.opts.element.data("placeholder") ||
-                this.opts.placeholder ||
-                ((placeholderOption = this.getPlaceholderOption()) !== undefined ? placeholderOption.text() : undefined);
-        },
-
-        // abstract
-        getPlaceholderOption: function() {
-            if (this.select) {
-                var firstOption = this.select.children('option').first();
-                if (this.opts.placeholderOption !== undefined ) {
-                    //Determine the placeholder option based on the specified placeholderOption setting
-                    return (this.opts.placeholderOption === "first" && firstOption) ||
-                           (typeof this.opts.placeholderOption === "function" && this.opts.placeholderOption(this.select));
-                } else if ($.trim(firstOption.text()) === "" && firstOption.val() === "") {
-                    //No explicit placeholder option specified, use the first if it's blank
-                    return firstOption;
-                }
-            }
-        },
-
-        /**
-         * Get the desired width for the container element.  This is
-         * derived first from option `width` passed to select2, then
-         * the inline 'style' on the original element, and finally
-         * falls back to the jQuery calculated element width.
-         */
-        // abstract
-        initContainerWidth: function () {
-            function resolveContainerWidth() {
-                var style, attrs, matches, i, l, attr;
-
-                if (this.opts.width === "off") {
-                    return null;
-                } else if (this.opts.width === "element"){
-                    return this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px';
-                } else if (this.opts.width === "copy" || this.opts.width === "resolve") {
-                    // check if there is inline style on the element that contains width
-                    style = this.opts.element.attr('style');
-                    if (style !== undefined) {
-                        attrs = style.split(';');
-                        for (i = 0, l = attrs.length; i < l; i = i + 1) {
-                            attr = attrs[i].replace(/\s/g, '');
-                            matches = attr.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);
-                            if (matches !== null && matches.length >= 1)
-                                return matches[1];
-                        }
-                    }
-
-                    if (this.opts.width === "resolve") {
-                        // next check if css('width') can resolve a width that is percent based, this is sometimes possible
-                        // when attached to input type=hidden or elements hidden via css
-                        style = this.opts.element.css('width');
-                        if (style.indexOf("%") > 0) return style;
-
-                        // finally, fallback on the calculated width of the element
-                        return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
-                    }
-
-                    return null;
-                } else if ($.isFunction(this.opts.width)) {
-                    return this.opts.width();
-                } else {
-                    return this.opts.width;
-               }
-            };
-
-            var width = resolveContainerWidth.call(this);
-            if (width !== null) {
-                this.container.css("width", width);
-            }
-        }
-    });
-
-    SingleSelect2 = clazz(AbstractSelect2, {
-
-        // single
-
-        createContainer: function () {
-            var container = $(document.createElement("div")).attr({
-                "class": "select2-container"
-            }).html([
-                "<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>",
-                "   <span class='select2-chosen'>&#160;</span><abbr class='select2-search-choice-close'></abbr>",
-                "   <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>",
-                "</a>",
-                "<label for='' class='select2-offscreen'></label>",
-                "<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />",
-                "<div class='select2-drop select2-display-none'>",
-                "   <div class='select2-search'>",
-                "       <label for='' class='select2-offscreen'></label>",
-                "       <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'",
-                "       aria-autocomplete='list' />",
-                "   </div>",
-                "   <ul class='select2-results' role='listbox'>",
-                "   </ul>",
-                "</div>"].join(""));
-            return container;
-        },
-
-        // single
-        enableInterface: function() {
-            if (this.parent.enableInterface.apply(this, arguments)) {
-                this.focusser.prop("disabled", !this.isInterfaceEnabled());
-            }
-        },
-
-        // single
-        opening: function () {
-            var el, range, len;
-
-            if (this.opts.minimumResultsForSearch >= 0) {
-                this.showSearch(true);
-            }
-
-            this.parent.opening.apply(this, arguments);
-
-            if (this.showSearchInput !== false) {
-                // IE appends focusser.val() at the end of field :/ so we manually insert it at the beginning using a range
-                // all other browsers handle this just fine
-
-                this.search.val(this.focusser.val());
-            }
-            if (this.opts.shouldFocusInput(this)) {
-                this.search.focus();
-                // move the cursor to the end after focussing, otherwise it will be at the beginning and
-                // new text will appear *before* focusser.val()
-                el = this.search.get(0);
-                if (el.createTextRange) {
-                    range = el.createTextRange();
-                    range.collapse(false);
-                    range.select();
-                } else if (el.setSelectionRange) {
-                    len = this.search.val().length;
-                    el.setSelectionRange(len, len);
-                }
-            }
-
-            // initializes search's value with nextSearchTerm (if defined by user)
-            // ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
-            if(this.search.val() === "") {
-                if(this.nextSearchTerm != undefined){
-                    this.search.val(this.nextSearchTerm);
-                    this.search.select();
-                }
-            }
-
-            this.focusser.prop("disabled", true).val("");
-            this.updateResults(true);
-            this.opts.element.trigger($.Event("select2-open"));
-        },
-
-        // single
-        close: function () {
-            if (!this.opened()) return;
-            this.parent.close.apply(this, arguments);
-
-            this.focusser.prop("disabled", false);
-
-            if (this.opts.shouldFocusInput(this)) {
-                this.focusser.focus();
-            }
-        },
-
-        // single
-        focus: function () {
-            if (this.opened()) {
-                this.close();
-            } else {
-                this.focusser.prop("disabled", false);
-                if (this.opts.shouldFocusInput(this)) {
-                    this.focusser.focus();
-                }
-            }
-        },
-
-        // single
-        isFocused: function () {
-            return this.container.hasClass("select2-container-active");
-        },
-
-        // single
-        cancel: function () {
-            this.parent.cancel.apply(this, arguments);
-            this.focusser.prop("disabled", false);
-
-            if (this.opts.shouldFocusInput(this)) {
-                this.focusser.focus();
-            }
-        },
-
-        // single
-        destroy: function() {
-            $("label[for='" + this.focusser.attr('id') + "']")
-                .attr('for', this.opts.element.attr("id"));
-            this.parent.destroy.apply(this, arguments);
-
-            cleanupJQueryElements.call(this,
-                "selection",
-                "focusser"
-            );
-        },
-
-        // single
-        initContainer: function () {
-
-            var selection,
-                container = this.container,
-                dropdown = this.dropdown,
-                idSuffix = nextUid(),
-                elementLabel;
-
-            if (this.opts.minimumResultsForSearch < 0) {
-                this.showSearch(false);
-            } else {
-                this.showSearch(true);
-            }
-
-            this.selection = selection = container.find(".select2-choice");
-
-            this.focusser = container.find(".select2-focusser");
-
-            // add aria associations
-            selection.find(".select2-chosen").attr("id", "select2-chosen-"+idSuffix);
-            this.focusser.attr("aria-labelledby", "select2-chosen-"+idSuffix);
-            this.results.attr("id", "select2-results-"+idSuffix);
-            this.search.attr("aria-owns", "select2-results-"+idSuffix);
-
-            // rewrite labels from original element to focusser
-            this.focusser.attr("id", "s2id_autogen"+idSuffix);
-
-            elementLabel = $("label[for='" + this.opts.element.attr("id") + "']");
-            this.opts.element.focus(this.bind(function () { this.focus(); }));
-
-            this.focusser.prev()
-                .text(elementLabel.text())
-                .attr('for', this.focusser.attr('id'));
-
-            // Ensure the original element retains an accessible name
-            var originalTitle = this.opts.element.attr("title");
-            this.opts.element.attr("title", (originalTitle || elementLabel.text()));
-
-            this.focusser.attr("tabindex", this.elementTabIndex);
-
-            // write label for search field using the label from the focusser element
-            this.search.attr("id", this.focusser.attr('id') + '_search');
-
-            this.search.prev()
-                .text($("label[for='" + this.focusser.attr('id') + "']").text())
-                .attr('for', this.search.attr('id'));
-
-            this.search.on("keydown", this.bind(function (e) {
-                if (!this.isInterfaceEnabled()) return;
-
-                // filter 229 keyCodes (input method editor is processing key input)
-                if (229 == e.keyCode) return;
-
-                if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) {
-                    // prevent the page from scrolling
-                    killEvent(e);
-                    return;
-                }
-
-                switch (e.which) {
-                    case KEY.UP:
-                    case KEY.DOWN:
-                        this.moveHighlight((e.which === KEY.UP) ? -1 : 1);
-                        killEvent(e);
-                        return;
-                    case KEY.ENTER:
-                        this.selectHighlighted();
-                        killEvent(e);
-                        return;
-                    case KEY.TAB:
-                        this.selectHighlighted({noFocus: true});
-                        return;
-                    case KEY.ESC:
-                        this.cancel(e);
-                        killEvent(e);
-                        return;
-                }
-            }));
-
-            this.search.on("blur", this.bind(function(e) {
-                // a workaround for chrome to keep the search field focussed when the scroll bar is used to scroll the dropdown.
-                // without this the search field loses focus which is annoying
-                if (document.activeElement === this.body.get(0)) {
-                    window.setTimeout(this.bind(function() {
-                        if (this.opened()) {
-                            this.search.focus();
-                        }
-                    }), 0);
-                }
-            }));
-
-            this.focusser.on("keydown", this.bind(function (e) {
-                if (!this.isInterfaceEnabled()) return;
-
-                if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
-                    return;
-                }
-
-                if (this.opts.openOnEnter === false && e.which === KEY.ENTER) {
-                    killEvent(e);
-                    return;
-                }
-
-                if (e.which == KEY.DOWN || e.which == KEY.UP
-                    || (e.which == KEY.ENTER && this.opts.openOnEnter)) {
-
-                    if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return;
-
-                    this.open();
-                    killEvent(e);
-                    return;
-                }
-
-                if (e.which == KEY.DELETE || e.which == KEY.BACKSPACE) {
-                    if (this.opts.allowClear) {
-                        this.clear();
-                    }
-                    killEvent(e);
-                    return;
-                }
-            }));
-
-
-            installKeyUpChangeEvent(this.focusser);
-            this.focusser.on("keyup-change input", this.bind(function(e) {
-                if (this.opts.minimumResultsForSearch >= 0) {
-                    e.stopPropagation();
-                    if (this.opened()) return;
-                    this.open();
-                }
-            }));
-
-            selection.on("mousedown touchstart", "abbr", this.bind(function (e) {
-                if (!this.isInterfaceEnabled()) {
-                    return;
-                }
-
-                this.clear();
-                killEventImmediately(e);
-                this.close();
-
-                if (this.selection) {
-                    this.selection.focus();
-                }
-            }));
-
-            selection.on("mousedown touchstart", this.bind(function (e) {
-                // Prevent IE from generating a click event on the body
-                reinsertElement(selection);
-
-                if (!this.container.hasClass("select2-container-active")) {
-                    this.opts.element.trigger($.Event("select2-focus"));
-                }
-
-                if (this.opened()) {
-                    this.close();
-                } else if (this.isInterfaceEnabled()) {
-                    this.open();
-                }
-
-                killEvent(e);
-            }));
-
-            dropdown.on("mousedown touchstart", this.bind(function() {
-                if (this.opts.shouldFocusInput(this)) {
-                    this.search.focus();
-                }
-            }));
-
-            selection.on("focus", this.bind(function(e) {
-                killEvent(e);
-            }));
-
-            this.focusser.on("focus", this.bind(function(){
-                if (!this.container.hasClass("select2-container-active")) {
-                    this.opts.element.trigger($.Event("select2-focus"));
-                }
-                this.container.addClass("select2-container-active");
-            })).on("blur", this.bind(function() {
-                if (!this.opened()) {
-                    this.container.removeClass("select2-container-active");
-                    this.opts.element.trigger($.Event("select2-blur"));
-                }
-            }));
-            this.search.on("focus", this.bind(function(){
-                if (!this.container.hasClass("select2-container-active")) {
-                    this.opts.element.trigger($.Event("select2-focus"));
-                }
-                this.container.addClass("select2-container-active");
-            }));
-
-            this.initContainerWidth();
-            this.opts.element.hide();
-            this.setPlaceholder();
-
-        },
-
-        // single
-        clear: function(triggerChange) {
-            var data=this.selection.data("select2-data");
-            if (data) { // guard against queued quick consecutive clicks
-                var evt = $.Event("select2-clearing");
-                this.opts.element.trigger(evt);
-                if (evt.isDefaultPrevented()) {
-                    return;
-                }
-                var placeholderOption = this.getPlaceholderOption();
-                this.opts.element.val(placeholderOption ? placeholderOption.val() : "");
-                this.selection.find(".select2-chosen").empty();
-                this.selection.removeData("select2-data");
-                this.setPlaceholder();
-
-                if (triggerChange !== false){
-                    this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
-                    this.triggerChange({removed:data});
-                }
-            }
-        },
-
-        /**
-         * Sets selection based on source element's value
-         */
-        // single
-        initSelection: function () {
-            var selected;
-            if (this.isPlaceholderOptionSelected()) {
-                this.updateSelection(null);
-                this.close();
-                this.setPlaceholder();
-            } else {
-                var self = this;
-                this.opts.initSelection.call(null, this.opts.element, function(selected){
-                    if (selected !== undefined && selected !== null) {
-                        self.updateSelection(selected);
-                        self.close();
-                        self.setPlaceholder();
-                        self.nextSearchTerm = self.opts.nextSearchTerm(selected, self.search.val());
-                    }
-                });
-            }
-        },
-
-        isPlaceholderOptionSelected: function() {
-            var placeholderOption;
-            if (this.getPlaceholder() === undefined) return false; // no placeholder specified so no option should be considered
-            return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.prop("selected"))
-                || (this.opts.element.val() === "")
-                || (this.opts.element.val() === undefined)
-                || (this.opts.element.val() === null);
-        },
-
-        // single
-        prepareOpts: function () {
-            var opts = this.parent.prepareOpts.apply(this, arguments),
-                self=this;
-
-            if (opts.element.get(0).tagName.toLowerCase() === "select") {
-                // install the selection initializer
-                opts.initSelection = function (element, callback) {
-                    var selected = element.find("option").filter(function() { return this.selected && !this.disabled });
-                    // a single select box always has a value, no need to null check 'selected'
-                    callback(self.optionToData(selected));
-                };
-            } else if ("data" in opts) {
-                // install default initSelection when applied to hidden input and data is local
-                opts.initSelection = opts.initSelection || function (element, callback) {
-                    var id = element.val();
-                    //search in data by id, storing the actual matching item
-                    var match = null;
-                    opts.query({
-                        matcher: function(term, text, el){
-                            var is_match = equal(id, opts.id(el));
-                            if (is_match) {
-                                match = el;
-                            }
-                            return is_match;
-                        },
-                        callback: !$.isFunction(callback) ? $.noop : function() {
-                            callback(match);
-                        }
-                    });
-                };
-            }
-
-            return opts;
-        },
-
-        // single
-        getPlaceholder: function() {
-            // if a placeholder is specified on a single select without a valid placeholder option ignore it
-            if (this.select) {
-                if (this.getPlaceholderOption() === undefined) {
-                    return undefined;
-                }
-            }
-
-            return this.parent.getPlaceholder.apply(this, arguments);
-        },
-
-        // single
-        setPlaceholder: function () {
-            var placeholder = this.getPlaceholder();
-
-            if (this.isPlaceholderOptionSelected() && placeholder !== undefined) {
-
-                // check for a placeholder option if attached to a select
-                if (this.select && this.getPlaceholderOption() === undefined) return;
-
-                this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(placeholder));
-
-                this.selection.addClass("select2-default");
-
-                this.container.removeClass("select2-allowclear");
-            }
-        },
-
-        // single
-        postprocessResults: function (data, initial, noHighlightUpdate) {
-            var selected = 0, self = this, showSearchInput = true;
-
-            // find the selected element in the result list
-
-            this.findHighlightableChoices().each2(function (i, elm) {
-                if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
-                    selected = i;
-                    return false;
-                }
-            });
-
-            // and highlight it
-            if (noHighlightUpdate !== false) {
-                if (initial === true && selected >= 0) {
-                    this.highlight(selected);
-                } else {
-                    this.highlight(0);
-                }
-            }
-
-            // hide the search box if this is the first we got the results and there are enough of them for search
-
-            if (initial === true) {
-                var min = this.opts.minimumResultsForSearch;
-                if (min >= 0) {
-                    this.showSearch(countResults(data.results) >= min);
-                }
-            }
-        },
-
-        // single
-        showSearch: function(showSearchInput) {
-            if (this.showSearchInput === showSearchInput) return;
-
-            this.showSearchInput = showSearchInput;
-
-            this.dropdown.find(".select2-search").toggleClass("select2-search-hidden", !showSearchInput);
-            this.dropdown.find(".select2-search").toggleClass("select2-offscreen", !showSearchInput);
-            //add "select2-with-searchbox" to the container if search box is shown
-            $(this.dropdown, this.container).toggleClass("select2-with-searchbox", showSearchInput);
-        },
-
-        // single
-        onSelect: function (data, options) {
-
-            if (!this.triggerSelect(data)) { return; }
-
-            var old = this.opts.element.val(),
-                oldData = this.data();
-
-            this.opts.element.val(this.id(data));
-            this.updateSelection(data);
-
-            this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });
-
-            this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
-            this.close();
-
-            if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) {
-                this.focusser.focus();
-            }
-
-            if (!equal(old, this.id(data))) {
-                this.triggerChange({ added: data, removed: oldData });
-            }
-        },
-
-        // single
-        updateSelection: function (data) {
-
-            var container=this.selection.find(".select2-chosen"), formatted, cssClass;
-
-            this.selection.data("select2-data", data);
-
-            container.empty();
-            if (data !== null) {
-                formatted=this.opts.formatSelection(data, container, this.opts.escapeMarkup);
-            }
-            if (formatted !== undefined) {
-                container.append(formatted);
-            }
-            cssClass=this.opts.formatSelectionCssClass(data, container);
-            if (cssClass !== undefined) {
-                container.addClass(cssClass);
-            }
-
-            this.selection.removeClass("select2-default");
-
-            if (this.opts.allowClear && this.getPlaceholder() !== undefined) {
-                this.container.addClass("select2-allowclear");
-            }
-        },
-
-        // single
-        val: function () {
-            var val,
-                triggerChange = false,
-                data = null,
-                self = this,
-                oldData = this.data();
-
-            if (arguments.length === 0) {
-                return this.opts.element.val();
-            }
-
-            val = arguments[0];
-
-            if (arguments.length > 1) {
-                triggerChange = arguments[1];
-            }
-
-            if (this.select) {
-                this.select
-                    .val(val)
-                    .find("option").filter(function() { return this.selected }).each2(function (i, elm) {
-                        data = self.optionToData(elm);
-                        return false;
-                    });
-                this.updateSelection(data);
-                this.setPlaceholder();
-                if (triggerChange) {
-                    this.triggerChange({added: data, removed:oldData});
-                }
-            } else {
-                // val is an id. !val is true for [undefined,null,'',0] - 0 is legal
-                if (!val && val !== 0) {
-                    this.clear(triggerChange);
-                    return;
-                }
-                if (this.opts.initSelection === undefined) {
-                    throw new Error("cannot call val() if initSelection() is not defined");
-                }
-                this.opts.element.val(val);
-                this.opts.initSelection(this.opts.element, function(data){
-                    self.opts.element.val(!data ? "" : self.id(data));
-                    self.updateSelection(data);
-                    self.setPlaceholder();
-                    if (triggerChange) {
-                        self.triggerChange({added: data, removed:oldData});
-                    }
-                });
-            }
-        },
-
-        // single
-        clearSearch: function () {
-            this.search.val("");
-            this.focusser.val("");
-        },
-
-        // single
-        data: function(value) {
-            var data,
-                triggerChange = false;
-
-            if (arguments.length === 0) {
-                data = this.selection.data("select2-data");
-                if (data == undefined) data = null;
-                return data;
-            } else {
-                if (arguments.length > 1) {
-                    triggerChange = arguments[1];
-                }
-                if (!value) {
-                    this.clear(triggerChange);
-                } else {
-                    data = this.data();
-                    this.opts.element.val(!value ? "" : this.id(value));
-                    this.updateSelection(value);
-                    if (triggerChange) {
-                        this.triggerChange({added: value, removed:data});
-                    }
-                }
-            }
-        }
-    });
-
-    MultiSelect2 = clazz(AbstractSelect2, {
-
-        // multi
-        createContainer: function () {
-            var container = $(document.createElement("div")).attr({
-                "class": "select2-container select2-container-multi"
-            }).html([
-                "<ul class='select2-choices'>",
-                "  <li class='select2-search-field'>",
-                "    <label for='' class='select2-offscreen'></label>",
-                "    <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>",
-                "  </li>",
-                "</ul>",
-                "<div class='select2-drop select2-drop-multi select2-display-none'>",
-                "   <ul class='select2-results'>",
-                "   </ul>",
-                "</div>"].join(""));
-            return container;
-        },
-
-        // multi
-        prepareOpts: function () {
-            var opts = this.parent.prepareOpts.apply(this, arguments),
-                self=this;
-
-            // TODO validate placeholder is a string if specified
-            if (opts.element.get(0).tagName.toLowerCase() === "select") {
-                // install the selection initializer
-                opts.initSelection = function (element, callback) {
-
-                    var data = [];
-
-                    element.find("option").filter(function() { return this.selected && !this.disabled }).each2(function (i, elm) {
-                        data.push(self.optionToData(elm));
-                    });
-                    callback(data);
-                };
-            } else if ("data" in opts) {
-                // install default initSelection when applied to hidden input and data is local
-                opts.initSelection = opts.initSelection || function (element, callback) {
-                    var ids = splitVal(element.val(), opts.separator, opts.transformVal);
-                    //search in data by array of ids, storing matching items in a list
-                    var matches = [];
-                    opts.query({
-                        matcher: function(term, text, el){
-                            var is_match = $.grep(ids, function(id) {
-                                return equal(id, opts.id(el));
-                            }).length;
-                            if (is_match) {
-                                matches.push(el);
-                            }
-                            return is_match;
-                        },
-                        callback: !$.isFunction(callback) ? $.noop : function() {
-                            // reorder matches based on the order they appear in the ids array because right now
-                            // they are in the order in which they appear in data array
-                            var ordered = [];
-                            for (var i = 0; i < ids.length; i++) {
-                                var id = ids[i];
-                                for (var j = 0; j < matches.length; j++) {
-                                    var match = matches[j];
-                                    if (equal(id, opts.id(match))) {
-                                        ordered.push(match);
-                                        matches.splice(j, 1);
-                                        break;
-                                    }
-                                }
-                            }
-                            callback(ordered);
-                        }
-                    });
-                };
-            }
-
-            return opts;
-        },
-
-        // multi
-        selectChoice: function (choice) {
-
-            var selected = this.container.find(".select2-search-choice-focus");
-            if (selected.length && choice && choice[0] == selected[0]) {
-
-            } else {
-                if (selected.length) {
-                    this.opts.element.trigger("choice-deselected", selected);
-                }
-                selected.removeClass("select2-search-choice-focus");
-                if (choice && choice.length) {
-                    this.close();
-                    choice.addClass("select2-search-choice-focus");
-                    this.opts.element.trigger("choice-selected", choice);
-                }
-            }
-        },
-
-        // multi
-        destroy: function() {
-            $("label[for='" + this.search.attr('id') + "']")
-                .attr('for', this.opts.element.attr("id"));
-            this.parent.destroy.apply(this, arguments);
-
-            cleanupJQueryElements.call(this,
-                "searchContainer",
-                "selection"
-            );
-        },
-
-        // multi
-        initContainer: function () {
-
-            var selector = ".select2-choices", selection;
-
-            this.searchContainer = this.container.find(".select2-search-field");
-            this.selection = selection = this.container.find(selector);
-
-            var _this = this;
-            this.selection.on("click", ".select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)", function (e) {
-                _this.search[0].focus();
-                _this.selectChoice($(this));
-            });
-
-            // rewrite labels from original element to focusser
-            this.search.attr("id", "s2id_autogen"+nextUid());
-
-            this.search.prev()
-                .text($("label[for='" + this.opts.element.attr("id") + "']").text())
-                .attr('for', this.search.attr('id'));
-            this.opts.element.focus(this.bind(function () { this.focus(); }));
-
-            this.search.on("input paste", this.bind(function() {
-                if (this.search.attr('placeholder') && this.search.val().length == 0) return;
-                if (!this.isInterfaceEnabled()) return;
-                if (!this.opened()) {
-                    this.open();
-                }
-            }));
-
-            this.search.attr("tabindex", this.elementTabIndex);
-
-            this.keydowns = 0;
-            this.search.on("keydown", this.bind(function (e) {
-                if (!this.isInterfaceEnabled()) return;
-
-                ++this.keydowns;
-                var selected = selection.find(".select2-search-choice-focus");
-                var prev = selected.prev(".select2-search-choice:not(.select2-locked)");
-                var next = selected.next(".select2-search-choice:not(.select2-locked)");
-                var pos = getCursorInfo(this.search);
-
-                if (selected.length &&
-                    (e.which == KEY.LEFT || e.which == KEY.RIGHT || e.which == KEY.BACKSPACE || e.which == KEY.DELETE || e.which == KEY.ENTER)) {
-                    var selectedChoice = selected;
-                    if (e.which == KEY.LEFT && prev.length) {
-                        selectedChoice = prev;
-                    }
-                    else if (e.which == KEY.RIGHT) {
-                        selectedChoice = next.length ? next : null;
-                    }
-                    else if (e.which === KEY.BACKSPACE) {
-                        if (this.unselect(selected.first())) {
-                            this.search.width(10);
-                            selectedChoice = prev.length ? prev : next;
-                        }
-                    } else if (e.which == KEY.DELETE) {
-                        if (this.unselect(selected.first())) {
-                            this.search.width(10);
-                            selectedChoice = next.length ? next : null;
-                        }
-                    } else if (e.which == KEY.ENTER) {
-                        selectedChoice = null;
-                    }
-
-                    this.selectChoice(selectedChoice);
-                    killEvent(e);
-                    if (!selectedChoice || !selectedChoice.length) {
-                        this.open();
-                    }
-                    return;
-                } else if (((e.which === KEY.BACKSPACE && this.keydowns == 1)
-                    || e.which == KEY.LEFT) && (pos.offset == 0 && !pos.length)) {
-
-                    this.selectChoice(selection.find(".select2-search-choice:not(.select2-locked)").last());
-                    killEvent(e);
-                    return;
-                } else {
-                    this.selectChoice(null);
-                }
-
-                if (this.opened()) {
-                    switch (e.which) {
-                    case KEY.UP:
-                    case KEY.DOWN:
-                        this.moveHighlight((e.which === KEY.UP) ? -1 : 1);
-                        killEvent(e);
-                        return;
-                    case KEY.ENTER:
-                        this.selectHighlighted();
-                        killEvent(e);
-                        return;
-                    case KEY.TAB:
-                        this.selectHighlighted({noFocus:true});
-                        this.close();
-                        return;
-                    case KEY.ESC:
-                        this.cancel(e);
-                        killEvent(e);
-                        return;
-                    }
-                }
-
-                if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e)
-                 || e.which === KEY.BACKSPACE || e.which === KEY.ESC) {
-                    return;
-                }
-
-                if (e.which === KEY.ENTER) {
-                    if (this.opts.openOnEnter === false) {
-                        return;
-                    } else if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
-                        return;
-                    }
-                }
-
-                this.open();
-
-                if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) {
-                    // prevent the page from scrolling
-                    killEvent(e);
-                }
-
-                if (e.which === KEY.ENTER) {
-                    // prevent form from being submitted
-                    killEvent(e);
-                }
-
-            }));
-
-            this.search.on("keyup", this.bind(function (e) {
-                this.keydowns = 0;
-                this.resizeSearch();
-            })
-            );
-
-            this.search.on("blur", this.bind(function(e) {
-                this.container.removeClass("select2-container-active");
-                this.search.removeClass("select2-focused");
-                this.selectChoice(null);
-                if (!this.opened()) this.clearSearch();
-                e.stopImmediatePropagation();
-                this.opts.element.trigger($.Event("select2-blur"));
-            }));
-
-            this.container.on("click", selector, this.bind(function (e) {
-                if (!this.isInterfaceEnabled()) return;
-                if ($(e.target).closest(".select2-search-choice").length > 0) {
-                    // clicked inside a select2 search choice, do not open
-                    return;
-                }
-                this.selectChoice(null);
-                this.clearPlaceholder();
-                if (!this.container.hasClass("select2-container-active")) {
-                    this.opts.element.trigger($.Event("select2-focus"));
-                }
-                this.open();
-                this.focusSearch();
-                e.preventDefault();
-            }));
-
-            this.container.on("focus", selector, this.bind(function () {
-                if (!this.isInterfaceEnabled()) return;
-                if (!this.container.hasClass("select2-container-active")) {
-                    this.opts.element.trigger($.Event("select2-focus"));
-                }
-                this.container.addClass("select2-container-active");
-                this.dropdown.addClass("select2-drop-active");
-                this.clearPlaceholder();
-            }));
-
-            this.initContainerWidth();
-            this.opts.element.hide();
-
-            // set the placeholder if necessary
-            this.clearSearch();
-        },
-
-        // multi
-        enableInterface: function() {
-            if (this.parent.enableInterface.apply(this, arguments)) {
-                this.search.prop("disabled", !this.isInterfaceEnabled());
-            }
-        },
-
-        // multi
-        initSelection: function () {
-            var data;
-            if (this.opts.element.val() === "" && this.opts.element.text() === "") {
-                this.updateSelection([]);
-                this.close();
-                // set the placeholder if necessary
-                this.clearSearch();
-            }
-            if (this.select || this.opts.element.val() !== "") {
-                var self = this;
-                this.opts.initSelection.call(null, this.opts.element, function(data){
-                    if (data !== undefined && data !== null) {
-                        self.updateSelection(data);
-                        self.close();
-                        // set the placeholder if necessary
-                        self.clearSearch();
-                    }
-                });
-            }
-        },
-
-        // multi
-        clearSearch: function () {
-            var placeholder = this.getPlaceholder(),
-                maxWidth = this.getMaxSearchWidth();
-
-            if (placeholder !== undefined  && this.getVal().length === 0 && this.search.hasClass("select2-focused") === false) {
-                this.search.val(placeholder).addClass("select2-default");
-                // stretch the search box to full width of the container so as much of the placeholder is visible as possible
-                // we could call this.resizeSearch(), but we do not because that requires a sizer and we do not want to create one so early because of a firefox bug, see #944
-                this.search.width(maxWidth > 0 ? maxWidth : this.container.css("width"));
-            } else {
-                this.search.val("").width(10);
-            }
-        },
-
-        // multi
-        clearPlaceholder: function () {
-            if (this.search.hasClass("select2-default")) {
-                this.search.val("").removeClass("select2-default");
-            }
-        },
-
-        // multi
-        opening: function () {
-            this.clearPlaceholder(); // should be done before super so placeholder is not used to search
-            this.resizeSearch();
-
-            this.parent.opening.apply(this, arguments);
-
-            this.focusSearch();
-
-            // initializes search's value with nextSearchTerm (if defined by user)
-            // ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
-            if(this.search.val() === "") {
-                if(this.nextSearchTerm != undefined){
-                    this.search.val(this.nextSearchTerm);
-                    this.search.select();
-                }
-            }
-
-            this.updateResults(true);
-            if (this.opts.shouldFocusInput(this)) {
-                this.search.focus();
-            }
-            this.opts.element.trigger($.Event("select2-open"));
-        },
-
-        // multi
-        close: function () {
-            if (!this.opened()) return;
-            this.parent.close.apply(this, arguments);
-        },
-
-        // multi
-        focus: function () {
-            this.close();
-            this.search.focus();
-        },
-
-        // multi
-        isFocused: function () {
-            return this.search.hasClass("select2-focused");
-        },
-
-        // multi
-        updateSelection: function (data) {
-            var ids = [], filtered = [], self = this;
-
-            // filter out duplicates
-            $(data).each(function () {
-                if (indexOf(self.id(this), ids) < 0) {
-                    ids.push(self.id(this));
-                    filtered.push(this);
-                }
-            });
-            data = filtered;
-
-            this.selection.find(".select2-search-choice").remove();
-            $(data).each(function () {
-                self.addSelectedChoice(this);
-            });
-            self.postprocessResults();
-        },
-
-        // multi
-        tokenize: function() {
-            var input = this.search.val();
-            input = this.opts.tokenizer.call(this, input, this.data(), this.bind(this.onSelect), this.opts);
-            if (input != null && input != undefined) {
-                this.search.val(input);
-                if (input.length > 0) {
-                    this.open();
-                }
-            }
-
-        },
-
-        // multi
-        onSelect: function (data, options) {
-
-            if (!this.triggerSelect(data) || data.text === "") { return; }
-
-            this.addSelectedChoice(data);
-
-            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
-
-            // keep track of the search's value before it gets cleared
-            this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
-
-            this.clearSearch();
-            this.updateResults();
-
-            if (this.select || !this.opts.closeOnSelect) this.postprocessResults(data, false, this.opts.closeOnSelect===true);
-
-            if (this.opts.closeOnSelect) {
-                this.close();
-                this.search.width(10);
-            } else {
-                if (this.countSelectableResults()>0) {
-                    this.search.width(10);
-                    this.resizeSearch();
-                    if (this.getMaximumSelectionSize() > 0 && this.val().length >= this.getMaximumSelectionSize()) {
-                        // if we reached max selection size repaint the results so choices
-                        // are replaced with the max selection reached message
-                        this.updateResults(true);
-                    } else {
-                        // initializes search's value with nextSearchTerm and update search result
-                        if(this.nextSearchTerm != undefined){
-                            this.search.val(this.nextSearchTerm);
-                            this.updateResults();
-                            this.search.select();
-                        }
-                    }
-                    this.positionDropdown();
-                } else {
-                    // if nothing left to select close
-                    this.close();
-                    this.search.width(10);
-                }
-            }
-
-            // since its not possible to select an element that has already been
-            // added we do not need to check if this is a new element before firing change
-            this.triggerChange({ added: data });
-
-            if (!options || !options.noFocus)
-                this.focusSearch();
-        },
-
-        // multi
-        cancel: function () {
-            this.close();
-            this.focusSearch();
-        },
-
-        addSelectedChoice: function (data) {
-            var enableChoice = !data.locked,
-                enabledItem = $(
-                    "<li class='select2-search-choice'>" +
-                    "    <div></div>" +
-                    "    <a href='#' class='select2-search-choice-close' tabindex='-1'></a>" +
-                    "</li>"),
-                disabledItem = $(
-                    "<li class='select2-search-choice select2-locked'>" +
-                    "<div></div>" +
-                    "</li>");
-            var choice = enableChoice ? enabledItem : disabledItem,
-                id = this.id(data),
-                val = this.getVal(),
-                formatted,
-                cssClass;
-
-            formatted=this.opts.formatSelection(data, choice.find("div"), this.opts.escapeMarkup);
-            if (formatted != undefined) {
-                choice.find("div").replaceWith($("<div></div>").html(formatted));
-            }
-            cssClass=this.opts.formatSelectionCssClass(data, choice.find("div"));
-            if (cssClass != undefined) {
-                choice.addClass(cssClass);
-            }
-
-            if(enableChoice){
-              choice.find(".select2-search-choice-close")
-                  .on("mousedown", killEvent)
-                  .on("click dblclick", this.bind(function (e) {
-                  if (!this.isInterfaceEnabled()) return;
-
-                  this.unselect($(e.target));
-                  this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
-                  killEvent(e);
-                  this.close();
-                  this.focusSearch();
-              })).on("focus", this.bind(function () {
-                  if (!this.isInterfaceEnabled()) return;
-                  this.container.addClass("select2-container-active");
-                  this.dropdown.addClass("select2-drop-active");
-              }));
-            }
-
-            choice.data("select2-data", data);
-            choice.insertBefore(this.searchContainer);
-
-            val.push(id);
-            this.setVal(val);
-        },
-
-        // multi
-        unselect: function (selected) {
-            var val = this.getVal(),
-                data,
-                index;
-            selected = selected.closest(".select2-search-choice");
-
-            if (selected.length === 0) {
-                throw "Invalid argument: " + selected + ". Must be .select2-search-choice";
-            }
-
-            data = selected.data("select2-data");
-
-            if (!data) {
-                // prevent a race condition when the 'x' is clicked really fast repeatedly the event can be queued
-                // and invoked on an element already removed
-                return;
-            }
-
-            var evt = $.Event("select2-removing");
-            evt.val = this.id(data);
-            evt.choice = data;
-            this.opts.element.trigger(evt);
-
-            if (evt.isDefaultPrevented()) {
-                return false;
-            }
-
-            while((index = indexOf(this.id(data), val)) >= 0) {
-                val.splice(index, 1);
-                this.setVal(val);
-                if (this.select) this.postprocessResults();
-            }
-
-            selected.remove();
-
-            this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
-            this.triggerChange({ removed: data });
-
-            return true;
-        },
-
-        // multi
-        postprocessResults: function (data, initial, noHighlightUpdate) {
-            var val = this.getVal(),
-                choices = this.results.find(".select2-result"),
-                compound = this.results.find(".select2-result-with-children"),
-                self = this;
-
-            choices.each2(function (i, choice) {
-                var id = self.id(choice.data("select2-data"));
-                if (indexOf(id, val) >= 0) {
-                    choice.addClass("select2-selected");
-                    // mark all children of the selected parent as selected
-                    choice.find(".select2-result-selectable").addClass("select2-selected");
-                }
-            });
-
-            compound.each2(function(i, choice) {
-                // hide an optgroup if it doesn't have any selectable children
-                if (!choice.is('.select2-result-selectable')
-                    && choice.find(".select2-result-selectable:not(.select2-selected)").length === 0) {
-                    choice.addClass("select2-selected");
-                }
-            });
-
-            if (this.highlight() == -1 && noHighlightUpdate !== false && this.opts.closeOnSelect === true){
-                self.highlight(0);
-            }
-
-            //If all results are chosen render formatNoMatches
-            if(!this.opts.createSearchChoice && !choices.filter('.select2-result:not(.select2-selected)').length > 0){
-                if(!data || data && !data.more && this.results.find(".select2-no-results").length === 0) {
-                    if (checkFormatter(self.opts.formatNoMatches, "formatNoMatches")) {
-                        this.results.append("<li class='select2-no-results'>" + evaluate(self.opts.formatNoMatches, self.opts.element, self.search.val()) + "</li>");
-                    }
-                }
-            }
-
-        },
-
-        // multi
-        getMaxSearchWidth: function() {
-            return this.selection.width() - getSideBorderPadding(this.search);
-        },
-
-        // multi
-        resizeSearch: function () {
-            var minimumWidth, left, maxWidth, containerLeft, searchWidth,
-                sideBorderPadding = getSideBorderPadding(this.search);
-
-            minimumWidth = measureTextWidth(this.search) + 10;
-
-            left = this.search.offset().left;
-
-            maxWidth = this.selection.width();
-            containerLeft = this.selection.offset().left;
-
-            searchWidth = maxWidth - (left - containerLeft) - sideBorderPadding;
-
-            if (searchWidth < minimumWidth) {
-                searchWidth = maxWidth - sideBorderPadding;
-            }
-
-            if (searchWidth < 40) {
-                searchWidth = maxWidth - sideBorderPadding;
-            }
-
-            if (searchWidth <= 0) {
-              searchWidth = minimumWidth;
-            }
-
-            this.search.width(Math.floor(searchWidth));
-        },
-
-        // multi
-        getVal: function () {
-            var val;
-            if (this.select) {
-                val = this.select.val();
-                return val === null ? [] : val;
-            } else {
-                val = this.opts.element.val();
-                return splitVal(val, this.opts.separator, this.opts.transformVal);
-            }
-        },
-
-        // multi
-        setVal: function (val) {
-            var unique;
-            if (this.select) {
-                this.select.val(val);
-            } else {
-                unique = [];
-                // filter out duplicates
-                $(val).each(function () {
-                    if (indexOf(this, unique) < 0) unique.push(this);
-                });
-                this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator));
-            }
-        },
-
-        // multi
-        buildChangeDetails: function (old, current) {
-            var current = current.slice(0),
-                old = old.slice(0);
-
-            // remove intersection from each array
-            for (var i = 0; i < current.length; i++) {
-                for (var j = 0; j < old.length; j++) {
-                    if (equal(this.opts.id(current[i]), this.opts.id(old[j]))) {
-                        current.splice(i, 1);
-                        if(i>0){
-                            i--;
-                        }
-                        old.splice(j, 1);
-                        j--;
-                    }
-                }
-            }
-
-            return {added: current, removed: old};
-        },
-
-
-        // multi
-        val: function (val, triggerChange) {
-            var oldData, self=this;
-
-            if (arguments.length === 0) {
-                return this.getVal();
-            }
-
-            oldData=this.data();
-            if (!oldData.length) oldData=[];
-
-            // val is an id. !val is true for [undefined,null,'',0] - 0 is legal
-            if (!val && val !== 0) {
-                this.opts.element.val("");
-                this.updateSelection([]);
-                this.clearSearch();
-                if (triggerChange) {
-                    this.triggerChange({added: this.data(), removed: oldData});
-                }
-                return;
-            }
-
-            // val is a list of ids
-            this.setVal(val);
-
-            if (this.select) {
-                this.opts.initSelection(this.select, this.bind(this.updateSelection));
-                if (triggerChange) {
-                    this.triggerChange(this.buildChangeDetails(oldData, this.data()));
-                }
-            } else {
-                if (this.opts.initSelection === undefined) {
-                    throw new Error("val() cannot be called if initSelection() is not defined");
-                }
-
-                this.opts.initSelection(this.opts.element, function(data){
-                    var ids=$.map(data, self.id);
-                    self.setVal(ids);
-                    self.updateSelection(data);
-                    self.clearSearch();
-                    if (triggerChange) {
-                        self.triggerChange(self.buildChangeDetails(oldData, self.data()));
-                    }
-                });
-            }
-            this.clearSearch();
-        },
-
-        // multi
-        onSortStart: function() {
-            if (this.select) {
-                throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");
-            }
-
-            // collapse search field into 0 width so its container can be collapsed as well
-            this.search.width(0);
-            // hide the container
-            this.searchContainer.hide();
-        },
-
-        // multi
-        onSortEnd:function() {
-
-            var val=[], self=this;
-
-            // show search and move it to the end of the list
-            this.searchContainer.show();
-            // make sure the search container is the last item in the list
-            this.searchContainer.appendTo(this.searchContainer.parent());
-            // since we collapsed the width in dragStarted, we resize it here
-            this.resizeSearch();
-
-            // update selection
-            this.selection.find(".select2-search-choice").each(function() {
-                val.push(self.opts.id($(this).data("select2-data")));
-            });
-            this.setVal(val);
-            this.triggerChange();
-        },
-
-        // multi
-        data: function(values, triggerChange) {
-            var self=this, ids, old;
-            if (arguments.length === 0) {
-                 return this.selection
-                     .children(".select2-search-choice")
-                     .map(function() { return $(this).data("select2-data"); })
-                     .get();
-            } else {
-                old = this.data();
-                if (!values) { values = []; }
-                ids = $.map(values, function(e) { return self.opts.id(e); });
-                this.setVal(ids);
-                this.updateSelection(values);
-                this.clearSearch();
-                if (triggerChange) {
-                    this.triggerChange(this.buildChangeDetails(old, this.data()));
-                }
-            }
-        }
-    });
-
-    $.fn.select2 = function () {
-
-        var args = Array.prototype.slice.call(arguments, 0),
-            opts,
-            select2,
-            method, value, multiple,
-            allowedMethods = ["val", "destroy", "opened", "open", "close", "focus", "isFocused", "container", "dropdown", "onSortStart", "onSortEnd", "enable", "disable", "readonly", "positionDropdown", "data", "search"],
-            valueMethods = ["opened", "isFocused", "container", "dropdown"],
-            propertyMethods = ["val", "data"],
-            methodsMap = { search: "externalSearch" };
-
-        this.each(function () {
-            if (args.length === 0 || typeof(args[0]) === "object") {
-                opts = args.length === 0 ? {} : $.extend({}, args[0]);
-                opts.element = $(this);
-
-                if (opts.element.get(0).tagName.toLowerCase() === "select") {
-                    multiple = opts.element.prop("multiple");
-                } else {
-                    multiple = opts.multiple || false;
-                    if ("tags" in opts) {opts.multiple = multiple = true;}
-                }
-
-                select2 = multiple ? new window.Select2["class"].multi() : new window.Select2["class"].single();
-                select2.init(opts);
-            } else if (typeof(args[0]) === "string") {
-
-                if (indexOf(args[0], allowedMethods) < 0) {
-                    throw "Unknown method: " + args[0];
-                }
-
-                value = undefined;
-                select2 = $(this).data("select2");
-                if (select2 === undefined) return;
-
-                method=args[0];
-
-                if (method === "container") {
-                    value = select2.container;
-                } else if (method === "dropdown") {
-                    value = select2.dropdown;
-                } else {
-                    if (methodsMap[method]) method = methodsMap[method];
-
-                    value = select2[method].apply(select2, args.slice(1));
-                }
-                if (indexOf(args[0], valueMethods) >= 0
-                    || (indexOf(args[0], propertyMethods) >= 0 && args.length == 1)) {
-                    return false; // abort the iteration, ready to return first matched value
-                }
-            } else {
-                throw "Invalid arguments to select2 plugin: " + args;
-            }
-        });
-        return (value === undefined) ? this : value;
-    };
-
-    // plugin defaults, accessible to users
-    $.fn.select2.defaults = {
-        width: "copy",
-        loadMorePadding: 0,
-        closeOnSelect: true,
-        openOnEnter: true,
-        containerCss: {},
-        dropdownCss: {},
-        containerCssClass: "",
-        dropdownCssClass: "",
-        formatResult: function(result, container, query, escapeMarkup) {
-            var markup=[];
-            markMatch(this.text(result), query.term, markup, escapeMarkup);
-            return markup.join("");
-        },
-        transformVal: function(val) {
-            return $.trim(val);
-        },
-        formatSelection: function (data, container, escapeMarkup) {
-            return data ? escapeMarkup(this.text(data)) : undefined;
-        },
-        sortResults: function (results, container, query) {
-            return results;
-        },
-        formatResultCssClass: function(data) {return data.css;},
-        formatSelectionCssClass: function(data, container) {return undefined;},
-        minimumResultsForSearch: 0,
-        minimumInputLength: 0,
-        maximumInputLength: null,
-        maximumSelectionSize: 0,
-        id: function (e) { return e == undefined ? null : e.id; },
-        text: function (e) {
-          if (e && this.data && this.data.text) {
-            if ($.isFunction(this.data.text)) {
-              return this.data.text(e);
-            } else {
-              return e[this.data.text];
-            }
-          } else {
-            return e.text;
-          }
-        },
-        matcher: function(term, text) {
-            return stripDiacritics(''+text).toUpperCase().indexOf(stripDiacritics(''+term).toUpperCase()) >= 0;
-        },
-        separator: ",",
-        tokenSeparators: [],
-        tokenizer: defaultTokenizer,
-        escapeMarkup: defaultEscapeMarkup,
-        blurOnChange: false,
-        selectOnBlur: false,
-        adaptContainerCssClass: function(c) { return c; },
-        adaptDropdownCssClass: function(c) { return null; },
-        nextSearchTerm: function(selectedObject, currentSearchTerm) { return undefined; },
-        searchInputPlaceholder: '',
-        createSearchChoicePosition: 'top',
-        shouldFocusInput: function (instance) {
-            // Attempt to detect touch devices
-            var supportsTouchEvents = (('ontouchstart' in window) ||
-                                       (navigator.msMaxTouchPoints > 0));
-
-            // Only devices which support touch events should be special cased
-            if (!supportsTouchEvents) {
-                return true;
-            }
-
-            // Never focus the input if search is disabled
-            if (instance.opts.minimumResultsForSearch < 0) {
-                return false;
-            }
-
-            return true;
-        }
-    };
-
-    $.fn.select2.locales = [];
-
-    $.fn.select2.locales['en'] = {
-         formatMatches: function (matches) { if (matches === 1) { return "One result is available, press enter to select it."; } return matches + " results are available, use up and down arrow keys to navigate."; },
-         formatNoMatches: function () { return "No matches found"; },
-         formatAjaxError: function (jqXHR, textStatus, errorThrown) { return "Loading failed"; },
-         formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1 ? "" : "s"); },
-         formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1 ? "" : "s"); },
-         formatSelectionTooBig: function (limit) { return "You can only select " + limit + " item" + (limit == 1 ? "" : "s"); },
-         formatLoadMore: function (pageNumber) { return "Loading more results…"; },
-         formatSearching: function () { return "Searching…"; }
-    };
-
-    $.extend($.fn.select2.defaults, $.fn.select2.locales['en']);
-
-    $.fn.select2.ajaxDefaults = {
-        transport: $.ajax,
-        params: {
-            type: "GET",
-            cache: false,
-            dataType: "json"
-        }
-    };
-
-    // exports
-    window.Select2 = {
-        query: {
-            ajax: ajax,
-            local: local,
-            tags: tags
-        }, util: {
-            debounce: debounce,
-            markMatch: markMatch,
-            escapeMarkup: defaultEscapeMarkup,
-            stripDiacritics: stripDiacritics
-        }, "class": {
-            "abstract": AbstractSelect2,
-            "single": SingleSelect2,
-            "multi": MultiSelect2
-        }
-    };
-
-}(jQuery));
--- a/src/ztfy/myams/resources/js/ext/jquery-select2-3.5.2.min.js	Mon Jun 04 12:32:06 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-(function(a){if(typeof a.fn.each2=="undefined"){a.extend(a.fn,{each2:function(f){var d=a([0]),e=-1,b=this.length;while(++e<b&&(d.context=d[0]=this[e])&&f.call(d[0],e,d)!==false){}return this}})}})(jQuery);(function(D,m){if(window.Select2!==m){return}var O,x,c,a,q,o={x:0,y:0},v,w,L={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(P){P=P.which?P.which:P;switch(P){case L.LEFT:case L.RIGHT:case L.UP:case L.DOWN:return true}return false},isControl:function(Q){var P=Q.which;switch(P){case L.SHIFT:case L.CTRL:case L.ALT:return true}if(Q.metaKey){return true}return false},isFunctionKey:function(P){P=P.which?P.which:P;return P>=112&&P<=123}},B="<div class='select2-measure-scrollbar'></div>",d={"\u24B6":"A","\uFF21":"A","\u00C0":"A","\u00C1":"A","\u00C2":"A","\u1EA6":"A","\u1EA4":"A","\u1EAA":"A","\u1EA8":"A","\u00C3":"A","\u0100":"A","\u0102":"A","\u1EB0":"A","\u1EAE":"A","\u1EB4":"A","\u1EB2":"A","\u0226":"A","\u01E0":"A","\u00C4":"A","\u01DE":"A","\u1EA2":"A","\u00C5":"A","\u01FA":"A","\u01CD":"A","\u0200":"A","\u0202":"A","\u1EA0":"A","\u1EAC":"A","\u1EB6":"A","\u1E00":"A","\u0104":"A","\u023A":"A","\u2C6F":"A","\uA732":"AA","\u00C6":"AE","\u01FC":"AE","\u01E2":"AE","\uA734":"AO","\uA736":"AU","\uA738":"AV","\uA73A":"AV","\uA73C":"AY","\u24B7":"B","\uFF22":"B","\u1E02":"B","\u1E04":"B","\u1E06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24B8":"C","\uFF23":"C","\u0106":"C","\u0108":"C","\u010A":"C","\u010C":"C","\u00C7":"C","\u1E08":"C","\u0187":"C","\u023B":"C","\uA73E":"C","\u24B9":"D","\uFF24":"D","\u1E0A":"D","\u010E":"D","\u1E0C":"D","\u1E10":"D","\u1E12":"D","\u1E0E":"D","\u0110":"D","\u018B":"D","\u018A":"D","\u0189":"D","\uA779":"D","\u01F1":"DZ","\u01C4":"DZ","\u01F2":"Dz","\u01C5":"Dz","\u24BA":"E","\uFF25":"E","\u00C8":"E","\u00C9":"E","\u00CA":"E","\u1EC0":"E","\u1EBE":"E","\u1EC4":"E","\u1EC2":"E","\u1EBC":"E","\u0112":"E","\u1E14":"E","\u1E16":"E","\u0114":"E","\u0116":"E","\u00CB":"E","\u1EBA":"E","\u011A":"E","\u0204":"E","\u0206":"E","\u1EB8":"E","\u1EC6":"E","\u0228":"E","\u1E1C":"E","\u0118":"E","\u1E18":"E","\u1E1A":"E","\u0190":"E","\u018E":"E","\u24BB":"F","\uFF26":"F","\u1E1E":"F","\u0191":"F","\uA77B":"F","\u24BC":"G","\uFF27":"G","\u01F4":"G","\u011C":"G","\u1E20":"G","\u011E":"G","\u0120":"G","\u01E6":"G","\u0122":"G","\u01E4":"G","\u0193":"G","\uA7A0":"G","\uA77D":"G","\uA77E":"G","\u24BD":"H","\uFF28":"H","\u0124":"H","\u1E22":"H","\u1E26":"H","\u021E":"H","\u1E24":"H","\u1E28":"H","\u1E2A":"H","\u0126":"H","\u2C67":"H","\u2C75":"H","\uA78D":"H","\u24BE":"I","\uFF29":"I","\u00CC":"I","\u00CD":"I","\u00CE":"I","\u0128":"I","\u012A":"I","\u012C":"I","\u0130":"I","\u00CF":"I","\u1E2E":"I","\u1EC8":"I","\u01CF":"I","\u0208":"I","\u020A":"I","\u1ECA":"I","\u012E":"I","\u1E2C":"I","\u0197":"I","\u24BF":"J","\uFF2A":"J","\u0134":"J","\u0248":"J","\u24C0":"K","\uFF2B":"K","\u1E30":"K","\u01E8":"K","\u1E32":"K","\u0136":"K","\u1E34":"K","\u0198":"K","\u2C69":"K","\uA740":"K","\uA742":"K","\uA744":"K","\uA7A2":"K","\u24C1":"L","\uFF2C":"L","\u013F":"L","\u0139":"L","\u013D":"L","\u1E36":"L","\u1E38":"L","\u013B":"L","\u1E3C":"L","\u1E3A":"L","\u0141":"L","\u023D":"L","\u2C62":"L","\u2C60":"L","\uA748":"L","\uA746":"L","\uA780":"L","\u01C7":"LJ","\u01C8":"Lj","\u24C2":"M","\uFF2D":"M","\u1E3E":"M","\u1E40":"M","\u1E42":"M","\u2C6E":"M","\u019C":"M","\u24C3":"N","\uFF2E":"N","\u01F8":"N","\u0143":"N","\u00D1":"N","\u1E44":"N","\u0147":"N","\u1E46":"N","\u0145":"N","\u1E4A":"N","\u1E48":"N","\u0220":"N","\u019D":"N","\uA790":"N","\uA7A4":"N","\u01CA":"NJ","\u01CB":"Nj","\u24C4":"O","\uFF2F":"O","\u00D2":"O","\u00D3":"O","\u00D4":"O","\u1ED2":"O","\u1ED0":"O","\u1ED6":"O","\u1ED4":"O","\u00D5":"O","\u1E4C":"O","\u022C":"O","\u1E4E":"O","\u014C":"O","\u1E50":"O","\u1E52":"O","\u014E":"O","\u022E":"O","\u0230":"O","\u00D6":"O","\u022A":"O","\u1ECE":"O","\u0150":"O","\u01D1":"O","\u020C":"O","\u020E":"O","\u01A0":"O","\u1EDC":"O","\u1EDA":"O","\u1EE0":"O","\u1EDE":"O","\u1EE2":"O","\u1ECC":"O","\u1ED8":"O","\u01EA":"O","\u01EC":"O","\u00D8":"O","\u01FE":"O","\u0186":"O","\u019F":"O","\uA74A":"O","\uA74C":"O","\u01A2":"OI","\uA74E":"OO","\u0222":"OU","\u24C5":"P","\uFF30":"P","\u1E54":"P","\u1E56":"P","\u01A4":"P","\u2C63":"P","\uA750":"P","\uA752":"P","\uA754":"P","\u24C6":"Q","\uFF31":"Q","\uA756":"Q","\uA758":"Q","\u024A":"Q","\u24C7":"R","\uFF32":"R","\u0154":"R","\u1E58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1E5A":"R","\u1E5C":"R","\u0156":"R","\u1E5E":"R","\u024C":"R","\u2C64":"R","\uA75A":"R","\uA7A6":"R","\uA782":"R","\u24C8":"S","\uFF33":"S","\u1E9E":"S","\u015A":"S","\u1E64":"S","\u015C":"S","\u1E60":"S","\u0160":"S","\u1E66":"S","\u1E62":"S","\u1E68":"S","\u0218":"S","\u015E":"S","\u2C7E":"S","\uA7A8":"S","\uA784":"S","\u24C9":"T","\uFF34":"T","\u1E6A":"T","\u0164":"T","\u1E6C":"T","\u021A":"T","\u0162":"T","\u1E70":"T","\u1E6E":"T","\u0166":"T","\u01AC":"T","\u01AE":"T","\u023E":"T","\uA786":"T","\uA728":"TZ","\u24CA":"U","\uFF35":"U","\u00D9":"U","\u00DA":"U","\u00DB":"U","\u0168":"U","\u1E78":"U","\u016A":"U","\u1E7A":"U","\u016C":"U","\u00DC":"U","\u01DB":"U","\u01D7":"U","\u01D5":"U","\u01D9":"U","\u1EE6":"U","\u016E":"U","\u0170":"U","\u01D3":"U","\u0214":"U","\u0216":"U","\u01AF":"U","\u1EEA":"U","\u1EE8":"U","\u1EEE":"U","\u1EEC":"U","\u1EF0":"U","\u1EE4":"U","\u1E72":"U","\u0172":"U","\u1E76":"U","\u1E74":"U","\u0244":"U","\u24CB":"V","\uFF36":"V","\u1E7C":"V","\u1E7E":"V","\u01B2":"V","\uA75E":"V","\u0245":"V","\uA760":"VY","\u24CC":"W","\uFF37":"W","\u1E80":"W","\u1E82":"W","\u0174":"W","\u1E86":"W","\u1E84":"W","\u1E88":"W","\u2C72":"W","\u24CD":"X","\uFF38":"X","\u1E8A":"X","\u1E8C":"X","\u24CE":"Y","\uFF39":"Y","\u1EF2":"Y","\u00DD":"Y","\u0176":"Y","\u1EF8":"Y","\u0232":"Y","\u1E8E":"Y","\u0178":"Y","\u1EF6":"Y","\u1EF4":"Y","\u01B3":"Y","\u024E":"Y","\u1EFE":"Y","\u24CF":"Z","\uFF3A":"Z","\u0179":"Z","\u1E90":"Z","\u017B":"Z","\u017D":"Z","\u1E92":"Z","\u1E94":"Z","\u01B5":"Z","\u0224":"Z","\u2C7F":"Z","\u2C6B":"Z","\uA762":"Z","\u24D0":"a","\uFF41":"a","\u1E9A":"a","\u00E0":"a","\u00E1":"a","\u00E2":"a","\u1EA7":"a","\u1EA5":"a","\u1EAB":"a","\u1EA9":"a","\u00E3":"a","\u0101":"a","\u0103":"a","\u1EB1":"a","\u1EAF":"a","\u1EB5":"a","\u1EB3":"a","\u0227":"a","\u01E1":"a","\u00E4":"a","\u01DF":"a","\u1EA3":"a","\u00E5":"a","\u01FB":"a","\u01CE":"a","\u0201":"a","\u0203":"a","\u1EA1":"a","\u1EAD":"a","\u1EB7":"a","\u1E01":"a","\u0105":"a","\u2C65":"a","\u0250":"a","\uA733":"aa","\u00E6":"ae","\u01FD":"ae","\u01E3":"ae","\uA735":"ao","\uA737":"au","\uA739":"av","\uA73B":"av","\uA73D":"ay","\u24D1":"b","\uFF42":"b","\u1E03":"b","\u1E05":"b","\u1E07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24D2":"c","\uFF43":"c","\u0107":"c","\u0109":"c","\u010B":"c","\u010D":"c","\u00E7":"c","\u1E09":"c","\u0188":"c","\u023C":"c","\uA73F":"c","\u2184":"c","\u24D3":"d","\uFF44":"d","\u1E0B":"d","\u010F":"d","\u1E0D":"d","\u1E11":"d","\u1E13":"d","\u1E0F":"d","\u0111":"d","\u018C":"d","\u0256":"d","\u0257":"d","\uA77A":"d","\u01F3":"dz","\u01C6":"dz","\u24D4":"e","\uFF45":"e","\u00E8":"e","\u00E9":"e","\u00EA":"e","\u1EC1":"e","\u1EBF":"e","\u1EC5":"e","\u1EC3":"e","\u1EBD":"e","\u0113":"e","\u1E15":"e","\u1E17":"e","\u0115":"e","\u0117":"e","\u00EB":"e","\u1EBB":"e","\u011B":"e","\u0205":"e","\u0207":"e","\u1EB9":"e","\u1EC7":"e","\u0229":"e","\u1E1D":"e","\u0119":"e","\u1E19":"e","\u1E1B":"e","\u0247":"e","\u025B":"e","\u01DD":"e","\u24D5":"f","\uFF46":"f","\u1E1F":"f","\u0192":"f","\uA77C":"f","\u24D6":"g","\uFF47":"g","\u01F5":"g","\u011D":"g","\u1E21":"g","\u011F":"g","\u0121":"g","\u01E7":"g","\u0123":"g","\u01E5":"g","\u0260":"g","\uA7A1":"g","\u1D79":"g","\uA77F":"g","\u24D7":"h","\uFF48":"h","\u0125":"h","\u1E23":"h","\u1E27":"h","\u021F":"h","\u1E25":"h","\u1E29":"h","\u1E2B":"h","\u1E96":"h","\u0127":"h","\u2C68":"h","\u2C76":"h","\u0265":"h","\u0195":"hv","\u24D8":"i","\uFF49":"i","\u00EC":"i","\u00ED":"i","\u00EE":"i","\u0129":"i","\u012B":"i","\u012D":"i","\u00EF":"i","\u1E2F":"i","\u1EC9":"i","\u01D0":"i","\u0209":"i","\u020B":"i","\u1ECB":"i","\u012F":"i","\u1E2D":"i","\u0268":"i","\u0131":"i","\u24D9":"j","\uFF4A":"j","\u0135":"j","\u01F0":"j","\u0249":"j","\u24DA":"k","\uFF4B":"k","\u1E31":"k","\u01E9":"k","\u1E33":"k","\u0137":"k","\u1E35":"k","\u0199":"k","\u2C6A":"k","\uA741":"k","\uA743":"k","\uA745":"k","\uA7A3":"k","\u24DB":"l","\uFF4C":"l","\u0140":"l","\u013A":"l","\u013E":"l","\u1E37":"l","\u1E39":"l","\u013C":"l","\u1E3D":"l","\u1E3B":"l","\u017F":"l","\u0142":"l","\u019A":"l","\u026B":"l","\u2C61":"l","\uA749":"l","\uA781":"l","\uA747":"l","\u01C9":"lj","\u24DC":"m","\uFF4D":"m","\u1E3F":"m","\u1E41":"m","\u1E43":"m","\u0271":"m","\u026F":"m","\u24DD":"n","\uFF4E":"n","\u01F9":"n","\u0144":"n","\u00F1":"n","\u1E45":"n","\u0148":"n","\u1E47":"n","\u0146":"n","\u1E4B":"n","\u1E49":"n","\u019E":"n","\u0272":"n","\u0149":"n","\uA791":"n","\uA7A5":"n","\u01CC":"nj","\u24DE":"o","\uFF4F":"o","\u00F2":"o","\u00F3":"o","\u00F4":"o","\u1ED3":"o","\u1ED1":"o","\u1ED7":"o","\u1ED5":"o","\u00F5":"o","\u1E4D":"o","\u022D":"o","\u1E4F":"o","\u014D":"o","\u1E51":"o","\u1E53":"o","\u014F":"o","\u022F":"o","\u0231":"o","\u00F6":"o","\u022B":"o","\u1ECF":"o","\u0151":"o","\u01D2":"o","\u020D":"o","\u020F":"o","\u01A1":"o","\u1EDD":"o","\u1EDB":"o","\u1EE1":"o","\u1EDF":"o","\u1EE3":"o","\u1ECD":"o","\u1ED9":"o","\u01EB":"o","\u01ED":"o","\u00F8":"o","\u01FF":"o","\u0254":"o","\uA74B":"o","\uA74D":"o","\u0275":"o","\u01A3":"oi","\u0223":"ou","\uA74F":"oo","\u24DF":"p","\uFF50":"p","\u1E55":"p","\u1E57":"p","\u01A5":"p","\u1D7D":"p","\uA751":"p","\uA753":"p","\uA755":"p","\u24E0":"q","\uFF51":"q","\u024B":"q","\uA757":"q","\uA759":"q","\u24E1":"r","\uFF52":"r","\u0155":"r","\u1E59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1E5B":"r","\u1E5D":"r","\u0157":"r","\u1E5F":"r","\u024D":"r","\u027D":"r","\uA75B":"r","\uA7A7":"r","\uA783":"r","\u24E2":"s","\uFF53":"s","\u00DF":"s","\u015B":"s","\u1E65":"s","\u015D":"s","\u1E61":"s","\u0161":"s","\u1E67":"s","\u1E63":"s","\u1E69":"s","\u0219":"s","\u015F":"s","\u023F":"s","\uA7A9":"s","\uA785":"s","\u1E9B":"s","\u24E3":"t","\uFF54":"t","\u1E6B":"t","\u1E97":"t","\u0165":"t","\u1E6D":"t","\u021B":"t","\u0163":"t","\u1E71":"t","\u1E6F":"t","\u0167":"t","\u01AD":"t","\u0288":"t","\u2C66":"t","\uA787":"t","\uA729":"tz","\u24E4":"u","\uFF55":"u","\u00F9":"u","\u00FA":"u","\u00FB":"u","\u0169":"u","\u1E79":"u","\u016B":"u","\u1E7B":"u","\u016D":"u","\u00FC":"u","\u01DC":"u","\u01D8":"u","\u01D6":"u","\u01DA":"u","\u1EE7":"u","\u016F":"u","\u0171":"u","\u01D4":"u","\u0215":"u","\u0217":"u","\u01B0":"u","\u1EEB":"u","\u1EE9":"u","\u1EEF":"u","\u1EED":"u","\u1EF1":"u","\u1EE5":"u","\u1E73":"u","\u0173":"u","\u1E77":"u","\u1E75":"u","\u0289":"u","\u24E5":"v","\uFF56":"v","\u1E7D":"v","\u1E7F":"v","\u028B":"v","\uA75F":"v","\u028C":"v","\uA761":"vy","\u24E6":"w","\uFF57":"w","\u1E81":"w","\u1E83":"w","\u0175":"w","\u1E87":"w","\u1E85":"w","\u1E98":"w","\u1E89":"w","\u2C73":"w","\u24E7":"x","\uFF58":"x","\u1E8B":"x","\u1E8D":"x","\u24E8":"y","\uFF59":"y","\u1EF3":"y","\u00FD":"y","\u0177":"y","\u1EF9":"y","\u0233":"y","\u1E8F":"y","\u00FF":"y","\u1EF7":"y","\u1E99":"y","\u1EF5":"y","\u01B4":"y","\u024F":"y","\u1EFF":"y","\u24E9":"z","\uFF5A":"z","\u017A":"z","\u1E91":"z","\u017C":"z","\u017E":"z","\u1E93":"z","\u1E95":"z","\u01B6":"z","\u0225":"z","\u0240":"z","\u2C6C":"z","\uA763":"z","\u0386":"\u0391","\u0388":"\u0395","\u0389":"\u0397","\u038A":"\u0399","\u03AA":"\u0399","\u038C":"\u039F","\u038E":"\u03A5","\u03AB":"\u03A5","\u038F":"\u03A9","\u03AC":"\u03B1","\u03AD":"\u03B5","\u03AE":"\u03B7","\u03AF":"\u03B9","\u03CA":"\u03B9","\u0390":"\u03B9","\u03CC":"\u03BF","\u03CD":"\u03C5","\u03CB":"\u03C5","\u03B0":"\u03C5","\u03C9":"\u03C9","\u03C2":"\u03C3"};v=D(document);a=(function(){var P=1;return function(){return P++}}());function p(P){var Q=D(document.createTextNode(""));P.before(Q);Q.before(P);Q.remove()}function e(Q){function P(R){return d[R]||R}return Q.replace(/[^\u0000-\u007E]/g,P)}function r(R,S){var Q=0,P=S.length;for(;Q<P;Q=Q+1){if(t(R,S[Q])){return Q}}return -1}function N(){var P=D(B);P.appendTo(document.body);var Q={width:P.width()-P[0].clientWidth,height:P.height()-P[0].clientHeight};P.remove();return Q}function t(Q,P){if(Q===P){return true}if(Q===m||P===m){return false}if(Q===null||P===null){return false}if(Q.constructor===String){return Q+""===P+""}if(P.constructor===String){return P+""===Q+""}return false}function i(R,T,Q){var U,S,P;if(R===null||R.length<1){return[]}U=R.split(T);for(S=0,P=U.length;S<P;S=S+1){U[S]=Q(U[S])}return U}function h(P){return P.outerWidth(false)-P.width()}function G(Q){var P="keyup-change-value";Q.on("keydown",function(){if(D.data(Q,P)===m){D.data(Q,P,Q.val())}});Q.on("keyup",function(){var R=D.data(Q,P);if(R!==m&&Q.val()!==R){D.removeData(Q,P);Q.trigger("keyup-change")}})}function K(P){P.on("mousemove",function(R){var Q=o;if(Q===m||Q.x!==R.pageX||Q.y!==R.pageY){D(R.target).trigger("mousemove-filtered",R)}})}function k(S,Q,P){P=P||m;var R;return function(){var T=arguments;window.clearTimeout(R);R=window.setTimeout(function(){Q.apply(P,T)},S)}}function l(P,R){var Q=k(P,function(S){R.trigger("scroll-debounced",S)});R.on("scroll",function(S){if(r(S.target,R.get())>=0){Q(S)}})}function J(P){if(P[0]===document.activeElement){return}window.setTimeout(function(){var S=P[0],T=P.val().length,R;P.focus();var Q=(S.offsetWidth>0||S.offsetHeight>0);if(Q&&S===document.activeElement){if(S.setSelectionRange){S.setSelectionRange(T,T)}else{if(S.createTextRange){R=S.createTextRange();R.collapse(false);R.select()}}}},0)}function f(P){P=D(P)[0];var S=0;var Q=0;if("selectionStart" in P){S=P.selectionStart;Q=P.selectionEnd-S}else{if("selection" in document){P.focus();var R=document.selection.createRange();Q=document.selection.createRange().text.length;R.moveStart("character",-P.value.length);S=R.text.length-Q}}return{offset:S,length:Q}}function A(P){P.preventDefault();P.stopPropagation()}function b(P){P.preventDefault();P.stopImmediatePropagation()}function n(Q){if(!q){var P=Q[0].currentStyle||window.getComputedStyle(Q[0],null);q=D(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:P.fontSize,fontFamily:P.fontFamily,fontStyle:P.fontStyle,fontWeight:P.fontWeight,letterSpacing:P.letterSpacing,textTransform:P.textTransform,whiteSpace:"nowrap"});q.attr("class","select2-sizer");D(document.body).append(q)}q.text(Q.val());return q.width()}function j(Q,U,P){var S,T=[],R;S=D.trim(Q.attr("class"));if(S){S=""+S;D(S.split(/\s+/)).each2(function(){if(this.indexOf("select2-")===0){T.push(this)}})}S=D.trim(U.attr("class"));if(S){S=""+S;D(S.split(/\s+/)).each2(function(){if(this.indexOf("select2-")!==0){R=P(this);if(R){T.push(R)}}})}Q.attr("class",T.join(" "))}function u(U,T,R,P){var S=e(U.toUpperCase()).indexOf(e(T.toUpperCase())),Q=T.length;if(S<0){R.push(P(U));return}R.push(P(U.substring(0,S)));R.push("<span class='select2-match'>");R.push(P(U.substring(S,S+Q)));R.push("</span>");R.push(P(U.substring(S+Q,U.length)))}function H(P){var Q={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return String(P).replace(/[&<>"'\/\\]/g,function(R){return Q[R]})}function E(Q){var T,R=null,U=Q.quietMillis||100,S=Q.url,P=this;return function(V){window.clearTimeout(T);T=window.setTimeout(function(){var Y=Q.data,X=S,aa=Q.transport||D.fn.select2.ajaxDefaults.transport,W={type:Q.type||"GET",cache:Q.cache||false,jsonpCallback:Q.jsonpCallback||m,dataType:Q.dataType||"json"},Z=D.extend({},D.fn.select2.ajaxDefaults.params,W);Y=Y?Y.call(P,V.term,V.page,V.context):null;X=(typeof X==="function")?X.call(P,V.term,V.page,V.context):X;if(R&&typeof R.abort==="function"){R.abort()}if(Q.params){if(D.isFunction(Q.params)){D.extend(Z,Q.params.call(P))}else{D.extend(Z,Q.params)}}D.extend(Z,{url:X,dataType:Q.dataType,data:Y,success:function(ac){var ab=Q.results(ac,V.page,V);V.callback(ab)},error:function(ac,ae,ad){var ab={hasError:true,jqXHR:ac,textStatus:ae,errorThrown:ad};V.callback(ab)}});R=aa.call(P,Z)},U)}}function I(Q){var T=Q,S,R,U=function(V){return""+V.text};if(D.isArray(T)){R=T;T={results:R}}if(D.isFunction(T)===false){R=T;T=function(){return R}}var P=T();if(P.text){U=P.text;if(!D.isFunction(U)){S=P.text;U=function(V){return V[S]}}}return function(X){var W=X.term,V={results:[]},Y;if(W===""){X.callback(T());return}Y=function(aa,ac){var ab,Z;aa=aa[0];if(aa.children){ab={};for(Z in aa){if(aa.hasOwnProperty(Z)){ab[Z]=aa[Z]}}ab.children=[];D(aa.children).each2(function(ad,ae){Y(ae,ab.children)});if(ab.children.length||X.matcher(W,U(ab),aa)){ac.push(ab)}}else{if(X.matcher(W,U(aa),aa)){ac.push(aa)}}};D(T().results).each2(function(aa,Z){Y(Z,V.results)});X.callback(V)}}function z(Q){var P=D.isFunction(Q);return function(U){var T=U.term,S={results:[]};var R=P?Q(U):Q;if(D.isArray(R)){D(R).each(function(){var V=this.text!==m,W=V?this.text:this;if(T===""||U.matcher(T,W)){S.results.push(V?this:{id:this,text:this})}});U.callback(S)}}}function y(P,Q){if(D.isFunction(P)){return true}if(!P){return false}if(typeof(P)==="string"){return true}throw new Error(Q+" must be a string, function, or falsy value")}function C(R,Q){if(D.isFunction(R)){var P=Array.prototype.slice.call(arguments,2);return R.apply(Q,P)}return R}function s(P){var Q=0;D.each(P,function(R,S){if(S.children){Q+=s(S.children)}else{Q++}});return Q}function g(X,Y,V,P){var Q=X,Z=false,S,W,T,R,U;if(!P.createSearchChoice||!P.tokenSeparators||P.tokenSeparators.length<1){return m}while(true){W=-1;for(T=0,R=P.tokenSeparators.length;T<R;T++){U=P.tokenSeparators[T];W=X.indexOf(U);if(W>=0){break}}if(W<0){break}S=X.substring(0,W);X=X.substring(W+U.length);if(S.length>0){S=P.createSearchChoice.call(this,S,Y);if(S!==m&&S!==null&&P.id(S)!==m&&P.id(S)!==null){Z=false;for(T=0,R=Y.length;T<R;T++){if(t(P.id(S),P.id(Y[T]))){Z=true;break}}if(!Z){V(S)}}}}if(Q!==X){return X}}function F(){var P=this;D.each(arguments,function(R,Q){P[Q].remove();P[Q]=null})}function M(P,Q){var R=function(){};R.prototype=new P;R.prototype.constructor=R;R.prototype.parent=P.prototype;R.prototype=D.extend(R.prototype,Q);return R}O=M(Object,{bind:function(Q){var P=this;return function(){Q.apply(P,arguments)}},init:function(T){var R,Q,U=".select2-results";this.opts=T=this.prepareOpts(T);this.id=T.id;if(T.element.data("select2")!==m&&T.element.data("select2")!==null){T.element.data("select2").destroy()}this.container=this.createContainer();this.liveRegion=D(".select2-hidden-accessible");if(this.liveRegion.length==0){this.liveRegion=D("<span>",{role:"status","aria-live":"polite"}).addClass("select2-hidden-accessible").appendTo(document.body)}this.containerId="s2id_"+(T.element.attr("id")||"autogen"+a());this.containerEventName=this.containerId.replace(/([.])/g,"_").replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1");this.container.attr("id",this.containerId);this.container.attr("title",T.element.attr("title"));this.body=D(document.body);j(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.attr("style",T.element.attr("style"));this.container.css(C(T.containerCss,this.opts.element));this.container.addClass(C(T.containerCssClass,this.opts.element));this.elementTabIndex=this.opts.element.attr("tabindex");this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",A);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");j(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass);this.dropdown.addClass(C(T.dropdownCssClass,this.opts.element));this.dropdown.data("select2",this);this.dropdown.on("click",A);this.results=R=this.container.find(U);this.search=Q=this.container.find("input.select2-input");this.queryCount=0;this.resultsPage=0;this.context=null;this.initContainer();this.container.on("click",A);K(this.results);this.dropdown.on("mousemove-filtered",U,this.bind(this.highlightUnderEvent));this.dropdown.on("touchstart touchmove touchend",U,this.bind(function(V){this._touchEvent=true;this.highlightUnderEvent(V)}));this.dropdown.on("touchmove",U,this.bind(this.touchMoved));this.dropdown.on("touchstart touchend",U,this.bind(this.clearTouchMoved));this.dropdown.on("click",this.bind(function(V){if(this._touchEvent){this._touchEvent=false;this.selectHighlighted()}}));l(80,this.results);this.dropdown.on("scroll-debounced",U,this.bind(this.loadMoreIfNeeded));D(this.container).on("change",".select2-input",function(V){V.stopPropagation()});D(this.dropdown).on("change",".select2-input",function(V){V.stopPropagation()});if(D.fn.mousewheel){R.mousewheel(function(Y,Z,W,V){var X=R.scrollTop();if(V>0&&X-V<=0){R.scrollTop(0);A(Y)}else{if(V<0&&R.get(0).scrollHeight-R.scrollTop()+V<=R.height()){R.scrollTop(R.get(0).scrollHeight-R.height());A(Y)}}})}G(Q);Q.on("keyup-change input paste",this.bind(this.updateResults));Q.on("focus",function(){Q.addClass("select2-focused")});Q.on("blur",function(){Q.removeClass("select2-focused")});this.dropdown.on("mouseup",U,this.bind(function(V){if(D(V.target).closest(".select2-result-selectable").length>0){this.highlightUnderEvent(V);this.selectHighlighted(V)}}));this.dropdown.on("click mouseup mousedown touchstart touchend focusin",function(V){V.stopPropagation()});this.nextSearchTerm=m;if(D.isFunction(this.opts.initSelection)){this.initSelection();this.monitorSource()}if(T.maximumInputLength!==null){this.search.attr("maxlength",T.maximumInputLength)}var S=T.element.prop("disabled");if(S===m){S=false}this.enable(!S);var P=T.element.prop("readonly");if(P===m){P=false}this.readonly(P);w=w||N();this.autofocus=T.element.prop("autofocus");T.element.prop("autofocus",false);if(this.autofocus){this.focus()}this.search.attr("placeholder",T.searchInputPlaceholder)},destroy:function(){var R=this.opts.element,Q=R.data("select2"),P=this;this.close();if(R.length&&R[0].detachEvent&&P._sync){R.each(function(){if(P._sync){this.detachEvent("onpropertychange",P._sync)}})}if(this.propertyObserver){this.propertyObserver.disconnect();this.propertyObserver=null}this._sync=null;if(Q!==m){Q.container.remove();Q.liveRegion.remove();Q.dropdown.remove();R.show().removeData("select2").off(".select2").prop("autofocus",this.autofocus||false);if(this.elementTabIndex){R.attr({tabindex:this.elementTabIndex})}else{R.removeAttr("tabindex")}R.show()}F.call(this,"container","liveRegion","dropdown","results","search")},optionToData:function(P){if(P.is("option")){return{id:P.prop("value"),text:P.text(),element:P.get(),css:P.attr("class"),disabled:P.prop("disabled"),locked:t(P.attr("locked"),"locked")||t(P.data("locked"),true)}}else{if(P.is("optgroup")){return{text:P.attr("label"),children:[],element:P.get(),css:P.attr("class")}}}},prepareOpts:function(U){var S,Q,P,T,R=this;S=U.element;if(S.get(0).tagName.toLowerCase()==="select"){this.select=Q=U.element}if(Q){D.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in U){throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}})}U=D.extend({},{populateResults:function(W,X,Z){var Y,aa=this.opts.id,V=this.liveRegion;Y=function(ai,ac,ah){var aj,ae,ao,al,af,an,ad,am,ak,ag;ai=U.sortResults(ai,ac,Z);var ab=[];for(aj=0,ae=ai.length;aj<ae;aj=aj+1){ao=ai[aj];af=(ao.disabled===true);al=(!af)&&(aa(ao)!==m);an=ao.children&&ao.children.length>0;ad=D("<li></li>");ad.addClass("select2-results-dept-"+ah);ad.addClass("select2-result");ad.addClass(al?"select2-result-selectable":"select2-result-unselectable");if(af){ad.addClass("select2-disabled")}if(an){ad.addClass("select2-result-with-children")}ad.addClass(R.opts.formatResultCssClass(ao));ad.attr("role","presentation");am=D(document.createElement("div"));am.addClass("select2-result-label");am.attr("id","select2-result-label-"+a());am.attr("role","option");ag=U.formatResult(ao,am,Z,R.opts.escapeMarkup);if(ag!==m){am.html(ag);ad.append(am)}if(an){ak=D("<ul></ul>");ak.addClass("select2-result-sub");Y(ao.children,ak,ah+1);ad.append(ak)}ad.data("select2-data",ao);ab.push(ad[0])}ac.append(ab);V.text(U.formatMatches(ai.length))};Y(X,W,0)}},D.fn.select2.defaults,U);if(typeof(U.id)!=="function"){P=U.id;U.id=function(V){return V[P]}}if(D.isArray(U.element.data("select2Tags"))){if("tags" in U){throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+U.element.attr("id")}U.tags=U.element.data("select2Tags")}if(Q){U.query=this.bind(function(Z){var Y={results:[],more:false},X=Z.term,W,V,aa;aa=function(ab,ad){var ac;if(ab.is("option")){if(Z.matcher(X,ab.text(),ab)){ad.push(R.optionToData(ab))}}else{if(ab.is("optgroup")){ac=R.optionToData(ab);ab.children().each2(function(ae,af){aa(af,ac.children)});if(ac.children.length>0){ad.push(ac)}}}};W=S.children();if(this.getPlaceholder()!==m&&W.length>0){V=this.getPlaceholderOption();if(V){W=W.not(V)}}W.each2(function(ab,ac){aa(ac,Y.results)});Z.callback(Y)});U.id=function(V){return V.id}}else{if(!("query" in U)){if("ajax" in U){T=U.element.data("ajax-url");if(T&&T.length>0){U.ajax.url=T}U.query=E.call(U.element,U.ajax)}else{if("data" in U){U.query=I(U.data)}else{if("tags" in U){U.query=z(U.tags);if(U.createSearchChoice===m){U.createSearchChoice=function(V){return{id:D.trim(V),text:D.trim(V)}}}if(U.initSelection===m){U.initSelection=function(V,X){var W=[];D(i(V.val(),U.separator,U.transformVal)).each(function(){var Z={id:this,text:this},Y=U.tags;if(D.isFunction(Y)){Y=Y()}D(Y).each(function(){if(t(this.id,Z.id)){Z=this;return false}});W.push(Z)});X(W)}}}}}}}if(typeof(U.query)!=="function"){throw"query function not defined for Select2 "+U.element.attr("id")}if(U.createSearchChoicePosition==="top"){U.createSearchChoicePosition=function(W,V){W.unshift(V)}}else{if(U.createSearchChoicePosition==="bottom"){U.createSearchChoicePosition=function(W,V){W.push(V)}}else{if(typeof(U.createSearchChoicePosition)!=="function"){throw"invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function"}}}return U},monitorSource:function(){var R=this.opts.element,Q,P=this;R.on("change.select2",this.bind(function(S){if(this.opts.element.data("select2-change-triggered")!==true){this.initSelection()}}));this._sync=this.bind(function(){var T=R.prop("disabled");if(T===m){T=false}this.enable(!T);var S=R.prop("readonly");if(S===m){S=false}this.readonly(S);if(this.container){j(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.addClass(C(this.opts.containerCssClass,this.opts.element))}if(this.dropdown){j(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass);this.dropdown.addClass(C(this.opts.dropdownCssClass,this.opts.element))}});if(R.length&&R[0].attachEvent){R.each(function(){this.attachEvent("onpropertychange",P._sync)})}Q=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(Q!==m){if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}this.propertyObserver=new Q(function(S){D.each(S,P._sync)});this.propertyObserver.observe(R.get(0),{attributes:true,subtree:false})}},triggerSelect:function(Q){var P=D.Event("select2-selecting",{val:this.id(Q),object:Q,choice:Q});this.opts.element.trigger(P);return !P.isDefaultPrevented()},triggerChange:function(P){P=P||{};P=D.extend({},P,{type:"change",val:this.val()});this.opts.element.data("select2-change-triggered",true);this.opts.element.trigger(P);this.opts.element.data("select2-change-triggered",false);this.opts.element.click();if(this.opts.blurOnChange){this.opts.element.blur()}},isInterfaceEnabled:function(){return this.enabledInterface===true},enableInterface:function(){var P=this._enabled&&!this._readonly,Q=!P;if(P===this.enabledInterface){return false}this.container.toggleClass("select2-container-disabled",Q);this.close();this.enabledInterface=P;return true},enable:function(P){if(P===m){P=true}if(this._enabled===P){return}this._enabled=P;this.opts.element.prop("disabled",!P);this.enableInterface()},disable:function(){this.enable(false)},readonly:function(P){if(P===m){P=false}if(this._readonly===P){return}this._readonly=P;this.opts.element.prop("readonly",P);this.enableInterface()},opened:function(){return(this.container)?this.container.hasClass("select2-dropdown-open"):false},positionDropdown:function(){var R=this.dropdown,aa=this.container,U=aa.offset(),ae=aa.outerHeight(false),af=aa.outerWidth(false),Z=R.outerHeight(false),ac=D(window),ak=ac.width(),X=ac.height(),Q=ac.scrollLeft()+ak,aj=ac.scrollTop()+X,S=U.top+ae,ah=U.left,P=S+Z<=aj,W=(U.top-Z)>=ac.scrollTop(),ab=R.outerWidth(false),am=function(){return ah+ab<=Q},ag=function(){return U.left+Q+aa.outerWidth(false)>ab},al=R.hasClass("select2-drop-above"),V,ai,T,Y,ad;if(al){ai=true;if(!W&&P){T=true;ai=false}}else{ai=false;if(!P&&W){T=true;ai=true}}if(T){R.hide();U=this.container.offset();ae=this.container.outerHeight(false);af=this.container.outerWidth(false);Z=R.outerHeight(false);Q=ac.scrollLeft()+ak;aj=ac.scrollTop()+X;S=U.top+ae;ah=U.left;ab=R.outerWidth(false);R.show();this.focusSearch()}if(this.opts.dropdownAutoWidth){ad=D(".select2-results",R)[0];R.addClass("select2-drop-auto-width");R.css("width","");ab=R.outerWidth(false)+(ad.scrollHeight===ad.clientHeight?0:w.width);ab>af?af=ab:ab=af;Z=R.outerHeight(false)}else{this.container.removeClass("select2-drop-auto-width")}if(this.body.css("position")!=="static"){V=this.body.offset();S-=V.top;ah-=V.left}if(!am()&&ag()){ah=U.left+this.container.outerWidth(false)-ab}Y={left:ah,width:af};if(ai){Y.top=U.top-Z;Y.bottom="auto";this.container.addClass("select2-drop-above");R.addClass("select2-drop-above")}else{Y.top=S;Y.bottom="auto";this.container.removeClass("select2-drop-above");R.removeClass("select2-drop-above")}Y=D.extend(Y,C(this.opts.dropdownCss,this.opts.element));R.css(Y)},shouldOpen:function(){var P;if(this.opened()){return false}if(this._enabled===false||this._readonly===true){return false}P=D.Event("select2-opening");this.opts.element.trigger(P);return !P.isDefaultPrevented()},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above");this.dropdown.removeClass("select2-drop-above")},open:function(){if(!this.shouldOpen()){return false}this.opening();v.on("mousemove.select2Event",function(P){o.x=P.pageX;o.y=P.pageY});return true},opening:function(){var U=this.containerEventName,P="scroll."+U,S="resize."+U,R="orientationchange."+U,Q;this.container.addClass("select2-dropdown-open").addClass("select2-container-active");this.clearDropdownAlignmentPreference();if(this.dropdown[0]!==this.body.children().last()[0]){this.dropdown.detach().appendTo(this.body)}Q=D("#select2-drop-mask");if(Q.length===0){Q=D(document.createElement("div"));Q.attr("id","select2-drop-mask").attr("class","select2-drop-mask");Q.hide();Q.appendTo(this.body);Q.on("mousedown touchstart click",function(W){p(Q);var X=D("#select2-drop"),V;if(X.length>0){V=X.data("select2");if(V.opts.selectOnBlur){V.selectHighlighted({noFocus:true})}V.close();W.preventDefault();W.stopPropagation()}})}if(this.dropdown.prev()[0]!==Q[0]){this.dropdown.before(Q)}D("#select2-drop").removeAttr("id");this.dropdown.attr("id","select2-drop");Q.show();this.positionDropdown();this.dropdown.show();this.positionDropdown();this.dropdown.addClass("select2-drop-active");var T=this;this.container.parents().add(window).each(function(){D(this).on(S+" "+P+" "+R,function(V){if(T.opened()){T.positionDropdown()}})})},close:function(){if(!this.opened()){return}var S=this.containerEventName,P="scroll."+S,R="resize."+S,Q="orientationchange."+S;this.container.parents().add(window).each(function(){D(this).off(P).off(R).off(Q)});this.clearDropdownAlignmentPreference();D("#select2-drop-mask").hide();this.dropdown.removeAttr("id");this.dropdown.hide();this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");this.results.empty();v.off("mousemove.select2Event");this.clearSearch();this.search.removeClass("select2-active");this.opts.element.trigger(D.Event("select2-close"))},externalSearch:function(P){this.open();this.search.val(P);this.updateResults(false)},clearSearch:function(){},getMaximumSelectionSize:function(){return C(this.opts.maximumSelectionSize,this.opts.element)},ensureHighlightVisible:function(){var S=this.results,R,V,Q,U,P,X,W,T;V=this.highlight();if(V<0){return}if(V==0){S.scrollTop(0);return}R=this.findHighlightableChoices().find(".select2-result-label");Q=D(R[V]);T=(Q.offset()||{}).top||0;U=T+Q.outerHeight(true);if(V===R.length-1){W=S.find("li.select2-more-results");if(W.length>0){U=W.offset().top+W.outerHeight(true)}}P=S.offset().top+S.outerHeight(false);if(U>P){S.scrollTop(S.scrollTop()+(U-P))}X=T-S.offset().top;if(X<0&&Q.css("display")!="none"){S.scrollTop(S.scrollTop()+X)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)")},moveHighlight:function(S){var R=this.findHighlightableChoices(),Q=this.highlight();while(Q>-1&&Q<R.length){Q+=S;var P=D(R[Q]);if(P.hasClass("select2-result-selectable")&&!P.hasClass("select2-disabled")&&!P.hasClass("select2-selected")){this.highlight(Q);break}}},highlight:function(Q){var S=this.findHighlightableChoices(),P,R;if(arguments.length===0){return r(S.filter(".select2-highlighted")[0],S.get())}if(Q>=S.length){Q=S.length-1}if(Q<0){Q=0}this.removeHighlight();P=D(S[Q]);P.addClass("select2-highlighted");this.search.attr("aria-activedescendant",P.find(".select2-result-label").attr("id"));this.ensureHighlightVisible();this.liveRegion.text(P.text());R=P.data("select2-data");if(R){this.opts.element.trigger({type:"select2-highlight",val:this.id(R),choice:R})}},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},touchMoved:function(){this._touchMoved=true},clearTouchMoved:function(){this._touchMoved=false},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(Q){var P=D(Q.target).closest(".select2-result-selectable");if(P.length>0&&!P.is(".select2-highlighted")){var R=this.findHighlightableChoices();this.highlight(R.index(P))}else{if(P.length==0){this.removeHighlight()}}},loadMoreIfNeeded:function(){var T=this.results,S=T.find("li.select2-more-results"),V,U=this.resultsPage+1,P=this,R=this.search.val(),Q=this.context;if(S.length===0){return}V=S.offset().top-T.offset().top-T.height();if(V<=this.opts.loadMorePadding){S.addClass("select2-active");this.opts.query({element:this.opts.element,term:R,page:U,context:Q,matcher:this.opts.matcher,callback:this.bind(function(W){if(!P.opened()){return}P.opts.populateResults.call(this,T,W.results,{term:R,page:U,context:Q});P.postprocessResults(W,false,false);if(W.more===true){S.detach().appendTo(T).html(P.opts.escapeMarkup(C(P.opts.formatLoadMore,P.opts.element,U+1)));window.setTimeout(function(){P.loadMoreIfNeeded()},10)}else{S.remove()}P.positionDropdown();P.resultsPage=U;P.context=W.context;this.opts.element.trigger({type:"select2-loaded",items:W})})})}},tokenize:function(){},updateResults:function(X){var ab=this.search,V=this.results,P=this.opts,U,aa=this,Y,T=ab.val(),R=D.data(this.container,"select2-last-term"),Z;if(X!==true&&R&&t(T,R)){return}D.data(this.container,"select2-last-term",T);if(X!==true&&(this.showSearchInput===false||!this.opened())){return}function W(){ab.removeClass("select2-active");aa.positionDropdown();if(V.find(".select2-no-results,.select2-selection-limit,.select2-searching").length){aa.liveRegion.text(V.text())}else{aa.liveRegion.text(aa.opts.formatMatches(V.find('.select2-result-selectable:not(".select2-selected")').length))}}function Q(ac){V.html(ac);W()}Z=++this.queryCount;var S=this.getMaximumSelectionSize();if(S>=1){U=this.data();if(D.isArray(U)&&U.length>=S&&y(P.formatSelectionTooBig,"formatSelectionTooBig")){Q("<li class='select2-selection-limit'>"+C(P.formatSelectionTooBig,P.element,S)+"</li>");return}}if(ab.val().length<P.minimumInputLength){if(y(P.formatInputTooShort,"formatInputTooShort")){Q("<li class='select2-no-results'>"+C(P.formatInputTooShort,P.element,ab.val(),P.minimumInputLength)+"</li>")}else{Q("")}if(X&&this.showSearch){this.showSearch(true)}return}if(P.maximumInputLength&&ab.val().length>P.maximumInputLength){if(y(P.formatInputTooLong,"formatInputTooLong")){Q("<li class='select2-no-results'>"+C(P.formatInputTooLong,P.element,ab.val(),P.maximumInputLength)+"</li>")}else{Q("")}return}if(P.formatSearching&&this.findHighlightableChoices().length===0){Q("<li class='select2-searching'>"+C(P.formatSearching,P.element)+"</li>")}ab.addClass("select2-active");this.removeHighlight();Y=this.tokenize();if(Y!=m&&Y!=null){ab.val(Y)}this.resultsPage=1;P.query({element:P.element,term:ab.val(),page:this.resultsPage,context:null,matcher:P.matcher,callback:this.bind(function(ad){var ac;if(Z!=this.queryCount){return}if(!this.opened()){this.search.removeClass("select2-active");return}if(ad.hasError!==m&&y(P.formatAjaxError,"formatAjaxError")){Q("<li class='select2-ajax-error'>"+C(P.formatAjaxError,P.element,ad.jqXHR,ad.textStatus,ad.errorThrown)+"</li>");return}this.context=(ad.context===m)?null:ad.context;if(this.opts.createSearchChoice&&ab.val()!==""){ac=this.opts.createSearchChoice.call(aa,ab.val(),ad.results);if(ac!==m&&ac!==null&&aa.id(ac)!==m&&aa.id(ac)!==null){if(D(ad.results).filter(function(){return t(aa.id(this),aa.id(ac))}).length===0){this.opts.createSearchChoicePosition(ad.results,ac)}}}if(ad.results.length===0&&y(P.formatNoMatches,"formatNoMatches")){Q("<li class='select2-no-results'>"+C(P.formatNoMatches,P.element,ab.val())+"</li>");return}V.empty();aa.opts.populateResults.call(this,V,ad.results,{term:ab.val(),page:this.resultsPage,context:null});if(ad.more===true&&y(P.formatLoadMore,"formatLoadMore")){V.append("<li class='select2-more-results'>"+P.escapeMarkup(C(P.formatLoadMore,P.element,this.resultsPage))+"</li>");window.setTimeout(function(){aa.loadMoreIfNeeded()},10)}this.postprocessResults(ad,X);W();this.opts.element.trigger({type:"select2-loaded",items:ad})})})},cancel:function(){this.close()},blur:function(){if(this.opts.selectOnBlur){this.selectHighlighted({noFocus:true})}this.close();this.container.removeClass("select2-container-active");if(this.search[0]===document.activeElement){this.search.blur()}this.clearSearch();this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){J(this.search)},selectHighlighted:function(Q){if(this._touchMoved){this.clearTouchMoved();return}var P=this.highlight(),R=this.results.find(".select2-highlighted"),S=R.closest(".select2-result").data("select2-data");if(S){this.highlight(P);this.onSelect(S,Q)}else{if(Q&&Q.noFocus){this.close()}}},getPlaceholder:function(){var P;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((P=this.getPlaceholderOption())!==m?P.text():m)},getPlaceholderOption:function(){if(this.select){var P=this.select.children("option").first();if(this.opts.placeholderOption!==m){return(this.opts.placeholderOption==="first"&&P)||(typeof this.opts.placeholderOption==="function"&&this.opts.placeholderOption(this.select))}else{if(D.trim(P.text())===""&&P.val()===""){return P}}}},initContainerWidth:function(){function Q(){var V,T,W,U,S,R;if(this.opts.width==="off"){return null}else{if(this.opts.width==="element"){return this.opts.element.outerWidth(false)===0?"auto":this.opts.element.outerWidth(false)+"px"}else{if(this.opts.width==="copy"||this.opts.width==="resolve"){V=this.opts.element.attr("style");if(V!==m){T=V.split(";");for(U=0,S=T.length;U<S;U=U+1){R=T[U].replace(/\s/g,"");W=R.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);if(W!==null&&W.length>=1){return W[1]}}}if(this.opts.width==="resolve"){V=this.opts.element.css("width");if(V.indexOf("%")>0){return V}return(this.opts.element.outerWidth(false)===0?"auto":this.opts.element.outerWidth(false)+"px")}return null}else{if(D.isFunction(this.opts.width)){return this.opts.width()}else{return this.opts.width}}}}}var P=Q.call(this);if(P!==null){this.container.css("width",P)}}});x=M(O,{createContainer:function(){var P=D(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>","   <span class='select2-chosen'>&#160;</span><abbr class='select2-search-choice-close'></abbr>","   <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>","</a>","<label for='' class='select2-offscreen'></label>","<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />","<div class='select2-drop select2-display-none'>","   <div class='select2-search'>","       <label for='' class='select2-offscreen'></label>","       <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'","       aria-autocomplete='list' />","   </div>","   <ul class='select2-results' role='listbox'>","   </ul>","</div>"].join(""));return P},enableInterface:function(){if(this.parent.enableInterface.apply(this,arguments)){this.focusser.prop("disabled",!this.isInterfaceEnabled())}},opening:function(){var R,Q,P;if(this.opts.minimumResultsForSearch>=0){this.showSearch(true)}this.parent.opening.apply(this,arguments);if(this.showSearchInput!==false){this.search.val(this.focusser.val())}if(this.opts.shouldFocusInput(this)){this.search.focus();R=this.search.get(0);if(R.createTextRange){Q=R.createTextRange();Q.collapse(false);Q.select()}else{if(R.setSelectionRange){P=this.search.val().length;R.setSelectionRange(P,P)}}}if(this.search.val()===""){if(this.nextSearchTerm!=m){this.search.val(this.nextSearchTerm);this.search.select()}}this.focusser.prop("disabled",true).val("");this.updateResults(true);this.opts.element.trigger(D.Event("select2-open"))},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments);this.focusser.prop("disabled",false);if(this.opts.shouldFocusInput(this)){this.focusser.focus()}},focus:function(){if(this.opened()){this.close()}else{this.focusser.prop("disabled",false);if(this.opts.shouldFocusInput(this)){this.focusser.focus()}}},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments);this.focusser.prop("disabled",false);if(this.opts.shouldFocusInput(this)){this.focusser.focus()}},destroy:function(){D("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id"));this.parent.destroy.apply(this,arguments);F.call(this,"selection","focusser")},initContainer:function(){var S,P=this.container,U=this.dropdown,T=a(),R;if(this.opts.minimumResultsForSearch<0){this.showSearch(false)}else{this.showSearch(true)}this.selection=S=P.find(".select2-choice");this.focusser=P.find(".select2-focusser");S.find(".select2-chosen").attr("id","select2-chosen-"+T);this.focusser.attr("aria-labelledby","select2-chosen-"+T);this.results.attr("id","select2-results-"+T);this.search.attr("aria-owns","select2-results-"+T);this.focusser.attr("id","s2id_autogen"+T);R=D("label[for='"+this.opts.element.attr("id")+"']");this.opts.element.focus(this.bind(function(){this.focus()}));this.focusser.prev().text(R.text()).attr("for",this.focusser.attr("id"));var Q=this.opts.element.attr("title");this.opts.element.attr("title",(Q||R.text()));this.focusser.attr("tabindex",this.elementTabIndex);this.search.attr("id",this.focusser.attr("id")+"_search");this.search.prev().text(D("label[for='"+this.focusser.attr("id")+"']").text()).attr("for",this.search.attr("id"));this.search.on("keydown",this.bind(function(V){if(!this.isInterfaceEnabled()){return}if(229==V.keyCode){return}if(V.which===L.PAGE_UP||V.which===L.PAGE_DOWN){A(V);return}switch(V.which){case L.UP:case L.DOWN:this.moveHighlight((V.which===L.UP)?-1:1);A(V);return;case L.ENTER:this.selectHighlighted();A(V);return;case L.TAB:this.selectHighlighted({noFocus:true});return;case L.ESC:this.cancel(V);A(V);return}}));this.search.on("blur",this.bind(function(V){if(document.activeElement===this.body.get(0)){window.setTimeout(this.bind(function(){if(this.opened()){this.search.focus()}}),0)}}));this.focusser.on("keydown",this.bind(function(V){if(!this.isInterfaceEnabled()){return}if(V.which===L.TAB||L.isControl(V)||L.isFunctionKey(V)||V.which===L.ESC){return}if(this.opts.openOnEnter===false&&V.which===L.ENTER){A(V);return}if(V.which==L.DOWN||V.which==L.UP||(V.which==L.ENTER&&this.opts.openOnEnter)){if(V.altKey||V.ctrlKey||V.shiftKey||V.metaKey){return}this.open();A(V);return}if(V.which==L.DELETE||V.which==L.BACKSPACE){if(this.opts.allowClear){this.clear()}A(V);return}}));G(this.focusser);this.focusser.on("keyup-change input",this.bind(function(V){if(this.opts.minimumResultsForSearch>=0){V.stopPropagation();if(this.opened()){return}this.open()}}));S.on("mousedown touchstart","abbr",this.bind(function(V){if(!this.isInterfaceEnabled()){return}this.clear();b(V);this.close();if(this.selection){this.selection.focus()}}));S.on("mousedown touchstart",this.bind(function(V){p(S);if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(D.Event("select2-focus"))}if(this.opened()){this.close()}else{if(this.isInterfaceEnabled()){this.open()}}A(V)}));U.on("mousedown touchstart",this.bind(function(){if(this.opts.shouldFocusInput(this)){this.search.focus()}}));S.on("focus",this.bind(function(V){A(V)}));this.focusser.on("focus",this.bind(function(){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(D.Event("select2-focus"))}this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active");this.opts.element.trigger(D.Event("select2-blur"))}}));this.search.on("focus",this.bind(function(){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(D.Event("select2-focus"))}this.container.addClass("select2-container-active")}));this.initContainerWidth();this.opts.element.hide();this.setPlaceholder()},clear:function(R){var S=this.selection.data("select2-data");if(S){var Q=D.Event("select2-clearing");this.opts.element.trigger(Q);if(Q.isDefaultPrevented()){return}var P=this.getPlaceholderOption();this.opts.element.val(P?P.val():"");this.selection.find(".select2-chosen").empty();this.selection.removeData("select2-data");this.setPlaceholder();if(R!==false){this.opts.element.trigger({type:"select2-removed",val:this.id(S),choice:S});this.triggerChange({removed:S})}}},initSelection:function(){var Q;if(this.isPlaceholderOptionSelected()){this.updateSelection(null);this.close();this.setPlaceholder()}else{var P=this;this.opts.initSelection.call(null,this.opts.element,function(R){if(R!==m&&R!==null){P.updateSelection(R);P.close();P.setPlaceholder();P.nextSearchTerm=P.opts.nextSearchTerm(R,P.search.val())}})}},isPlaceholderOptionSelected:function(){var P;if(this.getPlaceholder()===m){return false}return((P=this.getPlaceholderOption())!==m&&P.prop("selected"))||(this.opts.element.val()==="")||(this.opts.element.val()===m)||(this.opts.element.val()===null)},prepareOpts:function(){var Q=this.parent.prepareOpts.apply(this,arguments),P=this;if(Q.element.get(0).tagName.toLowerCase()==="select"){Q.initSelection=function(R,T){var S=R.find("option").filter(function(){return this.selected&&!this.disabled});T(P.optionToData(S))}}else{if("data" in Q){Q.initSelection=Q.initSelection||function(S,U){var T=S.val();var R=null;Q.query({matcher:function(V,Y,W){var X=t(T,Q.id(W));if(X){R=W}return X},callback:!D.isFunction(U)?D.noop:function(){U(R)}})}}}return Q},getPlaceholder:function(){if(this.select){if(this.getPlaceholderOption()===m){return m}}return this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var P=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&P!==m){if(this.select&&this.getPlaceholderOption()===m){return}this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(P));this.selection.addClass("select2-default");this.container.removeClass("select2-allowclear")}},postprocessResults:function(U,Q,T){var S=0,P=this,V=true;this.findHighlightableChoices().each2(function(W,X){if(t(P.id(X.data("select2-data")),P.opts.element.val())){S=W;return false}});if(T!==false){if(Q===true&&S>=0){this.highlight(S)}else{this.highlight(0)}}if(Q===true){var R=this.opts.minimumResultsForSearch;if(R>=0){this.showSearch(s(U.results)>=R)}}},showSearch:function(P){if(this.showSearchInput===P){return}this.showSearchInput=P;this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!P);this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!P);D(this.dropdown,this.container).toggleClass("select2-with-searchbox",P)},onSelect:function(R,Q){if(!this.triggerSelect(R)){return}var P=this.opts.element.val(),S=this.data();this.opts.element.val(this.id(R));this.updateSelection(R);this.opts.element.trigger({type:"select2-selected",val:this.id(R),choice:R});this.nextSearchTerm=this.opts.nextSearchTerm(R,this.search.val());this.close();if((!Q||!Q.noFocus)&&this.opts.shouldFocusInput(this)){this.focusser.focus()}if(!t(P,this.id(R))){this.triggerChange({added:R,removed:S})}},updateSelection:function(S){var Q=this.selection.find(".select2-chosen"),R,P;this.selection.data("select2-data",S);Q.empty();if(S!==null){R=this.opts.formatSelection(S,Q,this.opts.escapeMarkup)}if(R!==m){Q.append(R)}P=this.opts.formatSelectionCssClass(S,Q);if(P!==m){Q.addClass(P)}this.selection.removeClass("select2-default");if(this.opts.allowClear&&this.getPlaceholder()!==m){this.container.addClass("select2-allowclear")}},val:function(){var T,Q=false,R=null,P=this,S=this.data();if(arguments.length===0){return this.opts.element.val()}T=arguments[0];if(arguments.length>1){Q=arguments[1]}if(this.select){this.select.val(T).find("option").filter(function(){return this.selected}).each2(function(U,V){R=P.optionToData(V);return false});this.updateSelection(R);this.setPlaceholder();if(Q){this.triggerChange({added:R,removed:S})}}else{if(!T&&T!==0){this.clear(Q);return}if(this.opts.initSelection===m){throw new Error("cannot call val() if initSelection() is not defined")}this.opts.element.val(T);this.opts.initSelection(this.opts.element,function(U){P.opts.element.val(!U?"":P.id(U));P.updateSelection(U);P.setPlaceholder();if(Q){P.triggerChange({added:U,removed:S})}})}},clearSearch:function(){this.search.val("");this.focusser.val("")},data:function(R){var Q,P=false;if(arguments.length===0){Q=this.selection.data("select2-data");if(Q==m){Q=null}return Q}else{if(arguments.length>1){P=arguments[1]}if(!R){this.clear(P)}else{Q=this.data();this.opts.element.val(!R?"":this.id(R));this.updateSelection(R);if(P){this.triggerChange({added:R,removed:Q})}}}}});c=M(O,{createContainer:function(){var P=D(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>","  <li class='select2-search-field'>","    <label for='' class='select2-offscreen'></label>","    <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>","  </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>","   <ul class='select2-results'>","   </ul>","</div>"].join(""));return P},prepareOpts:function(){var Q=this.parent.prepareOpts.apply(this,arguments),P=this;if(Q.element.get(0).tagName.toLowerCase()==="select"){Q.initSelection=function(R,T){var S=[];R.find("option").filter(function(){return this.selected&&!this.disabled}).each2(function(U,V){S.push(P.optionToData(V))});T(S)}}else{if("data" in Q){Q.initSelection=Q.initSelection||function(R,U){var S=i(R.val(),Q.separator,Q.transformVal);var T=[];Q.query({matcher:function(V,Y,W){var X=D.grep(S,function(Z){return t(Z,Q.id(W))}).length;if(X){T.push(W)}return X},callback:!D.isFunction(U)?D.noop:function(){var V=[];for(var Y=0;Y<S.length;Y++){var Z=S[Y];for(var X=0;X<T.length;X++){var W=T[X];if(t(Z,Q.id(W))){V.push(W);T.splice(X,1);break}}}U(V)}})}}}return Q},selectChoice:function(P){var Q=this.container.find(".select2-search-choice-focus");if(Q.length&&P&&P[0]==Q[0]){}else{if(Q.length){this.opts.element.trigger("choice-deselected",Q)}Q.removeClass("select2-search-choice-focus");if(P&&P.length){this.close();P.addClass("select2-search-choice-focus");this.opts.element.trigger("choice-selected",P)}}},destroy:function(){D("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id"));this.parent.destroy.apply(this,arguments);F.call(this,"searchContainer","selection")},initContainer:function(){var P=".select2-choices",Q;this.searchContainer=this.container.find(".select2-search-field");this.selection=Q=this.container.find(P);var R=this;this.selection.on("click",".select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)",function(S){R.search[0].focus();R.selectChoice(D(this))});this.search.attr("id","s2id_autogen"+a());this.search.prev().text(D("label[for='"+this.opts.element.attr("id")+"']").text()).attr("for",this.search.attr("id"));this.opts.element.focus(this.bind(function(){this.focus()}));this.search.on("input paste",this.bind(function(){if(this.search.attr("placeholder")&&this.search.val().length==0){return}if(!this.isInterfaceEnabled()){return}if(!this.opened()){this.open()}}));this.search.attr("tabindex",this.elementTabIndex);this.keydowns=0;this.search.on("keydown",this.bind(function(W){if(!this.isInterfaceEnabled()){return}++this.keydowns;var U=Q.find(".select2-search-choice-focus");var V=U.prev(".select2-search-choice:not(.select2-locked)");var T=U.next(".select2-search-choice:not(.select2-locked)");var X=f(this.search);if(U.length&&(W.which==L.LEFT||W.which==L.RIGHT||W.which==L.BACKSPACE||W.which==L.DELETE||W.which==L.ENTER)){var S=U;if(W.which==L.LEFT&&V.length){S=V}else{if(W.which==L.RIGHT){S=T.length?T:null}else{if(W.which===L.BACKSPACE){if(this.unselect(U.first())){this.search.width(10);S=V.length?V:T}}else{if(W.which==L.DELETE){if(this.unselect(U.first())){this.search.width(10);S=T.length?T:null}}else{if(W.which==L.ENTER){S=null}}}}}this.selectChoice(S);A(W);if(!S||!S.length){this.open()}return}else{if(((W.which===L.BACKSPACE&&this.keydowns==1)||W.which==L.LEFT)&&(X.offset==0&&!X.length)){this.selectChoice(Q.find(".select2-search-choice:not(.select2-locked)").last());A(W);return}else{this.selectChoice(null)}}if(this.opened()){switch(W.which){case L.UP:case L.DOWN:this.moveHighlight((W.which===L.UP)?-1:1);A(W);return;case L.ENTER:this.selectHighlighted();A(W);return;case L.TAB:this.selectHighlighted({noFocus:true});this.close();return;case L.ESC:this.cancel(W);A(W);return}}if(W.which===L.TAB||L.isControl(W)||L.isFunctionKey(W)||W.which===L.BACKSPACE||W.which===L.ESC){return}if(W.which===L.ENTER){if(this.opts.openOnEnter===false){return}else{if(W.altKey||W.ctrlKey||W.shiftKey||W.metaKey){return}}}this.open();if(W.which===L.PAGE_UP||W.which===L.PAGE_DOWN){A(W)}if(W.which===L.ENTER){A(W)}}));this.search.on("keyup",this.bind(function(S){this.keydowns=0;this.resizeSearch()}));this.search.on("blur",this.bind(function(S){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");this.selectChoice(null);if(!this.opened()){this.clearSearch()}S.stopImmediatePropagation();this.opts.element.trigger(D.Event("select2-blur"))}));this.container.on("click",P,this.bind(function(S){if(!this.isInterfaceEnabled()){return}if(D(S.target).closest(".select2-search-choice").length>0){return}this.selectChoice(null);this.clearPlaceholder();if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(D.Event("select2-focus"))}this.open();this.focusSearch();S.preventDefault()}));this.container.on("focus",P,this.bind(function(){if(!this.isInterfaceEnabled()){return}if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(D.Event("select2-focus"))}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active");this.clearPlaceholder()}));this.initContainerWidth();this.opts.element.hide();this.clearSearch()},enableInterface:function(){if(this.parent.enableInterface.apply(this,arguments)){this.search.prop("disabled",!this.isInterfaceEnabled())}},initSelection:function(){var Q;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.updateSelection([]);this.close();this.clearSearch()}if(this.select||this.opts.element.val()!==""){var P=this;this.opts.initSelection.call(null,this.opts.element,function(R){if(R!==m&&R!==null){P.updateSelection(R);P.close();P.clearSearch()}})}},clearSearch:function(){var Q=this.getPlaceholder(),P=this.getMaxSearchWidth();if(Q!==m&&this.getVal().length===0&&this.search.hasClass("select2-focused")===false){this.search.val(Q).addClass("select2-default");this.search.width(P>0?P:this.container.css("width"))}else{this.search.val("").width(10)}},clearPlaceholder:function(){if(this.search.hasClass("select2-default")){this.search.val("").removeClass("select2-default")}},opening:function(){this.clearPlaceholder();this.resizeSearch();this.parent.opening.apply(this,arguments);this.focusSearch();if(this.search.val()===""){if(this.nextSearchTerm!=m){this.search.val(this.nextSearchTerm);this.search.select()}}this.updateResults(true);if(this.opts.shouldFocusInput(this)){this.search.focus()}this.opts.element.trigger(D.Event("select2-open"))},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments)},focus:function(){this.close();this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(S){var R=[],Q=[],P=this;D(S).each(function(){if(r(P.id(this),R)<0){R.push(P.id(this));Q.push(this)}});S=Q;this.selection.find(".select2-search-choice").remove();D(S).each(function(){P.addSelectedChoice(this)});P.postprocessResults()},tokenize:function(){var P=this.search.val();P=this.opts.tokenizer.call(this,P,this.data(),this.bind(this.onSelect),this.opts);if(P!=null&&P!=m){this.search.val(P);if(P.length>0){this.open()}}},onSelect:function(Q,P){if(!this.triggerSelect(Q)||Q.text===""){return}this.addSelectedChoice(Q);this.opts.element.trigger({type:"selected",val:this.id(Q),choice:Q});this.nextSearchTerm=this.opts.nextSearchTerm(Q,this.search.val());this.clearSearch();this.updateResults();if(this.select||!this.opts.closeOnSelect){this.postprocessResults(Q,false,this.opts.closeOnSelect===true)}if(this.opts.closeOnSelect){this.close();this.search.width(10)}else{if(this.countSelectableResults()>0){this.search.width(10);this.resizeSearch();if(this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()){this.updateResults(true)}else{if(this.nextSearchTerm!=m){this.search.val(this.nextSearchTerm);this.updateResults();this.search.select()}}this.positionDropdown()}else{this.close();this.search.width(10)}}this.triggerChange({added:Q});if(!P||!P.noFocus){this.focusSearch()}},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(T){var V=!T.locked,R=D("<li class='select2-search-choice'>    <div></div>    <a href='#' class='select2-search-choice-close' tabindex='-1'></a></li>"),W=D("<li class='select2-search-choice select2-locked'><div></div></li>");var S=V?R:W,P=this.id(T),Q=this.getVal(),U,X;U=this.opts.formatSelection(T,S.find("div"),this.opts.escapeMarkup);if(U!=m){S.find("div").replaceWith(D("<div></div>").html(U))}X=this.opts.formatSelectionCssClass(T,S.find("div"));if(X!=m){S.addClass(X)}if(V){S.find(".select2-search-choice-close").on("mousedown",A).on("click dblclick",this.bind(function(Y){if(!this.isInterfaceEnabled()){return}this.unselect(D(Y.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");A(Y);this.close();this.focusSearch()})).on("focus",this.bind(function(){if(!this.isInterfaceEnabled()){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active")}))}S.data("select2-data",T);S.insertBefore(this.searchContainer);Q.push(P);this.setVal(Q)},unselect:function(R){var T=this.getVal(),S,Q;R=R.closest(".select2-search-choice");if(R.length===0){throw"Invalid argument: "+R+". Must be .select2-search-choice"}S=R.data("select2-data");if(!S){return}var P=D.Event("select2-removing");P.val=this.id(S);P.choice=S;this.opts.element.trigger(P);if(P.isDefaultPrevented()){return false}while((Q=r(this.id(S),T))>=0){T.splice(Q,1);this.setVal(T);if(this.select){this.postprocessResults()}}R.remove();this.opts.element.trigger({type:"select2-removed",val:this.id(S),choice:S});this.triggerChange({removed:S});return true},postprocessResults:function(T,Q,S){var U=this.getVal(),V=this.results.find(".select2-result"),R=this.results.find(".select2-result-with-children"),P=this;V.each2(function(X,W){var Y=P.id(W.data("select2-data"));if(r(Y,U)>=0){W.addClass("select2-selected");W.find(".select2-result-selectable").addClass("select2-selected")}});R.each2(function(X,W){if(!W.is(".select2-result-selectable")&&W.find(".select2-result-selectable:not(.select2-selected)").length===0){W.addClass("select2-selected")}});if(this.highlight()==-1&&S!==false&&this.opts.closeOnSelect===true){P.highlight(0)}if(!this.opts.createSearchChoice&&!V.filter(".select2-result:not(.select2-selected)").length>0){if(!T||T&&!T.more&&this.results.find(".select2-no-results").length===0){if(y(P.opts.formatNoMatches,"formatNoMatches")){this.results.append("<li class='select2-no-results'>"+C(P.opts.formatNoMatches,P.opts.element,P.search.val())+"</li>")}}}},getMaxSearchWidth:function(){return this.selection.width()-h(this.search)},resizeSearch:function(){var U,S,R,P,Q,T=h(this.search);U=n(this.search)+10;S=this.search.offset().left;R=this.selection.width();P=this.selection.offset().left;Q=R-(S-P)-T;if(Q<U){Q=R-T}if(Q<40){Q=R-T}if(Q<=0){Q=U}this.search.width(Math.floor(Q))},getVal:function(){var P;if(this.select){P=this.select.val();return P===null?[]:P}else{P=this.opts.element.val();return i(P,this.opts.separator,this.opts.transformVal)}},setVal:function(Q){var P;if(this.select){this.select.val(Q)}else{P=[];D(Q).each(function(){if(r(this,P)<0){P.push(this)}});this.opts.element.val(P.length===0?"":P.join(this.opts.separator))}},buildChangeDetails:function(P,S){var S=S.slice(0),P=P.slice(0);for(var R=0;R<S.length;R++){for(var Q=0;Q<P.length;Q++){if(t(this.opts.id(S[R]),this.opts.id(P[Q]))){S.splice(R,1);if(R>0){R--}P.splice(Q,1);Q--}}}return{added:S,removed:P}},val:function(S,Q){var R,P=this;if(arguments.length===0){return this.getVal()}R=this.data();if(!R.length){R=[]}if(!S&&S!==0){this.opts.element.val("");this.updateSelection([]);this.clearSearch();if(Q){this.triggerChange({added:this.data(),removed:R})}return}this.setVal(S);if(this.select){this.opts.initSelection(this.select,this.bind(this.updateSelection));if(Q){this.triggerChange(this.buildChangeDetails(R,this.data()))}}else{if(this.opts.initSelection===m){throw new Error("val() cannot be called if initSelection() is not defined")}this.opts.initSelection(this.opts.element,function(U){var T=D.map(U,P.id);P.setVal(T);P.updateSelection(U);P.clearSearch();if(Q){P.triggerChange(P.buildChangeDetails(R,P.data()))}})}this.clearSearch()},onSortStart:function(){if(this.select){throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.")}this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var Q=[],P=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){Q.push(P.opts.id(D(this).data("select2-data")))});this.setVal(Q);this.triggerChange()},data:function(R,S){var Q=this,T,P;if(arguments.length===0){return this.selection.children(".select2-search-choice").map(function(){return D(this).data("select2-data")}).get()}else{P=this.data();if(!R){R=[]}T=D.map(R,function(U){return Q.opts.id(U)});this.setVal(T);this.updateSelection(R);this.clearSearch();if(S){this.triggerChange(this.buildChangeDetails(P,this.data()))}}}});D.fn.select2=function(){var U=Array.prototype.slice.call(arguments,0),Q,T,P,W,Y,X=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],V=["opened","isFocused","container","dropdown"],R=["val","data"],S={search:"externalSearch"};this.each(function(){if(U.length===0||typeof(U[0])==="object"){Q=U.length===0?{}:D.extend({},U[0]);Q.element=D(this);if(Q.element.get(0).tagName.toLowerCase()==="select"){Y=Q.element.prop("multiple")}else{Y=Q.multiple||false;if("tags" in Q){Q.multiple=Y=true}}T=Y?new window.Select2["class"].multi():new window.Select2["class"].single();T.init(Q)}else{if(typeof(U[0])==="string"){if(r(U[0],X)<0){throw"Unknown method: "+U[0]}W=m;T=D(this).data("select2");if(T===m){return}P=U[0];if(P==="container"){W=T.container}else{if(P==="dropdown"){W=T.dropdown}else{if(S[P]){P=S[P]}W=T[P].apply(T,U.slice(1))}}if(r(U[0],V)>=0||(r(U[0],R)>=0&&U.length==1)){return false}}else{throw"Invalid arguments to select2 plugin: "+U}}});return(W===m)?this:W};D.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:true,openOnEnter:true,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(Q,R,T,P){var S=[];u(this.text(Q),T.term,S,P);return S.join("")},transformVal:function(P){return D.trim(P)},formatSelection:function(R,Q,P){return R?P(this.text(R)):m},sortResults:function(Q,P,R){return Q},formatResultCssClass:function(P){return P.css},formatSelectionCssClass:function(Q,P){return m},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(P){return P==m?null:P.id},text:function(P){if(P&&this.data&&this.data.text){if(D.isFunction(this.data.text)){return this.data.text(P)}else{return P[this.data.text]}}else{return P.text}},matcher:function(P,Q){return e(""+Q).toUpperCase().indexOf(e(""+P).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:g,escapeMarkup:H,blurOnChange:false,selectOnBlur:false,adaptContainerCssClass:function(P){return P},adaptDropdownCssClass:function(P){return null},nextSearchTerm:function(P,Q){return m},searchInputPlaceholder:"",createSearchChoicePosition:"top",shouldFocusInput:function(P){var Q=(("ontouchstart" in window)||(navigator.msMaxTouchPoints>0));if(!Q){return true}if(P.opts.minimumResultsForSearch<0){return false}return true}};D.fn.select2.locales=[];D.fn.select2.locales.en={formatMatches:function(P){if(P===1){return"One result is available, press enter to select it."}return P+" results are available, use up and down arrow keys to navigate."},formatNoMatches:function(){return"No matches found"},formatAjaxError:function(P,R,Q){return"Loading failed"},formatInputTooShort:function(P,Q){var R=Q-P.length;return"Please enter "+R+" or more character"+(R==1?"":"s")},formatInputTooLong:function(Q,P){var R=Q.length-P;return"Please delete "+R+" character"+(R==1?"":"s")},formatSelectionTooBig:function(P){return"You can only select "+P+" item"+(P==1?"":"s")},formatLoadMore:function(P){return"Loading more results…"},formatSearching:function(){return"Searching…"}};D.extend(D.fn.select2.defaults,D.fn.select2.locales.en);D.fn.select2.ajaxDefaults={transport:D.ajax,params:{type:"GET",cache:false,dataType:"json"}};window.Select2={query:{ajax:E,local:I,tags:z},util:{debounce:k,markMatch:u,escapeMarkup:H,stripDiacritics:e},"class":{"abstract":O,single:x,multi:c}}}(jQuery));
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/jquery-select2-3.5.4.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,3729 @@
+/*
+Copyright 2012 Igor Vaynberg
+
+Version: 3.5.4 Timestamp: Sun Aug 30 13:30:32 EDT 2015
+
+This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
+General Public License version 2 (the "GPL License"). You may choose either license to govern your
+use of this software only upon the condition that you accept all of the terms of either the Apache
+License or the GPL License.
+
+You may obtain a copy of the Apache License and the GPL License at:
+
+    http://www.apache.org/licenses/LICENSE-2.0
+    http://www.gnu.org/licenses/gpl-2.0.html
+
+Unless required by applicable law or agreed to in writing, software distributed under the
+Apache License or the GPL License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied. See the Apache License and the GPL License for
+the specific language governing permissions and limitations under the Apache License and the GPL License.
+*/
+(function ($) {
+    if(typeof $.fn.each2 == "undefined") {
+        $.extend($.fn, {
+            /*
+            * 4-10 times faster .each replacement
+            * use it carefully, as it overrides jQuery context of element on each iteration
+            */
+            each2 : function (c) {
+                var j = $([0]), i = -1, l = this.length;
+                while (
+                    ++i < l
+                    && (j.context = j[0] = this[i])
+                    && c.call(j[0], i, j) !== false //"this"=DOM, i=index, j=jQuery object
+                );
+                return this;
+            }
+        });
+    }
+})(jQuery);
+
+(function ($, undefined) {
+    "use strict";
+    /*global document, window, jQuery, console */
+
+    if (window.Select2 !== undefined) {
+        return;
+    }
+
+    var AbstractSelect2, SingleSelect2, MultiSelect2, nextUid, sizer,
+        lastMousePosition={x:0,y:0}, $document, scrollBarDimensions,
+
+    KEY = {
+        TAB: 9,
+        ENTER: 13,
+        ESC: 27,
+        SPACE: 32,
+        LEFT: 37,
+        UP: 38,
+        RIGHT: 39,
+        DOWN: 40,
+        SHIFT: 16,
+        CTRL: 17,
+        ALT: 18,
+        PAGE_UP: 33,
+        PAGE_DOWN: 34,
+        HOME: 36,
+        END: 35,
+        BACKSPACE: 8,
+        DELETE: 46,
+        isArrow: function (k) {
+            k = k.which ? k.which : k;
+            switch (k) {
+            case KEY.LEFT:
+            case KEY.RIGHT:
+            case KEY.UP:
+            case KEY.DOWN:
+                return true;
+            }
+            return false;
+        },
+        isControl: function (e) {
+            var k = e.which;
+            switch (k) {
+            case KEY.SHIFT:
+            case KEY.CTRL:
+            case KEY.ALT:
+                return true;
+            }
+
+            if (e.metaKey) return true;
+
+            return false;
+        },
+        isFunctionKey: function (k) {
+            k = k.which ? k.which : k;
+            return k >= 112 && k <= 123;
+        }
+    },
+    MEASURE_SCROLLBAR_TEMPLATE = "<div class='select2-measure-scrollbar'></div>",
+
+    DIACRITICS = {"\u24B6":"A","\uFF21":"A","\u00C0":"A","\u00C1":"A","\u00C2":"A","\u1EA6":"A","\u1EA4":"A","\u1EAA":"A","\u1EA8":"A","\u00C3":"A","\u0100":"A","\u0102":"A","\u1EB0":"A","\u1EAE":"A","\u1EB4":"A","\u1EB2":"A","\u0226":"A","\u01E0":"A","\u00C4":"A","\u01DE":"A","\u1EA2":"A","\u00C5":"A","\u01FA":"A","\u01CD":"A","\u0200":"A","\u0202":"A","\u1EA0":"A","\u1EAC":"A","\u1EB6":"A","\u1E00":"A","\u0104":"A","\u023A":"A","\u2C6F":"A","\uA732":"AA","\u00C6":"AE","\u01FC":"AE","\u01E2":"AE","\uA734":"AO","\uA736":"AU","\uA738":"AV","\uA73A":"AV","\uA73C":"AY","\u24B7":"B","\uFF22":"B","\u1E02":"B","\u1E04":"B","\u1E06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24B8":"C","\uFF23":"C","\u0106":"C","\u0108":"C","\u010A":"C","\u010C":"C","\u00C7":"C","\u1E08":"C","\u0187":"C","\u023B":"C","\uA73E":"C","\u24B9":"D","\uFF24":"D","\u1E0A":"D","\u010E":"D","\u1E0C":"D","\u1E10":"D","\u1E12":"D","\u1E0E":"D","\u0110":"D","\u018B":"D","\u018A":"D","\u0189":"D","\uA779":"D","\u01F1":"DZ","\u01C4":"DZ","\u01F2":"Dz","\u01C5":"Dz","\u24BA":"E","\uFF25":"E","\u00C8":"E","\u00C9":"E","\u00CA":"E","\u1EC0":"E","\u1EBE":"E","\u1EC4":"E","\u1EC2":"E","\u1EBC":"E","\u0112":"E","\u1E14":"E","\u1E16":"E","\u0114":"E","\u0116":"E","\u00CB":"E","\u1EBA":"E","\u011A":"E","\u0204":"E","\u0206":"E","\u1EB8":"E","\u1EC6":"E","\u0228":"E","\u1E1C":"E","\u0118":"E","\u1E18":"E","\u1E1A":"E","\u0190":"E","\u018E":"E","\u24BB":"F","\uFF26":"F","\u1E1E":"F","\u0191":"F","\uA77B":"F","\u24BC":"G","\uFF27":"G","\u01F4":"G","\u011C":"G","\u1E20":"G","\u011E":"G","\u0120":"G","\u01E6":"G","\u0122":"G","\u01E4":"G","\u0193":"G","\uA7A0":"G","\uA77D":"G","\uA77E":"G","\u24BD":"H","\uFF28":"H","\u0124":"H","\u1E22":"H","\u1E26":"H","\u021E":"H","\u1E24":"H","\u1E28":"H","\u1E2A":"H","\u0126":"H","\u2C67":"H","\u2C75":"H","\uA78D":"H","\u24BE":"I","\uFF29":"I","\u00CC":"I","\u00CD":"I","\u00CE":"I","\u0128":"I","\u012A":"I","\u012C":"I","\u0130":"I","\u00CF":"I","\u1E2E":"I","\u1EC8":"I","\u01CF":"I","\u0208":"I","\u020A":"I","\u1ECA":"I","\u012E":"I","\u1E2C":"I","\u0197":"I","\u24BF":"J","\uFF2A":"J","\u0134":"J","\u0248":"J","\u24C0":"K","\uFF2B":"K","\u1E30":"K","\u01E8":"K","\u1E32":"K","\u0136":"K","\u1E34":"K","\u0198":"K","\u2C69":"K","\uA740":"K","\uA742":"K","\uA744":"K","\uA7A2":"K","\u24C1":"L","\uFF2C":"L","\u013F":"L","\u0139":"L","\u013D":"L","\u1E36":"L","\u1E38":"L","\u013B":"L","\u1E3C":"L","\u1E3A":"L","\u0141":"L","\u023D":"L","\u2C62":"L","\u2C60":"L","\uA748":"L","\uA746":"L","\uA780":"L","\u01C7":"LJ","\u01C8":"Lj","\u24C2":"M","\uFF2D":"M","\u1E3E":"M","\u1E40":"M","\u1E42":"M","\u2C6E":"M","\u019C":"M","\u24C3":"N","\uFF2E":"N","\u01F8":"N","\u0143":"N","\u00D1":"N","\u1E44":"N","\u0147":"N","\u1E46":"N","\u0145":"N","\u1E4A":"N","\u1E48":"N","\u0220":"N","\u019D":"N","\uA790":"N","\uA7A4":"N","\u01CA":"NJ","\u01CB":"Nj","\u24C4":"O","\uFF2F":"O","\u00D2":"O","\u00D3":"O","\u00D4":"O","\u1ED2":"O","\u1ED0":"O","\u1ED6":"O","\u1ED4":"O","\u00D5":"O","\u1E4C":"O","\u022C":"O","\u1E4E":"O","\u014C":"O","\u1E50":"O","\u1E52":"O","\u014E":"O","\u022E":"O","\u0230":"O","\u00D6":"O","\u022A":"O","\u1ECE":"O","\u0150":"O","\u01D1":"O","\u020C":"O","\u020E":"O","\u01A0":"O","\u1EDC":"O","\u1EDA":"O","\u1EE0":"O","\u1EDE":"O","\u1EE2":"O","\u1ECC":"O","\u1ED8":"O","\u01EA":"O","\u01EC":"O","\u00D8":"O","\u01FE":"O","\u0186":"O","\u019F":"O","\uA74A":"O","\uA74C":"O","\u01A2":"OI","\uA74E":"OO","\u0222":"OU","\u24C5":"P","\uFF30":"P","\u1E54":"P","\u1E56":"P","\u01A4":"P","\u2C63":"P","\uA750":"P","\uA752":"P","\uA754":"P","\u24C6":"Q","\uFF31":"Q","\uA756":"Q","\uA758":"Q","\u024A":"Q","\u24C7":"R","\uFF32":"R","\u0154":"R","\u1E58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1E5A":"R","\u1E5C":"R","\u0156":"R","\u1E5E":"R","\u024C":"R","\u2C64":"R","\uA75A":"R","\uA7A6":"R","\uA782":"R","\u24C8":"S","\uFF33":"S","\u1E9E":"S","\u015A":"S","\u1E64":"S","\u015C":"S","\u1E60":"S","\u0160":"S","\u1E66":"S","\u1E62":"S","\u1E68":"S","\u0218":"S","\u015E":"S","\u2C7E":"S","\uA7A8":"S","\uA784":"S","\u24C9":"T","\uFF34":"T","\u1E6A":"T","\u0164":"T","\u1E6C":"T","\u021A":"T","\u0162":"T","\u1E70":"T","\u1E6E":"T","\u0166":"T","\u01AC":"T","\u01AE":"T","\u023E":"T","\uA786":"T","\uA728":"TZ","\u24CA":"U","\uFF35":"U","\u00D9":"U","\u00DA":"U","\u00DB":"U","\u0168":"U","\u1E78":"U","\u016A":"U","\u1E7A":"U","\u016C":"U","\u00DC":"U","\u01DB":"U","\u01D7":"U","\u01D5":"U","\u01D9":"U","\u1EE6":"U","\u016E":"U","\u0170":"U","\u01D3":"U","\u0214":"U","\u0216":"U","\u01AF":"U","\u1EEA":"U","\u1EE8":"U","\u1EEE":"U","\u1EEC":"U","\u1EF0":"U","\u1EE4":"U","\u1E72":"U","\u0172":"U","\u1E76":"U","\u1E74":"U","\u0244":"U","\u24CB":"V","\uFF36":"V","\u1E7C":"V","\u1E7E":"V","\u01B2":"V","\uA75E":"V","\u0245":"V","\uA760":"VY","\u24CC":"W","\uFF37":"W","\u1E80":"W","\u1E82":"W","\u0174":"W","\u1E86":"W","\u1E84":"W","\u1E88":"W","\u2C72":"W","\u24CD":"X","\uFF38":"X","\u1E8A":"X","\u1E8C":"X","\u24CE":"Y","\uFF39":"Y","\u1EF2":"Y","\u00DD":"Y","\u0176":"Y","\u1EF8":"Y","\u0232":"Y","\u1E8E":"Y","\u0178":"Y","\u1EF6":"Y","\u1EF4":"Y","\u01B3":"Y","\u024E":"Y","\u1EFE":"Y","\u24CF":"Z","\uFF3A":"Z","\u0179":"Z","\u1E90":"Z","\u017B":"Z","\u017D":"Z","\u1E92":"Z","\u1E94":"Z","\u01B5":"Z","\u0224":"Z","\u2C7F":"Z","\u2C6B":"Z","\uA762":"Z","\u24D0":"a","\uFF41":"a","\u1E9A":"a","\u00E0":"a","\u00E1":"a","\u00E2":"a","\u1EA7":"a","\u1EA5":"a","\u1EAB":"a","\u1EA9":"a","\u00E3":"a","\u0101":"a","\u0103":"a","\u1EB1":"a","\u1EAF":"a","\u1EB5":"a","\u1EB3":"a","\u0227":"a","\u01E1":"a","\u00E4":"a","\u01DF":"a","\u1EA3":"a","\u00E5":"a","\u01FB":"a","\u01CE":"a","\u0201":"a","\u0203":"a","\u1EA1":"a","\u1EAD":"a","\u1EB7":"a","\u1E01":"a","\u0105":"a","\u2C65":"a","\u0250":"a","\uA733":"aa","\u00E6":"ae","\u01FD":"ae","\u01E3":"ae","\uA735":"ao","\uA737":"au","\uA739":"av","\uA73B":"av","\uA73D":"ay","\u24D1":"b","\uFF42":"b","\u1E03":"b","\u1E05":"b","\u1E07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24D2":"c","\uFF43":"c","\u0107":"c","\u0109":"c","\u010B":"c","\u010D":"c","\u00E7":"c","\u1E09":"c","\u0188":"c","\u023C":"c","\uA73F":"c","\u2184":"c","\u24D3":"d","\uFF44":"d","\u1E0B":"d","\u010F":"d","\u1E0D":"d","\u1E11":"d","\u1E13":"d","\u1E0F":"d","\u0111":"d","\u018C":"d","\u0256":"d","\u0257":"d","\uA77A":"d","\u01F3":"dz","\u01C6":"dz","\u24D4":"e","\uFF45":"e","\u00E8":"e","\u00E9":"e","\u00EA":"e","\u1EC1":"e","\u1EBF":"e","\u1EC5":"e","\u1EC3":"e","\u1EBD":"e","\u0113":"e","\u1E15":"e","\u1E17":"e","\u0115":"e","\u0117":"e","\u00EB":"e","\u1EBB":"e","\u011B":"e","\u0205":"e","\u0207":"e","\u1EB9":"e","\u1EC7":"e","\u0229":"e","\u1E1D":"e","\u0119":"e","\u1E19":"e","\u1E1B":"e","\u0247":"e","\u025B":"e","\u01DD":"e","\u24D5":"f","\uFF46":"f","\u1E1F":"f","\u0192":"f","\uA77C":"f","\u24D6":"g","\uFF47":"g","\u01F5":"g","\u011D":"g","\u1E21":"g","\u011F":"g","\u0121":"g","\u01E7":"g","\u0123":"g","\u01E5":"g","\u0260":"g","\uA7A1":"g","\u1D79":"g","\uA77F":"g","\u24D7":"h","\uFF48":"h","\u0125":"h","\u1E23":"h","\u1E27":"h","\u021F":"h","\u1E25":"h","\u1E29":"h","\u1E2B":"h","\u1E96":"h","\u0127":"h","\u2C68":"h","\u2C76":"h","\u0265":"h","\u0195":"hv","\u24D8":"i","\uFF49":"i","\u00EC":"i","\u00ED":"i","\u00EE":"i","\u0129":"i","\u012B":"i","\u012D":"i","\u00EF":"i","\u1E2F":"i","\u1EC9":"i","\u01D0":"i","\u0209":"i","\u020B":"i","\u1ECB":"i","\u012F":"i","\u1E2D":"i","\u0268":"i","\u0131":"i","\u24D9":"j","\uFF4A":"j","\u0135":"j","\u01F0":"j","\u0249":"j","\u24DA":"k","\uFF4B":"k","\u1E31":"k","\u01E9":"k","\u1E33":"k","\u0137":"k","\u1E35":"k","\u0199":"k","\u2C6A":"k","\uA741":"k","\uA743":"k","\uA745":"k","\uA7A3":"k","\u24DB":"l","\uFF4C":"l","\u0140":"l","\u013A":"l","\u013E":"l","\u1E37":"l","\u1E39":"l","\u013C":"l","\u1E3D":"l","\u1E3B":"l","\u017F":"l","\u0142":"l","\u019A":"l","\u026B":"l","\u2C61":"l","\uA749":"l","\uA781":"l","\uA747":"l","\u01C9":"lj","\u24DC":"m","\uFF4D":"m","\u1E3F":"m","\u1E41":"m","\u1E43":"m","\u0271":"m","\u026F":"m","\u24DD":"n","\uFF4E":"n","\u01F9":"n","\u0144":"n","\u00F1":"n","\u1E45":"n","\u0148":"n","\u1E47":"n","\u0146":"n","\u1E4B":"n","\u1E49":"n","\u019E":"n","\u0272":"n","\u0149":"n","\uA791":"n","\uA7A5":"n","\u01CC":"nj","\u24DE":"o","\uFF4F":"o","\u00F2":"o","\u00F3":"o","\u00F4":"o","\u1ED3":"o","\u1ED1":"o","\u1ED7":"o","\u1ED5":"o","\u00F5":"o","\u1E4D":"o","\u022D":"o","\u1E4F":"o","\u014D":"o","\u1E51":"o","\u1E53":"o","\u014F":"o","\u022F":"o","\u0231":"o","\u00F6":"o","\u022B":"o","\u1ECF":"o","\u0151":"o","\u01D2":"o","\u020D":"o","\u020F":"o","\u01A1":"o","\u1EDD":"o","\u1EDB":"o","\u1EE1":"o","\u1EDF":"o","\u1EE3":"o","\u1ECD":"o","\u1ED9":"o","\u01EB":"o","\u01ED":"o","\u00F8":"o","\u01FF":"o","\u0254":"o","\uA74B":"o","\uA74D":"o","\u0275":"o","\u01A3":"oi","\u0223":"ou","\uA74F":"oo","\u24DF":"p","\uFF50":"p","\u1E55":"p","\u1E57":"p","\u01A5":"p","\u1D7D":"p","\uA751":"p","\uA753":"p","\uA755":"p","\u24E0":"q","\uFF51":"q","\u024B":"q","\uA757":"q","\uA759":"q","\u24E1":"r","\uFF52":"r","\u0155":"r","\u1E59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1E5B":"r","\u1E5D":"r","\u0157":"r","\u1E5F":"r","\u024D":"r","\u027D":"r","\uA75B":"r","\uA7A7":"r","\uA783":"r","\u24E2":"s","\uFF53":"s","\u00DF":"s","\u015B":"s","\u1E65":"s","\u015D":"s","\u1E61":"s","\u0161":"s","\u1E67":"s","\u1E63":"s","\u1E69":"s","\u0219":"s","\u015F":"s","\u023F":"s","\uA7A9":"s","\uA785":"s","\u1E9B":"s","\u24E3":"t","\uFF54":"t","\u1E6B":"t","\u1E97":"t","\u0165":"t","\u1E6D":"t","\u021B":"t","\u0163":"t","\u1E71":"t","\u1E6F":"t","\u0167":"t","\u01AD":"t","\u0288":"t","\u2C66":"t","\uA787":"t","\uA729":"tz","\u24E4":"u","\uFF55":"u","\u00F9":"u","\u00FA":"u","\u00FB":"u","\u0169":"u","\u1E79":"u","\u016B":"u","\u1E7B":"u","\u016D":"u","\u00FC":"u","\u01DC":"u","\u01D8":"u","\u01D6":"u","\u01DA":"u","\u1EE7":"u","\u016F":"u","\u0171":"u","\u01D4":"u","\u0215":"u","\u0217":"u","\u01B0":"u","\u1EEB":"u","\u1EE9":"u","\u1EEF":"u","\u1EED":"u","\u1EF1":"u","\u1EE5":"u","\u1E73":"u","\u0173":"u","\u1E77":"u","\u1E75":"u","\u0289":"u","\u24E5":"v","\uFF56":"v","\u1E7D":"v","\u1E7F":"v","\u028B":"v","\uA75F":"v","\u028C":"v","\uA761":"vy","\u24E6":"w","\uFF57":"w","\u1E81":"w","\u1E83":"w","\u0175":"w","\u1E87":"w","\u1E85":"w","\u1E98":"w","\u1E89":"w","\u2C73":"w","\u24E7":"x","\uFF58":"x","\u1E8B":"x","\u1E8D":"x","\u24E8":"y","\uFF59":"y","\u1EF3":"y","\u00FD":"y","\u0177":"y","\u1EF9":"y","\u0233":"y","\u1E8F":"y","\u00FF":"y","\u1EF7":"y","\u1E99":"y","\u1EF5":"y","\u01B4":"y","\u024F":"y","\u1EFF":"y","\u24E9":"z","\uFF5A":"z","\u017A":"z","\u1E91":"z","\u017C":"z","\u017E":"z","\u1E93":"z","\u1E95":"z","\u01B6":"z","\u0225":"z","\u0240":"z","\u2C6C":"z","\uA763":"z","\u0386":"\u0391","\u0388":"\u0395","\u0389":"\u0397","\u038A":"\u0399","\u03AA":"\u0399","\u038C":"\u039F","\u038E":"\u03A5","\u03AB":"\u03A5","\u038F":"\u03A9","\u03AC":"\u03B1","\u03AD":"\u03B5","\u03AE":"\u03B7","\u03AF":"\u03B9","\u03CA":"\u03B9","\u0390":"\u03B9","\u03CC":"\u03BF","\u03CD":"\u03C5","\u03CB":"\u03C5","\u03B0":"\u03C5","\u03C9":"\u03C9","\u03C2":"\u03C3"};
+
+    $document = $(document);
+
+    nextUid=(function() { var counter=1; return function() { return counter++; }; }());
+
+
+    function reinsertElement(element) {
+        var placeholder = $(document.createTextNode(''));
+
+        element.before(placeholder);
+        placeholder.before(element);
+        placeholder.remove();
+    }
+
+    function stripDiacritics(str) {
+        // Used 'uni range + named function' from http://jsperf.com/diacritics/18
+        function match(a) {
+            return DIACRITICS[a] || a;
+        }
+
+        return str.replace(/[^\u0000-\u007E]/g, match);
+    }
+
+    function indexOf(value, array) {
+        var i = 0, l = array.length;
+        for (; i < l; i = i + 1) {
+            if (equal(value, array[i])) return i;
+        }
+        return -1;
+    }
+
+    function measureScrollbar () {
+        var $template = $( MEASURE_SCROLLBAR_TEMPLATE );
+        $template.appendTo(document.body);
+
+        var dim = {
+            width: $template.width() - $template[0].clientWidth,
+            height: $template.height() - $template[0].clientHeight
+        };
+        $template.remove();
+
+        return dim;
+    }
+
+    /**
+     * Compares equality of a and b
+     * @param a
+     * @param b
+     */
+    function equal(a, b) {
+        if (a === b) return true;
+        if (a === undefined || b === undefined) return false;
+        if (a === null || b === null) return false;
+        // Check whether 'a' or 'b' is a string (primitive or object).
+        // The concatenation of an empty string (+'') converts its argument to a string's primitive.
+        if (a.constructor === String) return a+'' === b+''; // a+'' - in case 'a' is a String object
+        if (b.constructor === String) return b+'' === a+''; // b+'' - in case 'b' is a String object
+        return false;
+    }
+
+    /**
+     * Splits the string into an array of values, transforming each value. An empty array is returned for nulls or empty
+     * strings
+     * @param string
+     * @param separator
+     */
+    function splitVal(string, separator, transform) {
+        var val, i, l;
+        if (string === null || string.length < 1) return [];
+        val = string.split(separator);
+        for (i = 0, l = val.length; i < l; i = i + 1) val[i] = transform(val[i]);
+        return val;
+    }
+
+    function getSideBorderPadding(element) {
+        return element.outerWidth(false) - element.width();
+    }
+
+    function installKeyUpChangeEvent(element) {
+        var key="keyup-change-value";
+        element.on("keydown", function () {
+            if ($.data(element, key) === undefined) {
+                $.data(element, key, element.val());
+            }
+        });
+        element.on("keyup", function () {
+            var val= $.data(element, key);
+            if (val !== undefined && element.val() !== val) {
+                $.removeData(element, key);
+                element.trigger("keyup-change");
+            }
+        });
+    }
+
+
+    /**
+     * filters mouse events so an event is fired only if the mouse moved.
+     *
+     * filters out mouse events that occur when mouse is stationary but
+     * the elements under the pointer are scrolled.
+     */
+    function installFilteredMouseMove(element) {
+        element.on("mousemove", function (e) {
+            var lastpos = lastMousePosition;
+            if (lastpos === undefined || lastpos.x !== e.pageX || lastpos.y !== e.pageY) {
+                $(e.target).trigger("mousemove-filtered", e);
+            }
+        });
+    }
+
+    /**
+     * Debounces a function. Returns a function that calls the original fn function only if no invocations have been made
+     * within the last quietMillis milliseconds.
+     *
+     * @param quietMillis number of milliseconds to wait before invoking fn
+     * @param fn function to be debounced
+     * @param ctx object to be used as this reference within fn
+     * @return debounced version of fn
+     */
+    function debounce(quietMillis, fn, ctx) {
+        ctx = ctx || undefined;
+        var timeout;
+        return function () {
+            var args = arguments;
+            window.clearTimeout(timeout);
+            timeout = window.setTimeout(function() {
+                fn.apply(ctx, args);
+            }, quietMillis);
+        };
+    }
+
+    function installDebouncedScroll(threshold, element) {
+        var notify = debounce(threshold, function (e) { element.trigger("scroll-debounced", e);});
+        element.on("scroll", function (e) {
+            if (indexOf(e.target, element.get()) >= 0) notify(e);
+        });
+    }
+
+    function focus($el) {
+        if ($el[0] === document.activeElement) return;
+
+        /* set the focus in a 0 timeout - that way the focus is set after the processing
+            of the current event has finished - which seems like the only reliable way
+            to set focus */
+        window.setTimeout(function() {
+            var el=$el[0], pos=$el.val().length, range;
+
+            $el.focus();
+
+            /* make sure el received focus so we do not error out when trying to manipulate the caret.
+                sometimes modals or others listeners may steal it after its set */
+            var isVisible = (el.offsetWidth > 0 || el.offsetHeight > 0);
+            if (isVisible && el === document.activeElement) {
+
+                /* after the focus is set move the caret to the end, necessary when we val()
+                    just before setting focus */
+                if(el.setSelectionRange)
+                {
+                    el.setSelectionRange(pos, pos);
+                }
+                else if (el.createTextRange) {
+                    range = el.createTextRange();
+                    range.collapse(false);
+                    range.select();
+                }
+            }
+        }, 0);
+    }
+
+    function getCursorInfo(el) {
+        el = $(el)[0];
+        var offset = 0;
+        var length = 0;
+        if ('selectionStart' in el) {
+            offset = el.selectionStart;
+            length = el.selectionEnd - offset;
+        } else if ('selection' in document) {
+            el.focus();
+            var sel = document.selection.createRange();
+            length = document.selection.createRange().text.length;
+            sel.moveStart('character', -el.value.length);
+            offset = sel.text.length - length;
+        }
+        return { offset: offset, length: length };
+    }
+
+    function killEvent(event) {
+        event.preventDefault();
+        event.stopPropagation();
+    }
+    function killEventImmediately(event) {
+        event.preventDefault();
+        event.stopImmediatePropagation();
+    }
+
+    function measureTextWidth(e) {
+        if (!sizer){
+            var style = e[0].currentStyle || window.getComputedStyle(e[0], null);
+            sizer = $(document.createElement("div")).css({
+                position: "absolute",
+                left: "-10000px",
+                top: "-10000px",
+                display: "none",
+                fontSize: style.fontSize,
+                fontFamily: style.fontFamily,
+                fontStyle: style.fontStyle,
+                fontWeight: style.fontWeight,
+                letterSpacing: style.letterSpacing,
+                textTransform: style.textTransform,
+                whiteSpace: "nowrap"
+            });
+            sizer.attr("class","select2-sizer");
+            $(document.body).append(sizer);
+        }
+        sizer.text(e.val());
+        return sizer.width();
+    }
+
+    function syncCssClasses(dest, src, adapter) {
+        var classes, replacements = [], adapted;
+
+        classes = $.trim(dest.attr("class"));
+
+        if (classes) {
+            classes = '' + classes; // for IE which returns object
+
+            $(classes.split(/\s+/)).each2(function() {
+                if (this.indexOf("select2-") === 0) {
+                    replacements.push(this);
+                }
+            });
+        }
+
+        classes = $.trim(src.attr("class"));
+
+        if (classes) {
+            classes = '' + classes; // for IE which returns object
+
+            $(classes.split(/\s+/)).each2(function() {
+                if (this.indexOf("select2-") !== 0) {
+                    adapted = adapter(this);
+
+                    if (adapted) {
+                        replacements.push(adapted);
+                    }
+                }
+            });
+        }
+
+        dest.attr("class", replacements.join(" "));
+    }
+
+
+    function markMatch(text, term, markup, escapeMarkup) {
+        var match=stripDiacritics(text.toUpperCase()).indexOf(stripDiacritics(term.toUpperCase())),
+            tl=term.length;
+
+        if (match<0) {
+            markup.push(escapeMarkup(text));
+            return;
+        }
+
+        markup.push(escapeMarkup(text.substring(0, match)));
+        markup.push("<span class='select2-match'>");
+        markup.push(escapeMarkup(text.substring(match, match + tl)));
+        markup.push("</span>");
+        markup.push(escapeMarkup(text.substring(match + tl, text.length)));
+    }
+
+    function defaultEscapeMarkup(markup) {
+        var replace_map = {
+            '\\': '&#92;',
+            '&': '&amp;',
+            '<': '&lt;',
+            '>': '&gt;',
+            '"': '&quot;',
+            "'": '&#39;',
+            "/": '&#47;'
+        };
+
+        return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
+            return replace_map[match];
+        });
+    }
+
+    /**
+     * Produces an ajax-based query function
+     *
+     * @param options object containing configuration parameters
+     * @param options.params parameter map for the transport ajax call, can contain such options as cache, jsonpCallback, etc. see $.ajax
+     * @param options.transport function that will be used to execute the ajax request. must be compatible with parameters supported by $.ajax
+     * @param options.url url for the data
+     * @param options.data a function(searchTerm, pageNumber, context) that should return an object containing query string parameters for the above url.
+     * @param options.dataType request data type: ajax, jsonp, other datatypes supported by jQuery's $.ajax function or the transport function if specified
+     * @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often
+     * @param options.results a function(remoteData, pageNumber, query) that converts data returned form the remote request to the format expected by Select2.
+     *      The expected format is an object containing the following keys:
+     *      results array of objects that will be used as choices
+     *      more (optional) boolean indicating whether there are more results available
+     *      Example: {results:[{id:1, text:'Red'},{id:2, text:'Blue'}], more:true}
+     */
+    function ajax(options) {
+        var timeout, // current scheduled but not yet executed request
+            handler = null,
+            quietMillis = options.quietMillis || 100,
+            ajaxUrl = options.url,
+            self = this;
+
+        return function (query) {
+            window.clearTimeout(timeout);
+            timeout = window.setTimeout(function () {
+                var data = options.data, // ajax data function
+                    url = ajaxUrl, // ajax url string or function
+                    transport = options.transport || $.fn.select2.ajaxDefaults.transport,
+                    // deprecated - to be removed in 4.0  - use params instead
+                    deprecated = {
+                        type: options.type || 'GET', // set type of request (GET or POST)
+                        cache: options.cache || false,
+                        jsonpCallback: options.jsonpCallback||undefined,
+                        dataType: options.dataType||"json"
+                    },
+                    params = $.extend({}, $.fn.select2.ajaxDefaults.params, deprecated);
+
+                data = data ? data.call(self, query.term, query.page, query.context) : null;
+                url = (typeof url === 'function') ? url.call(self, query.term, query.page, query.context) : url;
+
+                if (handler && typeof handler.abort === "function") { handler.abort(); }
+
+                if (options.params) {
+                    if ($.isFunction(options.params)) {
+                        $.extend(params, options.params.call(self));
+                    } else {
+                        $.extend(params, options.params);
+                    }
+                }
+
+                $.extend(params, {
+                    url: url,
+                    dataType: options.dataType,
+                    data: data,
+                    success: function (data) {
+                        // TODO - replace query.page with query so users have access to term, page, etc.
+                        // added query as third paramter to keep backwards compatibility
+                        var results = options.results(data, query.page, query);
+                        query.callback(results);
+                    },
+                    error: function(jqXHR, textStatus, errorThrown){
+                        var results = {
+                            hasError: true,
+                            jqXHR: jqXHR,
+                            textStatus: textStatus,
+                            errorThrown: errorThrown
+                        };
+
+                        query.callback(results);
+                    }
+                });
+                handler = transport.call(self, params);
+            }, quietMillis);
+        };
+    }
+
+    /**
+     * Produces a query function that works with a local array
+     *
+     * @param options object containing configuration parameters. The options parameter can either be an array or an
+     * object.
+     *
+     * If the array form is used it is assumed that it contains objects with 'id' and 'text' keys.
+     *
+     * If the object form is used it is assumed that it contains 'data' and 'text' keys. The 'data' key should contain
+     * an array of objects that will be used as choices. These objects must contain at least an 'id' key. The 'text'
+     * key can either be a String in which case it is expected that each element in the 'data' array has a key with the
+     * value of 'text' which will be used to match choices. Alternatively, text can be a function(item) that can extract
+     * the text.
+     */
+    function local(options) {
+        var data = options, // data elements
+            dataText,
+            tmp,
+            text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
+
+         if ($.isArray(data)) {
+            tmp = data;
+            data = { results: tmp };
+        }
+
+         if ($.isFunction(data) === false) {
+            tmp = data;
+            data = function() { return tmp; };
+        }
+
+        var dataItem = data();
+        if (dataItem.text) {
+            text = dataItem.text;
+            // if text is not a function we assume it to be a key name
+            if (!$.isFunction(text)) {
+                dataText = dataItem.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available
+                text = function (item) { return item[dataText]; };
+            }
+        }
+
+        return function (query) {
+            var t = query.term, filtered = { results: [] }, process;
+            if (t === "") {
+                query.callback(data());
+                return;
+            }
+
+            process = function(datum, collection) {
+                var group, attr;
+                datum = datum[0];
+                if (datum.children) {
+                    group = {};
+                    for (attr in datum) {
+                        if (datum.hasOwnProperty(attr)) group[attr]=datum[attr];
+                    }
+                    group.children=[];
+                    $(datum.children).each2(function(i, childDatum) { process(childDatum, group.children); });
+                    if (group.children.length || query.matcher(t, text(group), datum)) {
+                        collection.push(group);
+                    }
+                } else {
+                    if (query.matcher(t, text(datum), datum)) {
+                        collection.push(datum);
+                    }
+                }
+            };
+
+            $(data().results).each2(function(i, datum) { process(datum, filtered.results); });
+            query.callback(filtered);
+        };
+    }
+
+    // TODO javadoc
+    function tags(data) {
+        var isFunc = $.isFunction(data);
+        return function (query) {
+            var t = query.term, filtered = {results: []};
+            var result = isFunc ? data(query) : data;
+            if ($.isArray(result)) {
+                $(result).each(function () {
+                    var isObject = this.text !== undefined,
+                        text = isObject ? this.text : this;
+                    if (t === "" || query.matcher(t, text)) {
+                        filtered.results.push(isObject ? this : {id: this, text: this});
+                    }
+                });
+                query.callback(filtered);
+            }
+        };
+    }
+
+    /**
+     * Checks if the formatter function should be used.
+     *
+     * Throws an error if it is not a function. Returns true if it should be used,
+     * false if no formatting should be performed.
+     *
+     * @param formatter
+     */
+    function checkFormatter(formatter, formatterName) {
+        if ($.isFunction(formatter)) return true;
+        if (!formatter) return false;
+        if (typeof(formatter) === 'string') return true;
+        throw new Error(formatterName +" must be a string, function, or falsy value");
+    }
+
+  /**
+   * Returns a given value
+   * If given a function, returns its output
+   *
+   * @param val string|function
+   * @param context value of "this" to be passed to function
+   * @returns {*}
+   */
+    function evaluate(val, context) {
+        if ($.isFunction(val)) {
+            var args = Array.prototype.slice.call(arguments, 2);
+            return val.apply(context, args);
+        }
+        return val;
+    }
+
+    function countResults(results) {
+        var count = 0;
+        $.each(results, function(i, item) {
+            if (item.children) {
+                count += countResults(item.children);
+            } else {
+                count++;
+            }
+        });
+        return count;
+    }
+
+    /**
+     * Default tokenizer. This function uses breaks the input on substring match of any string from the
+     * opts.tokenSeparators array and uses opts.createSearchChoice to create the choice object. Both of those
+     * two options have to be defined in order for the tokenizer to work.
+     *
+     * @param input text user has typed so far or pasted into the search field
+     * @param selection currently selected choices
+     * @param selectCallback function(choice) callback tho add the choice to selection
+     * @param opts select2's opts
+     * @return undefined/null to leave the current input unchanged, or a string to change the input to the returned value
+     */
+    function defaultTokenizer(input, selection, selectCallback, opts) {
+        var original = input, // store the original so we can compare and know if we need to tell the search to update its text
+            dupe = false, // check for whether a token we extracted represents a duplicate selected choice
+            token, // token
+            index, // position at which the separator was found
+            i, l, // looping variables
+            separator; // the matched separator
+
+        if (!opts.createSearchChoice || !opts.tokenSeparators || opts.tokenSeparators.length < 1) return undefined;
+
+        while (true) {
+            index = -1;
+
+            for (i = 0, l = opts.tokenSeparators.length; i < l; i++) {
+                separator = opts.tokenSeparators[i];
+                index = input.indexOf(separator);
+                if (index >= 0) break;
+            }
+
+            if (index < 0) break; // did not find any token separator in the input string, bail
+
+            token = input.substring(0, index);
+            input = input.substring(index + separator.length);
+
+            if (token.length > 0) {
+                token = opts.createSearchChoice.call(this, token, selection);
+                if (token !== undefined && token !== null && opts.id(token) !== undefined && opts.id(token) !== null) {
+                    dupe = false;
+                    for (i = 0, l = selection.length; i < l; i++) {
+                        if (equal(opts.id(token), opts.id(selection[i]))) {
+                            dupe = true; break;
+                        }
+                    }
+
+                    if (!dupe) selectCallback(token);
+                }
+            }
+        }
+
+        if (original!==input) return input;
+    }
+
+    function cleanupJQueryElements() {
+        var self = this;
+
+        $.each(arguments, function (i, element) {
+            self[element].remove();
+            self[element] = null;
+        });
+    }
+
+    /**
+     * Creates a new class
+     *
+     * @param superClass
+     * @param methods
+     */
+    function clazz(SuperClass, methods) {
+        var constructor = function () {};
+        constructor.prototype = new SuperClass;
+        constructor.prototype.constructor = constructor;
+        constructor.prototype.parent = SuperClass.prototype;
+        constructor.prototype = $.extend(constructor.prototype, methods);
+        return constructor;
+    }
+
+    AbstractSelect2 = clazz(Object, {
+
+        // abstract
+        bind: function (func) {
+            var self = this;
+            return function () {
+                func.apply(self, arguments);
+            };
+        },
+
+        // abstract
+        init: function (opts) {
+            var results, search, resultsSelector = ".select2-results";
+
+            // prepare options
+            this.opts = opts = this.prepareOpts(opts);
+
+            this.id=opts.id;
+
+            // destroy if called on an existing component
+            if (opts.element.data("select2") !== undefined &&
+                opts.element.data("select2") !== null) {
+                opts.element.data("select2").destroy();
+            }
+
+            this.container = this.createContainer();
+
+            this.liveRegion = $('.select2-hidden-accessible');
+            if (this.liveRegion.length == 0) {
+                this.liveRegion = $("<span>", {
+                        role: "status",
+                        "aria-live": "polite"
+                    })
+                    .addClass("select2-hidden-accessible")
+                    .appendTo(document.body);
+            }
+
+            this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid());
+            this.containerEventName= this.containerId
+                .replace(/([.])/g, '_')
+                .replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
+            this.container.attr("id", this.containerId);
+
+            this.container.attr("title", opts.element.attr("title"));
+
+            this.body = $(document.body);
+
+            syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
+
+            this.container.attr("style", opts.element.attr("style"));
+            this.container.css(evaluate(opts.containerCss, this.opts.element));
+            this.container.addClass(evaluate(opts.containerCssClass, this.opts.element));
+
+            this.elementTabIndex = this.opts.element.attr("tabindex");
+
+            // swap container for the element
+            this.opts.element
+                .data("select2", this)
+                .attr("tabindex", "-1")
+                .before(this.container)
+                .on("click.select2", killEvent); // do not leak click events
+
+            this.container.data("select2", this);
+
+            this.dropdown = this.container.find(".select2-drop");
+
+            syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
+
+            this.dropdown.addClass(evaluate(opts.dropdownCssClass, this.opts.element));
+            this.dropdown.data("select2", this);
+            this.dropdown.on("click", killEvent);
+
+            this.results = results = this.container.find(resultsSelector);
+            this.search = search = this.container.find("input.select2-input");
+
+            this.queryCount = 0;
+            this.resultsPage = 0;
+            this.context = null;
+
+            // initialize the container
+            this.initContainer();
+
+            this.container.on("click", killEvent);
+
+            installFilteredMouseMove(this.results);
+
+            this.dropdown.on("mousemove-filtered", resultsSelector, this.bind(this.highlightUnderEvent));
+            this.dropdown.on("touchstart touchmove touchend", resultsSelector, this.bind(function (event) {
+                this._touchEvent = true;
+                this.highlightUnderEvent(event);
+            }));
+            this.dropdown.on("touchmove", resultsSelector, this.bind(this.touchMoved));
+            this.dropdown.on("touchstart touchend", resultsSelector, this.bind(this.clearTouchMoved));
+
+            // Waiting for a click event on touch devices to select option and hide dropdown
+            // otherwise click will be triggered on an underlying element
+            this.dropdown.on('click', this.bind(function (event) {
+                if (this._touchEvent) {
+                    this._touchEvent = false;
+                    this.selectHighlighted();
+                }
+            }));
+
+            installDebouncedScroll(80, this.results);
+            this.dropdown.on("scroll-debounced", resultsSelector, this.bind(this.loadMoreIfNeeded));
+
+            // do not propagate change event from the search field out of the component
+            $(this.container).on("change", ".select2-input", function(e) {e.stopPropagation();});
+            $(this.dropdown).on("change", ".select2-input", function(e) {e.stopPropagation();});
+
+            // if jquery.mousewheel plugin is installed we can prevent out-of-bounds scrolling of results via mousewheel
+            if ($.fn.mousewheel) {
+                results.mousewheel(function (e, delta, deltaX, deltaY) {
+                    var top = results.scrollTop();
+                    if (deltaY > 0 && top - deltaY <= 0) {
+                        results.scrollTop(0);
+                        killEvent(e);
+                    } else if (deltaY < 0 && results.get(0).scrollHeight - results.scrollTop() + deltaY <= results.height()) {
+                        results.scrollTop(results.get(0).scrollHeight - results.height());
+                        killEvent(e);
+                    }
+                });
+            }
+
+            installKeyUpChangeEvent(search);
+            search.on("keyup-change input paste", this.bind(this.updateResults));
+            search.on("focus", function () { search.addClass("select2-focused"); });
+            search.on("blur", function () { search.removeClass("select2-focused");});
+
+            this.dropdown.on("mouseup", resultsSelector, this.bind(function (e) {
+                if ($(e.target).closest(".select2-result-selectable").length > 0) {
+                    this.highlightUnderEvent(e);
+                    this.selectHighlighted(e);
+                }
+            }));
+
+            // trap all mouse events from leaving the dropdown. sometimes there may be a modal that is listening
+            // for mouse events outside of itself so it can close itself. since the dropdown is now outside the select2's
+            // dom it will trigger the popup close, which is not what we want
+            // focusin can cause focus wars between modals and select2 since the dropdown is outside the modal.
+            this.dropdown.on("click mouseup mousedown touchstart touchend focusin", function (e) { e.stopPropagation(); });
+
+            this.lastSearchTerm = undefined;
+
+            if ($.isFunction(this.opts.initSelection)) {
+                // initialize selection based on the current value of the source element
+                this.initSelection();
+
+                // if the user has provided a function that can set selection based on the value of the source element
+                // we monitor the change event on the element and trigger it, allowing for two way synchronization
+                this.monitorSource();
+            }
+
+            if (opts.maximumInputLength !== null) {
+                this.search.attr("maxlength", opts.maximumInputLength);
+            }
+
+            var disabled = opts.element.prop("disabled");
+            if (disabled === undefined) disabled = false;
+            this.enable(!disabled);
+
+            var readonly = opts.element.prop("readonly");
+            if (readonly === undefined) readonly = false;
+            this.readonly(readonly);
+
+            // Calculate size of scrollbar
+            scrollBarDimensions = scrollBarDimensions || measureScrollbar();
+
+            this.autofocus = opts.element.prop("autofocus");
+            opts.element.prop("autofocus", false);
+            if (this.autofocus) this.focus();
+
+            this.search.attr("placeholder", opts.searchInputPlaceholder);
+        },
+
+        // abstract
+        destroy: function () {
+            var element=this.opts.element, select2 = element.data("select2"), self = this;
+
+            this.close();
+
+            if (element.length && element[0].detachEvent && self._sync) {
+                element.each(function () {
+                    if (self._sync) {
+                        this.detachEvent("onpropertychange", self._sync);
+                    }
+                });
+            }
+            if (this.propertyObserver) {
+                this.propertyObserver.disconnect();
+                this.propertyObserver = null;
+            }
+            this._sync = null;
+
+            if (select2 !== undefined) {
+                select2.container.remove();
+                select2.liveRegion.remove();
+                select2.dropdown.remove();
+                element.removeData("select2")
+                    .off(".select2");
+                if (!element.is("input[type='hidden']")) {
+                    element
+                        .show()
+                        .prop("autofocus", this.autofocus || false);
+                    if (this.elementTabIndex) {
+                        element.attr({tabindex: this.elementTabIndex});
+                    } else {
+                        element.removeAttr("tabindex");
+                    }
+                    element.show();
+                } else {
+                    element.css("display", "");
+                }
+            }
+
+            cleanupJQueryElements.call(this,
+                "container",
+                "liveRegion",
+                "dropdown",
+                "results",
+                "search"
+            );
+        },
+
+        // abstract
+        optionToData: function(element) {
+            if (element.is("option")) {
+                return {
+                    id:element.prop("value"),
+                    text:element.text(),
+                    element: element.get(),
+                    css: element.attr("class"),
+                    disabled: element.prop("disabled"),
+                    locked: equal(element.attr("locked"), "locked") || equal(element.data("locked"), true)
+                };
+            } else if (element.is("optgroup")) {
+                return {
+                    text:element.attr("label"),
+                    children:[],
+                    element: element.get(),
+                    css: element.attr("class")
+                };
+            }
+        },
+
+        // abstract
+        prepareOpts: function (opts) {
+            var element, select, idKey, ajaxUrl, self = this;
+
+            element = opts.element;
+
+            if (element.get(0).tagName.toLowerCase() === "select") {
+                this.select = select = opts.element;
+            }
+
+            if (select) {
+                // these options are not allowed when attached to a select because they are picked up off the element itself
+                $.each(["id", "multiple", "ajax", "query", "createSearchChoice", "initSelection", "data", "tags"], function () {
+                    if (this in opts) {
+                        throw new Error("Option '" + this + "' is not allowed for Select2 when attached to a <select> element.");
+                    }
+                });
+            }
+
+            opts.debug = opts.debug || $.fn.select2.defaults.debug;
+
+            // Warnings for options renamed/removed in Select2 4.0.0
+            // Only when it's enabled through debug mode
+            if (opts.debug && console && console.warn) {
+                // id was removed
+                if (opts.id != null) {
+                    console.warn(
+                        'Select2: The `id` option has been removed in Select2 4.0.0, ' +
+                        'consider renaming your `id` property or mapping the property before your data makes it to Select2. ' +
+                        'You can read more at https://select2.github.io/announcements-4.0.html#changed-id'
+                    );
+                }
+
+                // text was removed
+                if (opts.text != null) {
+                    console.warn(
+                        'Select2: The `text` option has been removed in Select2 4.0.0, ' +
+                        'consider renaming your `text` property or mapping the property before your data makes it to Select2. ' +
+                        'You can read more at https://select2.github.io/announcements-4.0.html#changed-id'
+                    );
+                }
+
+                // sortResults was renamed to results
+                if (opts.sortResults != null) {
+                    console.warn(
+                        'Select2: the `sortResults` option has been renamed to `sorter` in Select2 4.0.0. '
+                    );
+                }
+
+                // selectOnBlur was renamed to selectOnClose
+                if (opts.selectOnBlur != null) {
+                    console.warn(
+                        'Select2: The `selectOnBlur` option has been renamed to `selectOnClose` in Select2 4.0.0.'
+                    );
+                }
+
+                // ajax.results was renamed to ajax.processResults
+                if (opts.ajax != null && opts.ajax.results != null) {
+                    console.warn(
+                        'Select2: The `ajax.results` option has been renamed to `ajax.processResults` in Select2 4.0.0.'
+                    );
+                }
+
+                // format* options were renamed to language.*
+                if (opts.formatNoResults != null) {
+                    console.warn(
+                        'Select2: The `formatNoResults` option has been renamed to `language.noResults` in Select2 4.0.0.'
+                    );
+                }
+                if (opts.formatSearching != null) {
+                    console.warn(
+                        'Select2: The `formatSearching` option has been renamed to `language.searching` in Select2 4.0.0.'
+                    );
+                }
+                if (opts.formatInputTooShort != null) {
+                    console.warn(
+                        'Select2: The `formatInputTooShort` option has been renamed to `language.inputTooShort` in Select2 4.0.0.'
+                    );
+                }
+                if (opts.formatInputTooLong != null) {
+                    console.warn(
+                        'Select2: The `formatInputTooLong` option has been renamed to `language.inputTooLong` in Select2 4.0.0.'
+                    );
+                }
+                if (opts.formatLoading != null) {
+                    console.warn(
+                        'Select2: The `formatLoading` option has been renamed to `language.loadingMore` in Select2 4.0.0.'
+                    );
+                }
+                if (opts.formatSelectionTooBig != null) {
+                    console.warn(
+                        'Select2: The `formatSelectionTooBig` option has been renamed to `language.maximumSelected` in Select2 4.0.0.'
+                    );
+                }
+
+                if (opts.element.data('select2Tags')) {
+                    console.warn(
+                        'Select2: The `data-select2-tags` attribute has been renamed to `data-tags` in Select2 4.0.0.'
+                    );
+                }
+            }
+
+            // Aliasing options renamed in Select2 4.0.0
+
+            // data-select2-tags -> data-tags
+            if (opts.element.data('tags') != null) {
+                var elemTags = opts.element.data('tags');
+
+                // data-tags should actually be a boolean
+                if (!$.isArray(elemTags)) {
+                    elemTags = [];
+                }
+
+                opts.element.data('select2Tags', elemTags);
+            }
+
+            // sortResults -> sorter
+            if (opts.sorter != null) {
+                opts.sortResults = opts.sorter;
+            }
+
+            // selectOnBlur -> selectOnClose
+            if (opts.selectOnClose != null) {
+                opts.selectOnBlur = opts.selectOnClose;
+            }
+
+            // ajax.results -> ajax.processResults
+            if (opts.ajax != null) {
+                if ($.isFunction(opts.ajax.processResults)) {
+                    opts.ajax.results = opts.ajax.processResults;
+                }
+            }
+
+            // Formatters/language options
+            if (opts.language != null) {
+                var lang = opts.language;
+
+                // formatNoMatches -> language.noMatches
+                if ($.isFunction(lang.noMatches)) {
+                    opts.formatNoMatches = lang.noMatches;
+                }
+
+                // formatSearching -> language.searching
+                if ($.isFunction(lang.searching)) {
+                    opts.formatSearching = lang.searching;
+                }
+
+                // formatInputTooShort -> language.inputTooShort
+                if ($.isFunction(lang.inputTooShort)) {
+                    opts.formatInputTooShort = lang.inputTooShort;
+                }
+
+                // formatInputTooLong -> language.inputTooLong
+                if ($.isFunction(lang.inputTooLong)) {
+                    opts.formatInputTooLong = lang.inputTooLong;
+                }
+
+                // formatLoading -> language.loadingMore
+                if ($.isFunction(lang.loadingMore)) {
+                    opts.formatLoading = lang.loadingMore;
+                }
+
+                // formatSelectionTooBig -> language.maximumSelected
+                if ($.isFunction(lang.maximumSelected)) {
+                    opts.formatSelectionTooBig = lang.maximumSelected;
+                }
+            }
+
+            opts = $.extend({}, {
+                populateResults: function(container, results, query) {
+                    var populate, id=this.opts.id, liveRegion=this.liveRegion;
+
+                    populate=function(results, container, depth) {
+
+                        var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted;
+
+                        results = opts.sortResults(results, container, query);
+
+                        // collect the created nodes for bulk append
+                        var nodes = [];
+                        for (i = 0, l = results.length; i < l; i = i + 1) {
+
+                            result=results[i];
+
+                            disabled = (result.disabled === true);
+                            selectable = (!disabled) && (id(result) !== undefined);
+
+                            compound=result.children && result.children.length > 0;
+
+                            node=$("<li></li>");
+                            node.addClass("select2-results-dept-"+depth);
+                            node.addClass("select2-result");
+                            node.addClass(selectable ? "select2-result-selectable" : "select2-result-unselectable");
+                            if (disabled) { node.addClass("select2-disabled"); }
+                            if (compound) { node.addClass("select2-result-with-children"); }
+                            node.addClass(self.opts.formatResultCssClass(result));
+                            node.attr("role", "presentation");
+
+                            label=$(document.createElement("div"));
+                            label.addClass("select2-result-label");
+                            label.attr("id", "select2-result-label-" + nextUid());
+                            label.attr("role", "option");
+
+                            formatted=opts.formatResult(result, label, query, self.opts.escapeMarkup);
+                            if (formatted!==undefined) {
+                                label.html(formatted);
+                                node.append(label);
+                            }
+
+
+                            if (compound) {
+                                innerContainer=$("<ul></ul>");
+                                innerContainer.addClass("select2-result-sub");
+                                populate(result.children, innerContainer, depth+1);
+                                node.append(innerContainer);
+                            }
+
+                            node.data("select2-data", result);
+                            nodes.push(node[0]);
+                        }
+
+                        // bulk append the created nodes
+                        container.append(nodes);
+                        liveRegion.text(opts.formatMatches(results.length));
+                    };
+
+                    populate(results, container, 0);
+                }
+            }, $.fn.select2.defaults, opts);
+
+            if (typeof(opts.id) !== "function") {
+                idKey = opts.id;
+                opts.id = function (e) { return e[idKey]; };
+            }
+
+            if ($.isArray(opts.element.data("select2Tags"))) {
+                if ("tags" in opts) {
+                    throw "tags specified as both an attribute 'data-select2-tags' and in options of Select2 " + opts.element.attr("id");
+                }
+                opts.tags=opts.element.data("select2Tags");
+            }
+
+            if (select) {
+                opts.query = this.bind(function (query) {
+                    var data = { results: [], more: false },
+                        term = query.term,
+                        children, placeholderOption, process;
+
+                    process=function(element, collection) {
+                        var group;
+                        if (element.is("option")) {
+                            if (query.matcher(term, element.text(), element)) {
+                                collection.push(self.optionToData(element));
+                            }
+                        } else if (element.is("optgroup")) {
+                            group=self.optionToData(element);
+                            element.children().each2(function(i, elm) { process(elm, group.children); });
+                            if (group.children.length>0) {
+                                collection.push(group);
+                            }
+                        }
+                    };
+
+                    children=element.children();
+
+                    // ignore the placeholder option if there is one
+                    if (this.getPlaceholder() !== undefined && children.length > 0) {
+                        placeholderOption = this.getPlaceholderOption();
+                        if (placeholderOption) {
+                            children=children.not(placeholderOption);
+                        }
+                    }
+
+                    children.each2(function(i, elm) { process(elm, data.results); });
+
+                    query.callback(data);
+                });
+                // this is needed because inside val() we construct choices from options and their id is hardcoded
+                opts.id=function(e) { return e.id; };
+            } else {
+                if (!("query" in opts)) {
+                    if ("ajax" in opts) {
+                        ajaxUrl = opts.element.data("ajax-url");
+                        if (ajaxUrl && ajaxUrl.length > 0) {
+                            opts.ajax.url = ajaxUrl;
+                        }
+                        opts.query = ajax.call(opts.element, opts.ajax);
+                    } else if ("data" in opts) {
+                        opts.query = local(opts.data);
+                    } else if ("tags" in opts) {
+                        opts.query = tags(opts.tags);
+                        if (opts.createSearchChoice === undefined) {
+                            opts.createSearchChoice = function (term) { return {id: $.trim(term), text: $.trim(term)}; };
+                        }
+                        if (opts.initSelection === undefined) {
+                            opts.initSelection = function (element, callback) {
+                                var data = [];
+                                $(splitVal(element.val(), opts.separator, opts.transformVal)).each(function () {
+                                    var obj = { id: this, text: this },
+                                        tags = opts.tags;
+                                    if ($.isFunction(tags)) tags=tags();
+                                    $(tags).each(function() { if (equal(this.id, obj.id)) { obj = this; return false; } });
+                                    data.push(obj);
+                                });
+
+                                callback(data);
+                            };
+                        }
+                    }
+                }
+            }
+            if (typeof(opts.query) !== "function") {
+                throw "query function not defined for Select2 " + opts.element.attr("id");
+            }
+
+            if (opts.createSearchChoicePosition === 'top') {
+                opts.createSearchChoicePosition = function(list, item) { list.unshift(item); };
+            }
+            else if (opts.createSearchChoicePosition === 'bottom') {
+                opts.createSearchChoicePosition = function(list, item) { list.push(item); };
+            }
+            else if (typeof(opts.createSearchChoicePosition) !== "function")  {
+                throw "invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";
+            }
+
+            return opts;
+        },
+
+        /**
+         * Monitor the original element for changes and update select2 accordingly
+         */
+        // abstract
+        monitorSource: function () {
+            var el = this.opts.element, observer, self = this;
+
+            el.on("change.select2", this.bind(function (e) {
+                if (this.opts.element.data("select2-change-triggered") !== true) {
+                    this.initSelection();
+                }
+            }));
+
+            this._sync = this.bind(function () {
+
+                // sync enabled state
+                var disabled = el.prop("disabled");
+                if (disabled === undefined) disabled = false;
+                this.enable(!disabled);
+
+                var readonly = el.prop("readonly");
+                if (readonly === undefined) readonly = false;
+                this.readonly(readonly);
+
+                if (this.container) {
+                    syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
+                    this.container.addClass(evaluate(this.opts.containerCssClass, this.opts.element));
+                }
+
+                if (this.dropdown) {
+                    syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
+                    this.dropdown.addClass(evaluate(this.opts.dropdownCssClass, this.opts.element));
+                }
+
+            });
+
+            // IE8-10 (IE9/10 won't fire propertyChange via attachEventListener)
+            if (el.length && el[0].attachEvent) {
+                el.each(function() {
+                    this.attachEvent("onpropertychange", self._sync);
+                });
+            }
+
+            // safari, chrome, firefox, IE11
+            observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver;
+            if (observer !== undefined) {
+                if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
+                this.propertyObserver = new observer(function (mutations) {
+                    $.each(mutations, self._sync);
+                });
+                this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
+            }
+        },
+
+        // abstract
+        triggerSelect: function(data) {
+            var evt = $.Event("select2-selecting", { val: this.id(data), object: data, choice: data });
+            this.opts.element.trigger(evt);
+            return !evt.isDefaultPrevented();
+        },
+
+        /**
+         * Triggers the change event on the source element
+         */
+        // abstract
+        triggerChange: function (details) {
+
+            details = details || {};
+            details= $.extend({}, details, { type: "change", val: this.val() });
+            // prevents recursive triggering
+            this.opts.element.data("select2-change-triggered", true);
+            this.opts.element.trigger(details);
+            this.opts.element.data("select2-change-triggered", false);
+
+            // some validation frameworks ignore the change event and listen instead to keyup, click for selects
+            // so here we trigger the click event manually
+            this.opts.element.click();
+
+            // ValidationEngine ignores the change event and listens instead to blur
+            // so here we trigger the blur event manually if so desired
+            if (this.opts.blurOnChange)
+                this.opts.element.blur();
+        },
+
+        //abstract
+        isInterfaceEnabled: function()
+        {
+            return this.enabledInterface === true;
+        },
+
+        // abstract
+        enableInterface: function() {
+            var enabled = this._enabled && !this._readonly,
+                disabled = !enabled;
+
+            if (enabled === this.enabledInterface) return false;
+
+            this.container.toggleClass("select2-container-disabled", disabled);
+            this.close();
+            this.enabledInterface = enabled;
+
+            return true;
+        },
+
+        // abstract
+        enable: function(enabled) {
+            if (enabled === undefined) enabled = true;
+            if (this._enabled === enabled) return;
+            this._enabled = enabled;
+
+            this.opts.element.prop("disabled", !enabled);
+            this.enableInterface();
+        },
+
+        // abstract
+        disable: function() {
+            this.enable(false);
+        },
+
+        // abstract
+        readonly: function(enabled) {
+            if (enabled === undefined) enabled = false;
+            if (this._readonly === enabled) return;
+            this._readonly = enabled;
+
+            this.opts.element.prop("readonly", enabled);
+            this.enableInterface();
+        },
+
+        // abstract
+        opened: function () {
+            return (this.container) ? this.container.hasClass("select2-dropdown-open") : false;
+        },
+
+        // abstract
+        positionDropdown: function() {
+            var $dropdown = this.dropdown,
+                container = this.container,
+                offset = container.offset(),
+                height = container.outerHeight(false),
+                width = container.outerWidth(false),
+                dropHeight = $dropdown.outerHeight(false),
+                $window = $(window),
+                windowWidth = $window.width(),
+                windowHeight = $window.height(),
+                viewPortRight = $window.scrollLeft() + windowWidth,
+                viewportBottom = $window.scrollTop() + windowHeight,
+                dropTop = offset.top + height,
+                dropLeft = offset.left,
+                enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
+                enoughRoomAbove = (offset.top - dropHeight) >= $window.scrollTop(),
+                dropWidth = $dropdown.outerWidth(false),
+                enoughRoomOnRight = function() {
+                    return dropLeft + dropWidth <= viewPortRight;
+                },
+                enoughRoomOnLeft = function() {
+                    return offset.left + viewPortRight + container.outerWidth(false)  > dropWidth;
+                },
+                aboveNow = $dropdown.hasClass("select2-drop-above"),
+                bodyOffset,
+                above,
+                changeDirection,
+                css,
+                resultsListNode;
+
+            // always prefer the current above/below alignment, unless there is not enough room
+            if (aboveNow) {
+                above = true;
+                if (!enoughRoomAbove && enoughRoomBelow) {
+                    changeDirection = true;
+                    above = false;
+                }
+            } else {
+                above = false;
+                if (!enoughRoomBelow && enoughRoomAbove) {
+                    changeDirection = true;
+                    above = true;
+                }
+            }
+
+            //if we are changing direction we need to get positions when dropdown is hidden;
+            if (changeDirection) {
+                $dropdown.hide();
+                offset = this.container.offset();
+                height = this.container.outerHeight(false);
+                width = this.container.outerWidth(false);
+                dropHeight = $dropdown.outerHeight(false);
+                viewPortRight = $window.scrollLeft() + windowWidth;
+                viewportBottom = $window.scrollTop() + windowHeight;
+                dropTop = offset.top + height;
+                dropLeft = offset.left;
+                dropWidth = $dropdown.outerWidth(false);
+                $dropdown.show();
+
+                // fix so the cursor does not move to the left within the search-textbox in IE
+                this.focusSearch();
+            }
+
+            if (this.opts.dropdownAutoWidth) {
+                resultsListNode = $('.select2-results', $dropdown)[0];
+                $dropdown.addClass('select2-drop-auto-width');
+                $dropdown.css('width', '');
+                // Add scrollbar width to dropdown if vertical scrollbar is present
+                dropWidth = $dropdown.outerWidth(false) + (resultsListNode.scrollHeight === resultsListNode.clientHeight ? 0 : scrollBarDimensions.width);
+                dropWidth > width ? width = dropWidth : dropWidth = width;
+                dropHeight = $dropdown.outerHeight(false);
+            }
+            else {
+                this.container.removeClass('select2-drop-auto-width');
+            }
+
+            //console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
+            //console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body.scrollTop(), "enough?", enoughRoomAbove);
+
+            // fix positioning when body has an offset and is not position: static
+            if (this.body.css('position') !== 'static') {
+                bodyOffset = this.body.offset();
+                dropTop -= bodyOffset.top;
+                dropLeft -= bodyOffset.left;
+            }
+
+            if (!enoughRoomOnRight() && enoughRoomOnLeft()) {
+                dropLeft = offset.left + this.container.outerWidth(false) - dropWidth;
+            }
+
+            css =  {
+                left: dropLeft,
+                width: width
+            };
+
+            if (above) {
+                this.container.addClass("select2-drop-above");
+                $dropdown.addClass("select2-drop-above");
+                dropHeight = $dropdown.outerHeight(false);
+                css.top = offset.top - dropHeight;
+                css.bottom = 'auto';
+            }
+            else {
+                css.top = dropTop;
+                css.bottom = 'auto';
+                this.container.removeClass("select2-drop-above");
+                $dropdown.removeClass("select2-drop-above");
+            }
+            css = $.extend(css, evaluate(this.opts.dropdownCss, this.opts.element));
+
+            $dropdown.css(css);
+        },
+
+        // abstract
+        shouldOpen: function() {
+            var event;
+
+            if (this.opened()) return false;
+
+            if (this._enabled === false || this._readonly === true) return false;
+
+            event = $.Event("select2-opening");
+            this.opts.element.trigger(event);
+            return !event.isDefaultPrevented();
+        },
+
+        // abstract
+        clearDropdownAlignmentPreference: function() {
+            // clear the classes used to figure out the preference of where the dropdown should be opened
+            this.container.removeClass("select2-drop-above");
+            this.dropdown.removeClass("select2-drop-above");
+        },
+
+        /**
+         * Opens the dropdown
+         *
+         * @return {Boolean} whether or not dropdown was opened. This method will return false if, for example,
+         * the dropdown is already open, or if the 'open' event listener on the element called preventDefault().
+         */
+        // abstract
+        open: function () {
+
+            if (!this.shouldOpen()) return false;
+
+            this.opening();
+
+            // Only bind the document mousemove when the dropdown is visible
+            $document.on("mousemove.select2Event", function (e) {
+                lastMousePosition.x = e.pageX;
+                lastMousePosition.y = e.pageY;
+            });
+
+            return true;
+        },
+
+        /**
+         * Performs the opening of the dropdown
+         */
+        // abstract
+        opening: function() {
+            var cid = this.containerEventName,
+                scroll = "scroll." + cid,
+                resize = "resize."+cid,
+                orient = "orientationchange."+cid,
+                mask;
+
+            this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
+
+            this.clearDropdownAlignmentPreference();
+
+            if(this.dropdown[0] !== this.body.children().last()[0]) {
+                this.dropdown.detach().appendTo(this.body);
+            }
+
+            // create the dropdown mask if doesn't already exist
+            mask = $("#select2-drop-mask");
+            if (mask.length === 0) {
+                mask = $(document.createElement("div"));
+                mask.attr("id","select2-drop-mask").attr("class","select2-drop-mask");
+                mask.hide();
+                mask.appendTo(this.body);
+                mask.on("mousedown touchstart click", function (e) {
+                    // Prevent IE from generating a click event on the body
+                    reinsertElement(mask);
+
+                    var dropdown = $("#select2-drop"), self;
+                    if (dropdown.length > 0) {
+                        self=dropdown.data("select2");
+                        if (self.opts.selectOnBlur) {
+                            self.selectHighlighted({noFocus: true});
+                        }
+                        self.close();
+                        e.preventDefault();
+                        e.stopPropagation();
+                    }
+                });
+            }
+
+            // ensure the mask is always right before the dropdown
+            if (this.dropdown.prev()[0] !== mask[0]) {
+                this.dropdown.before(mask);
+            }
+
+            // move the global id to the correct dropdown
+            $("#select2-drop").removeAttr("id");
+            this.dropdown.attr("id", "select2-drop");
+
+            // show the elements
+            mask.show();
+
+            this.positionDropdown();
+            this.dropdown.show();
+            this.positionDropdown();
+
+            this.dropdown.addClass("select2-drop-active");
+
+            // attach listeners to events that can change the position of the container and thus require
+            // the position of the dropdown to be updated as well so it does not come unglued from the container
+            var that = this;
+            this.container.parents().add(window).each(function () {
+                $(this).on(resize+" "+scroll+" "+orient, function (e) {
+                    if (that.opened()) that.positionDropdown();
+                });
+            });
+
+
+        },
+
+        // abstract
+        close: function () {
+            if (!this.opened()) return;
+
+            var cid = this.containerEventName,
+                scroll = "scroll." + cid,
+                resize = "resize."+cid,
+                orient = "orientationchange."+cid;
+
+            // unbind event listeners
+            this.container.parents().add(window).each(function () { $(this).off(scroll).off(resize).off(orient); });
+
+            this.clearDropdownAlignmentPreference();
+
+            $("#select2-drop-mask").hide();
+            this.dropdown.removeAttr("id"); // only the active dropdown has the select2-drop id
+            this.dropdown.hide();
+            this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");
+            this.results.empty();
+
+            // Now that the dropdown is closed, unbind the global document mousemove event
+            $document.off("mousemove.select2Event");
+
+            this.clearSearch();
+            this.search.removeClass("select2-active");
+
+            // Remove the aria active descendant for highlighted element
+            this.search.removeAttr("aria-activedescendant");
+            this.opts.element.trigger($.Event("select2-close"));
+        },
+
+        /**
+         * Opens control, sets input value, and updates results.
+         */
+        // abstract
+        externalSearch: function (term) {
+            this.open();
+            this.search.val(term);
+            this.updateResults(false);
+        },
+
+        // abstract
+        clearSearch: function () {
+
+        },
+
+        /**
+         * @return {Boolean} Whether or not search value was changed.
+         * @private
+         */
+        prefillNextSearchTerm: function () {
+            // initializes search's value with nextSearchTerm (if defined by user)
+            // ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
+            if(this.search.val() !== "") {
+                return false;
+            }
+
+            var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.lastSearchTerm);
+            if(nextSearchTerm !== undefined){
+                this.search.val(nextSearchTerm);
+                this.search.select();
+                return true;
+            }
+
+            return false;
+        },
+
+        //abstract
+        getMaximumSelectionSize: function() {
+            return evaluate(this.opts.maximumSelectionSize, this.opts.element);
+        },
+
+        // abstract
+        ensureHighlightVisible: function () {
+            var results = this.results, children, index, child, hb, rb, y, more, topOffset;
+
+            index = this.highlight();
+
+            if (index < 0) return;
+
+            if (index == 0) {
+
+                // if the first element is highlighted scroll all the way to the top,
+                // that way any unselectable headers above it will also be scrolled
+                // into view
+
+                results.scrollTop(0);
+                return;
+            }
+
+            children = this.findHighlightableChoices().find('.select2-result-label');
+
+            child = $(children[index]);
+
+            topOffset = (child.offset() || {}).top || 0;
+
+            hb = topOffset + child.outerHeight(true);
+
+            // if this is the last child lets also make sure select2-more-results is visible
+            if (index === children.length - 1) {
+                more = results.find("li.select2-more-results");
+                if (more.length > 0) {
+                    hb = more.offset().top + more.outerHeight(true);
+                }
+            }
+
+            rb = results.offset().top + results.outerHeight(false);
+            if (hb > rb) {
+                results.scrollTop(results.scrollTop() + (hb - rb));
+            }
+            y = topOffset - results.offset().top;
+
+            // make sure the top of the element is visible
+            if (y < 0 && child.css('display') != 'none' ) {
+                results.scrollTop(results.scrollTop() + y); // y is negative
+            }
+        },
+
+        // abstract
+        findHighlightableChoices: function() {
+            return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)");
+        },
+
+        // abstract
+        moveHighlight: function (delta) {
+            var choices = this.findHighlightableChoices(),
+                index = this.highlight();
+
+            while (index > -1 && index < choices.length) {
+                index += delta;
+                var choice = $(choices[index]);
+                if (choice.hasClass("select2-result-selectable") && !choice.hasClass("select2-disabled") && !choice.hasClass("select2-selected")) {
+                    this.highlight(index);
+                    break;
+                }
+            }
+        },
+
+        // abstract
+        highlight: function (index) {
+            var choices = this.findHighlightableChoices(),
+                choice,
+                data;
+
+            if (arguments.length === 0) {
+                return indexOf(choices.filter(".select2-highlighted")[0], choices.get());
+            }
+
+            if (index >= choices.length) index = choices.length - 1;
+            if (index < 0) index = 0;
+
+            this.removeHighlight();
+
+            choice = $(choices[index]);
+            choice.addClass("select2-highlighted");
+
+            // ensure assistive technology can determine the active choice
+            this.search.attr("aria-activedescendant", choice.find(".select2-result-label").attr("id"));
+
+            this.ensureHighlightVisible();
+
+            this.liveRegion.text(choice.text());
+
+            data = choice.data("select2-data");
+            if (data) {
+                this.opts.element.trigger({ type: "select2-highlight", val: this.id(data), choice: data });
+            }
+        },
+
+        removeHighlight: function() {
+            this.results.find(".select2-highlighted").removeClass("select2-highlighted");
+        },
+
+        touchMoved: function() {
+            this._touchMoved = true;
+        },
+
+        clearTouchMoved: function() {
+          this._touchMoved = false;
+        },
+
+        // abstract
+        countSelectableResults: function() {
+            return this.findHighlightableChoices().length;
+        },
+
+        // abstract
+        highlightUnderEvent: function (event) {
+            var el = $(event.target).closest(".select2-result-selectable");
+            if (el.length > 0 && !el.is(".select2-highlighted")) {
+                var choices = this.findHighlightableChoices();
+                this.highlight(choices.index(el));
+            } else if (el.length == 0) {
+                // if we are over an unselectable item remove all highlights
+                this.removeHighlight();
+            }
+        },
+
+        // abstract
+        loadMoreIfNeeded: function () {
+            var results = this.results,
+                more = results.find("li.select2-more-results"),
+                below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
+                page = this.resultsPage + 1,
+                self=this,
+                term=this.search.val(),
+                context=this.context;
+
+            if (more.length === 0) return;
+            below = more.offset().top - results.offset().top - results.height();
+
+            if (below <= this.opts.loadMorePadding) {
+                more.addClass("select2-active");
+                this.opts.query({
+                        element: this.opts.element,
+                        term: term,
+                        page: page,
+                        context: context,
+                        matcher: this.opts.matcher,
+                        callback: this.bind(function (data) {
+
+                    // ignore a response if the select2 has been closed before it was received
+                    if (!self.opened()) return;
+
+
+                    self.opts.populateResults.call(this, results, data.results, {term: term, page: page, context:context});
+                    self.postprocessResults(data, false, false);
+
+                    if (data.more===true) {
+                        more.detach().appendTo(results).html(self.opts.escapeMarkup(evaluate(self.opts.formatLoadMore, self.opts.element, page+1)));
+                        window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10);
+                    } else {
+                        more.remove();
+                    }
+                    self.positionDropdown();
+                    self.resultsPage = page;
+                    self.context = data.context;
+                    this.opts.element.trigger({ type: "select2-loaded", items: data });
+                })});
+            }
+        },
+
+        /**
+         * Default tokenizer function which does nothing
+         */
+        tokenize: function() {
+
+        },
+
+        /**
+         * @param initial whether or not this is the call to this method right after the dropdown has been opened
+         */
+        // abstract
+        updateResults: function (initial) {
+            var search = this.search,
+                results = this.results,
+                opts = this.opts,
+                data,
+                self = this,
+                input,
+                term = search.val(),
+                lastTerm = $.data(this.container, "select2-last-term"),
+                // sequence number used to drop out-of-order responses
+                queryNumber;
+
+            // prevent duplicate queries against the same term
+            if (initial !== true && lastTerm && equal(term, lastTerm)) return;
+
+            $.data(this.container, "select2-last-term", term);
+
+            // if the search is currently hidden we do not alter the results
+            if (initial !== true && (this.showSearchInput === false || !this.opened())) {
+                return;
+            }
+
+            function postRender() {
+                search.removeClass("select2-active");
+                self.positionDropdown();
+                if (results.find('.select2-no-results,.select2-selection-limit,.select2-searching').length) {
+                    self.liveRegion.text(results.text());
+                }
+                else {
+                    self.liveRegion.text(self.opts.formatMatches(results.find('.select2-result-selectable:not(".select2-selected")').length));
+                }
+            }
+
+            function render(html) {
+                results.html(html);
+                postRender();
+            }
+
+            queryNumber = ++this.queryCount;
+
+            var maxSelSize = this.getMaximumSelectionSize();
+            if (maxSelSize >=1) {
+                data = this.data();
+                if ($.isArray(data) && data.length >= maxSelSize && checkFormatter(opts.formatSelectionTooBig, "formatSelectionTooBig")) {
+                    render("<li class='select2-selection-limit'>" + evaluate(opts.formatSelectionTooBig, opts.element, maxSelSize) + "</li>");
+                    return;
+                }
+            }
+
+            if (search.val().length < opts.minimumInputLength) {
+                if (checkFormatter(opts.formatInputTooShort, "formatInputTooShort")) {
+                    render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooShort, opts.element, search.val(), opts.minimumInputLength) + "</li>");
+                } else {
+                    render("");
+                }
+                if (initial && this.showSearch) this.showSearch(true);
+                return;
+            }
+
+            if (opts.maximumInputLength && search.val().length > opts.maximumInputLength) {
+                if (checkFormatter(opts.formatInputTooLong, "formatInputTooLong")) {
+                    render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooLong, opts.element, search.val(), opts.maximumInputLength) + "</li>");
+                } else {
+                    render("");
+                }
+                return;
+            }
+
+            if (opts.formatSearching && this.findHighlightableChoices().length === 0) {
+                render("<li class='select2-searching'>" + evaluate(opts.formatSearching, opts.element) + "</li>");
+            }
+
+            search.addClass("select2-active");
+
+            this.removeHighlight();
+
+            // give the tokenizer a chance to pre-process the input
+            input = this.tokenize();
+            if (input != undefined && input != null) {
+                search.val(input);
+            }
+
+            this.resultsPage = 1;
+
+            opts.query({
+                element: opts.element,
+                    term: search.val(),
+                    page: this.resultsPage,
+                    context: null,
+                    matcher: opts.matcher,
+                    callback: this.bind(function (data) {
+                var def; // default choice
+
+                // ignore old responses
+                if (queryNumber != this.queryCount) {
+                  return;
+                }
+
+                // ignore a response if the select2 has been closed before it was received
+                if (!this.opened()) {
+                    this.search.removeClass("select2-active");
+                    return;
+                }
+
+                // handle ajax error
+                if(data.hasError !== undefined && checkFormatter(opts.formatAjaxError, "formatAjaxError")) {
+                    render("<li class='select2-ajax-error'>" + evaluate(opts.formatAjaxError, opts.element, data.jqXHR, data.textStatus, data.errorThrown) + "</li>");
+                    return;
+                }
+
+                // save context, if any
+                this.context = (data.context===undefined) ? null : data.context;
+                // create a default choice and prepend it to the list
+                if (this.opts.createSearchChoice && search.val() !== "") {
+                    def = this.opts.createSearchChoice.call(self, search.val(), data.results);
+                    if (def !== undefined && def !== null && self.id(def) !== undefined && self.id(def) !== null) {
+                        if ($(data.results).filter(
+                            function () {
+                                return equal(self.id(this), self.id(def));
+                            }).length === 0) {
+                            this.opts.createSearchChoicePosition(data.results, def);
+                        }
+                    }
+                }
+
+                if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) {
+                    render("<li class='select2-no-results'>" + evaluate(opts.formatNoMatches, opts.element, search.val()) + "</li>");
+                    if(this.showSearch){
+                        this.showSearch(search.val());
+                    }
+                    return;
+                }
+
+                results.empty();
+                self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null});
+
+                if (data.more === true && checkFormatter(opts.formatLoadMore, "formatLoadMore")) {
+                    results.append("<li class='select2-more-results'>" + opts.escapeMarkup(evaluate(opts.formatLoadMore, opts.element, this.resultsPage)) + "</li>");
+                    window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10);
+                }
+
+                this.postprocessResults(data, initial);
+
+                postRender();
+
+                this.opts.element.trigger({ type: "select2-loaded", items: data });
+            })});
+        },
+
+        // abstract
+        cancel: function () {
+            this.close();
+        },
+
+        // abstract
+        blur: function () {
+            // if selectOnBlur == true, select the currently highlighted option
+            if (this.opts.selectOnBlur)
+                this.selectHighlighted({noFocus: true});
+
+            this.close();
+            this.container.removeClass("select2-container-active");
+            // synonymous to .is(':focus'), which is available in jquery >= 1.6
+            if (this.search[0] === document.activeElement) { this.search.blur(); }
+            this.clearSearch();
+            this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
+        },
+
+        // abstract
+        focusSearch: function () {
+            focus(this.search);
+        },
+
+        // abstract
+        selectHighlighted: function (options) {
+            if (this._touchMoved) {
+              this.clearTouchMoved();
+              return;
+            }
+            var index=this.highlight(),
+                highlighted=this.results.find(".select2-highlighted"),
+                data = highlighted.closest('.select2-result').data("select2-data");
+
+            if (data) {
+                this.highlight(index);
+                this.onSelect(data, options);
+            } else if (options && options.noFocus) {
+                this.close();
+            }
+        },
+
+        // abstract
+        getPlaceholder: function () {
+            var placeholderOption;
+            return this.opts.element.attr("placeholder") ||
+                this.opts.element.attr("data-placeholder") || // jquery 1.4 compat
+                this.opts.element.data("placeholder") ||
+                this.opts.placeholder ||
+                ((placeholderOption = this.getPlaceholderOption()) !== undefined ? placeholderOption.text() : undefined);
+        },
+
+        // abstract
+        getPlaceholderOption: function() {
+            if (this.select) {
+                var firstOption = this.select.children('option').first();
+                if (this.opts.placeholderOption !== undefined ) {
+                    //Determine the placeholder option based on the specified placeholderOption setting
+                    return (this.opts.placeholderOption === "first" && firstOption) ||
+                           (typeof this.opts.placeholderOption === "function" && this.opts.placeholderOption(this.select));
+                } else if ($.trim(firstOption.text()) === "" && firstOption.val() === "") {
+                    //No explicit placeholder option specified, use the first if it's blank
+                    return firstOption;
+                }
+            }
+        },
+
+        /**
+         * Get the desired width for the container element.  This is
+         * derived first from option `width` passed to select2, then
+         * the inline 'style' on the original element, and finally
+         * falls back to the jQuery calculated element width.
+         */
+        // abstract
+        initContainerWidth: function () {
+            function resolveContainerWidth() {
+                var style, attrs, matches, i, l, attr;
+
+                if (this.opts.width === "off") {
+                    return null;
+                } else if (this.opts.width === "element"){
+                    return this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px';
+                } else if (this.opts.width === "copy" || this.opts.width === "resolve") {
+                    // check if there is inline style on the element that contains width
+                    style = this.opts.element.attr('style');
+                    if (typeof(style) === "string") {
+                        attrs = style.split(';');
+                        for (i = 0, l = attrs.length; i < l; i = i + 1) {
+                            attr = attrs[i].replace(/\s/g, '');
+                            matches = attr.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);
+                            if (matches !== null && matches.length >= 1)
+                                return matches[1];
+                        }
+                    }
+
+                    if (this.opts.width === "resolve") {
+                        // next check if css('width') can resolve a width that is percent based, this is sometimes possible
+                        // when attached to input type=hidden or elements hidden via css
+                        style = this.opts.element.css('width');
+                        if (style.indexOf("%") > 0) return style;
+
+                        // finally, fallback on the calculated width of the element
+                        return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
+                    }
+
+                    return null;
+                } else if ($.isFunction(this.opts.width)) {
+                    return this.opts.width();
+                } else {
+                    return this.opts.width;
+               }
+            };
+
+            var width = resolveContainerWidth.call(this);
+            if (width !== null) {
+                this.container.css("width", width);
+            }
+        }
+    });
+
+    SingleSelect2 = clazz(AbstractSelect2, {
+
+        // single
+
+        createContainer: function () {
+            var container = $(document.createElement("div")).attr({
+                "class": "select2-container"
+            }).html([
+                "<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>",
+                "   <span class='select2-chosen'>&#160;</span><abbr class='select2-search-choice-close'></abbr>",
+                "   <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>",
+                "</a>",
+                "<label for='' class='select2-offscreen'></label>",
+                "<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />",
+                "<div class='select2-drop select2-display-none'>",
+                "   <div class='select2-search'>",
+                "       <label for='' class='select2-offscreen'></label>",
+                "       <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'",
+                "       aria-autocomplete='list' />",
+                "   </div>",
+                "   <ul class='select2-results' role='listbox'>",
+                "   </ul>",
+                "</div>"].join(""));
+            return container;
+        },
+
+        // single
+        enableInterface: function() {
+            if (this.parent.enableInterface.apply(this, arguments)) {
+                this.focusser.prop("disabled", !this.isInterfaceEnabled());
+            }
+        },
+
+        // single
+        opening: function () {
+            var el, range, len;
+
+            if (this.opts.minimumResultsForSearch >= 0) {
+                this.showSearch(true);
+            }
+
+            this.parent.opening.apply(this, arguments);
+
+            if (this.showSearchInput !== false) {
+                // IE appends focusser.val() at the end of field :/ so we manually insert it at the beginning using a range
+                // all other browsers handle this just fine
+
+                this.search.val(this.focusser.val());
+            }
+            if (this.opts.shouldFocusInput(this)) {
+                this.search.focus();
+                // move the cursor to the end after focussing, otherwise it will be at the beginning and
+                // new text will appear *before* focusser.val()
+                el = this.search.get(0);
+                if (el.createTextRange) {
+                    range = el.createTextRange();
+                    range.collapse(false);
+                    range.select();
+                } else if (el.setSelectionRange) {
+                    len = this.search.val().length;
+                    el.setSelectionRange(len, len);
+                }
+            }
+
+            this.prefillNextSearchTerm();
+
+            this.focusser.prop("disabled", true).val("");
+            this.updateResults(true);
+            this.opts.element.trigger($.Event("select2-open"));
+        },
+
+        // single
+        close: function () {
+            if (!this.opened()) return;
+            this.parent.close.apply(this, arguments);
+
+            this.focusser.prop("disabled", false);
+
+            if (this.opts.shouldFocusInput(this)) {
+                this.focusser.focus();
+            }
+        },
+
+        // single
+        focus: function () {
+            if (this.opened()) {
+                this.close();
+            } else {
+                this.focusser.prop("disabled", false);
+                if (this.opts.shouldFocusInput(this)) {
+                    this.focusser.focus();
+                }
+            }
+        },
+
+        // single
+        isFocused: function () {
+            return this.container.hasClass("select2-container-active");
+        },
+
+        // single
+        cancel: function () {
+            this.parent.cancel.apply(this, arguments);
+            this.focusser.prop("disabled", false);
+
+            if (this.opts.shouldFocusInput(this)) {
+                this.focusser.focus();
+            }
+        },
+
+        // single
+        destroy: function() {
+            $("label[for='" + this.focusser.attr('id') + "']")
+                .attr('for', this.opts.element.attr("id"));
+            this.parent.destroy.apply(this, arguments);
+
+            cleanupJQueryElements.call(this,
+                "selection",
+                "focusser"
+            );
+        },
+
+        // single
+        initContainer: function () {
+
+            var selection,
+                container = this.container,
+                dropdown = this.dropdown,
+                idSuffix = nextUid(),
+                elementLabel;
+
+            if (this.opts.minimumResultsForSearch < 0) {
+                this.showSearch(false);
+            } else {
+                this.showSearch(true);
+            }
+
+            this.selection = selection = container.find(".select2-choice");
+
+            this.focusser = container.find(".select2-focusser");
+
+            // add aria associations
+            selection.find(".select2-chosen").attr("id", "select2-chosen-"+idSuffix);
+            this.focusser.attr("aria-labelledby", "select2-chosen-"+idSuffix);
+            this.results.attr("id", "select2-results-"+idSuffix);
+            this.search.attr("aria-owns", "select2-results-"+idSuffix);
+
+            // rewrite labels from original element to focusser
+            this.focusser.attr("id", "s2id_autogen"+idSuffix);
+
+            elementLabel = $("label[for='" + this.opts.element.attr("id") + "']");
+            this.opts.element.on('focus.select2', this.bind(function () { this.focus(); }));
+
+            this.focusser.prev()
+                .text(elementLabel.text())
+                .attr('for', this.focusser.attr('id'));
+
+            // Ensure the original element retains an accessible name
+            var originalTitle = this.opts.element.attr("title");
+            this.opts.element.attr("title", (originalTitle || elementLabel.text()));
+
+            this.focusser.attr("tabindex", this.elementTabIndex);
+
+            // write label for search field using the label from the focusser element
+            this.search.attr("id", this.focusser.attr('id') + '_search');
+
+            this.search.prev()
+                .text($("label[for='" + this.focusser.attr('id') + "']").text())
+                .attr('for', this.search.attr('id'));
+
+            this.search.on("keydown", this.bind(function (e) {
+                if (!this.isInterfaceEnabled()) return;
+
+                // filter 229 keyCodes (input method editor is processing key input)
+                if (229 == e.keyCode) return;
+
+                if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) {
+                    // prevent the page from scrolling
+                    killEvent(e);
+                    return;
+                }
+
+                switch (e.which) {
+                    case KEY.UP:
+                    case KEY.DOWN:
+                        this.moveHighlight((e.which === KEY.UP) ? -1 : 1);
+                        killEvent(e);
+                        return;
+                    case KEY.ENTER:
+                        this.selectHighlighted();
+                        killEvent(e);
+                        return;
+                    case KEY.TAB:
+                        this.selectHighlighted({noFocus: true});
+                        return;
+                    case KEY.ESC:
+                        this.cancel(e);
+                        killEvent(e);
+                        return;
+                }
+            }));
+
+            this.search.on("blur", this.bind(function(e) {
+                // a workaround for chrome to keep the search field focussed when the scroll bar is used to scroll the dropdown.
+                // without this the search field loses focus which is annoying
+                if (document.activeElement === this.body.get(0)) {
+                    window.setTimeout(this.bind(function() {
+                        if (this.opened() && this.results && this.results.length > 1) {
+                            this.search.focus();
+                        }
+                    }), 0);
+                }
+            }));
+
+            this.focusser.on("keydown", this.bind(function (e) {
+                if (!this.isInterfaceEnabled()) return;
+
+                if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
+                    return;
+                }
+
+                if (this.opts.openOnEnter === false && e.which === KEY.ENTER) {
+                    killEvent(e);
+                    return;
+                }
+
+                if (e.which == KEY.DOWN || e.which == KEY.UP
+                    || (e.which == KEY.ENTER && this.opts.openOnEnter)) {
+
+                    if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return;
+
+                    this.open();
+                    killEvent(e);
+                    return;
+                }
+
+                if (e.which == KEY.DELETE || e.which == KEY.BACKSPACE) {
+                    if (this.opts.allowClear) {
+                        this.clear();
+                    }
+                    killEvent(e);
+                    return;
+                }
+            }));
+
+
+            installKeyUpChangeEvent(this.focusser);
+            this.focusser.on("keyup-change input", this.bind(function(e) {
+                if (this.opts.minimumResultsForSearch >= 0) {
+                    e.stopPropagation();
+                    if (this.opened()) return;
+                    this.open();
+                }
+            }));
+
+            selection.on("mousedown touchstart", "abbr", this.bind(function (e) {
+                if (!this.isInterfaceEnabled()) {
+                    return;
+                }
+
+                this.clear();
+                killEventImmediately(e);
+                this.close();
+
+                if (this.selection) {
+                    this.selection.focus();
+                }
+            }));
+
+            selection.on("mousedown touchstart", this.bind(function (e) {
+                // Prevent IE from generating a click event on the body
+                reinsertElement(selection);
+
+                if (!this.container.hasClass("select2-container-active")) {
+                    this.opts.element.trigger($.Event("select2-focus"));
+                }
+
+                if (this.opened()) {
+                    this.close();
+                } else if (this.isInterfaceEnabled()) {
+                    this.open();
+                }
+
+                killEvent(e);
+            }));
+
+            dropdown.on("mousedown touchstart", this.bind(function() {
+                if (this.opts.shouldFocusInput(this)) {
+                    this.search.focus();
+                }
+            }));
+
+            selection.on("focus", this.bind(function(e) {
+                killEvent(e);
+            }));
+
+            this.focusser.on("focus", this.bind(function(){
+                if (!this.container.hasClass("select2-container-active")) {
+                    this.opts.element.trigger($.Event("select2-focus"));
+                }
+                this.container.addClass("select2-container-active");
+            })).on("blur", this.bind(function() {
+                if (!this.opened()) {
+                    this.container.removeClass("select2-container-active");
+                    this.opts.element.trigger($.Event("select2-blur"));
+                }
+            }));
+            this.search.on("focus", this.bind(function(){
+                if (!this.container.hasClass("select2-container-active")) {
+                    this.opts.element.trigger($.Event("select2-focus"));
+                }
+                this.container.addClass("select2-container-active");
+            }));
+
+            this.initContainerWidth();
+            this.opts.element.hide();
+            this.setPlaceholder();
+
+        },
+
+        // single
+        clear: function(triggerChange) {
+            var data=this.selection.data("select2-data");
+            if (data) { // guard against queued quick consecutive clicks
+                var evt = $.Event("select2-clearing");
+                this.opts.element.trigger(evt);
+                if (evt.isDefaultPrevented()) {
+                    return;
+                }
+                var placeholderOption = this.getPlaceholderOption();
+                this.opts.element.val(placeholderOption ? placeholderOption.val() : "");
+                this.selection.find(".select2-chosen").empty();
+                this.selection.removeData("select2-data");
+                this.setPlaceholder();
+
+                if (triggerChange !== false){
+                    this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
+                    this.triggerChange({removed:data});
+                }
+            }
+        },
+
+        /**
+         * Sets selection based on source element's value
+         */
+        // single
+        initSelection: function () {
+            var selected;
+            if (this.isPlaceholderOptionSelected()) {
+                this.updateSelection(null);
+                this.close();
+                this.setPlaceholder();
+            } else {
+                var self = this;
+                this.opts.initSelection.call(null, this.opts.element, function(selected){
+                    if (selected !== undefined && selected !== null) {
+                        self.updateSelection(selected);
+                        self.close();
+                        self.setPlaceholder();
+                        self.lastSearchTerm = self.search.val();
+                    }
+                });
+            }
+        },
+
+        isPlaceholderOptionSelected: function() {
+            var placeholderOption;
+            if (this.getPlaceholder() === undefined) return false; // no placeholder specified so no option should be considered
+            return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.prop("selected"))
+                || (this.opts.element.val() === "")
+                || (this.opts.element.val() === undefined)
+                || (this.opts.element.val() === null);
+        },
+
+        // single
+        prepareOpts: function () {
+            var opts = this.parent.prepareOpts.apply(this, arguments),
+                self=this;
+
+            if (opts.element.get(0).tagName.toLowerCase() === "select") {
+                // install the selection initializer
+                opts.initSelection = function (element, callback) {
+                    var selected = element.find("option").filter(function() { return this.selected && !this.disabled });
+                    // a single select box always has a value, no need to null check 'selected'
+                    callback(self.optionToData(selected));
+                };
+            } else if ("data" in opts) {
+                // install default initSelection when applied to hidden input and data is local
+                opts.initSelection = opts.initSelection || function (element, callback) {
+                    var id = element.val();
+                    //search in data by id, storing the actual matching item
+                    var match = null;
+                    opts.query({
+                        matcher: function(term, text, el){
+                            var is_match = equal(id, opts.id(el));
+                            if (is_match) {
+                                match = el;
+                            }
+                            return is_match;
+                        },
+                        callback: !$.isFunction(callback) ? $.noop : function() {
+                            callback(match);
+                        }
+                    });
+                };
+            }
+
+            return opts;
+        },
+
+        // single
+        getPlaceholder: function() {
+            // if a placeholder is specified on a single select without a valid placeholder option ignore it
+            if (this.select) {
+                if (this.getPlaceholderOption() === undefined) {
+                    return undefined;
+                }
+            }
+
+            return this.parent.getPlaceholder.apply(this, arguments);
+        },
+
+        // single
+        setPlaceholder: function () {
+            var placeholder = this.getPlaceholder();
+
+            if (this.isPlaceholderOptionSelected() && placeholder !== undefined) {
+
+                // check for a placeholder option if attached to a select
+                if (this.select && this.getPlaceholderOption() === undefined) return;
+
+                this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(placeholder));
+
+                this.selection.addClass("select2-default");
+
+                this.container.removeClass("select2-allowclear");
+            }
+        },
+
+        // single
+        postprocessResults: function (data, initial, noHighlightUpdate) {
+            var selected = 0, self = this, showSearchInput = true;
+
+            // find the selected element in the result list
+
+            this.findHighlightableChoices().each2(function (i, elm) {
+                if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
+                    selected = i;
+                    return false;
+                }
+            });
+
+            // and highlight it
+            if (noHighlightUpdate !== false) {
+                if (initial === true && selected >= 0) {
+                    this.highlight(selected);
+                } else {
+                    this.highlight(0);
+                }
+            }
+
+            // hide the search box if this is the first we got the results and there are enough of them for search
+
+            if (initial === true) {
+                var min = this.opts.minimumResultsForSearch;
+                if (min >= 0) {
+                    this.showSearch(countResults(data.results) >= min);
+                }
+            }
+        },
+
+        // single
+        showSearch: function(showSearchInput) {
+            if (this.showSearchInput === showSearchInput) return;
+
+            this.showSearchInput = showSearchInput;
+
+            this.dropdown.find(".select2-search").toggleClass("select2-search-hidden", !showSearchInput);
+            this.dropdown.find(".select2-search").toggleClass("select2-offscreen", !showSearchInput);
+            //add "select2-with-searchbox" to the container if search box is shown
+            $(this.dropdown, this.container).toggleClass("select2-with-searchbox", showSearchInput);
+        },
+
+        // single
+        onSelect: function (data, options) {
+
+            if (!this.triggerSelect(data)) { return; }
+
+            var old = this.opts.element.val(),
+                oldData = this.data();
+
+            this.opts.element.val(this.id(data));
+            this.updateSelection(data);
+
+            this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });
+
+            this.lastSearchTerm = this.search.val();
+            this.close();
+
+            if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) {
+                this.focusser.focus();
+            }
+
+            if (!equal(old, this.id(data))) {
+                this.triggerChange({ added: data, removed: oldData });
+            }
+        },
+
+        // single
+        updateSelection: function (data) {
+
+            var container=this.selection.find(".select2-chosen"), formatted, cssClass;
+
+            this.selection.data("select2-data", data);
+
+            container.empty();
+            if (data !== null) {
+                formatted=this.opts.formatSelection(data, container, this.opts.escapeMarkup);
+            }
+            if (formatted !== undefined) {
+                container.append(formatted);
+            }
+            cssClass=this.opts.formatSelectionCssClass(data, container);
+            if (cssClass !== undefined) {
+                container.addClass(cssClass);
+            }
+
+            this.selection.removeClass("select2-default");
+
+            if (this.opts.allowClear && this.getPlaceholder() !== undefined) {
+                this.container.addClass("select2-allowclear");
+            }
+        },
+
+        // single
+        val: function () {
+            var val,
+                triggerChange = false,
+                data = null,
+                self = this,
+                oldData = this.data();
+
+            if (arguments.length === 0) {
+                return this.opts.element.val();
+            }
+
+            val = arguments[0];
+
+            if (arguments.length > 1) {
+                triggerChange = arguments[1];
+
+                if (this.opts.debug && console && console.warn) {
+                    console.warn(
+                        'Select2: The second option to `select2("val")` is not supported in Select2 4.0.0. ' +
+                        'The `change` event will always be triggered in 4.0.0.'
+                    );
+                }
+            }
+
+            if (this.select) {
+                if (this.opts.debug && console && console.warn) {
+                    console.warn(
+                        'Select2: Setting the value on a <select> using `select2("val")` is no longer supported in 4.0.0. ' +
+                        'You can use the `.val(newValue).trigger("change")` method provided by jQuery instead.'
+                    );
+                }
+
+                this.select
+                    .val(val)
+                    .find("option").filter(function() { return this.selected }).each2(function (i, elm) {
+                        data = self.optionToData(elm);
+                        return false;
+                    });
+                this.updateSelection(data);
+                this.setPlaceholder();
+                if (triggerChange) {
+                    this.triggerChange({added: data, removed:oldData});
+                }
+            } else {
+                // val is an id. !val is true for [undefined,null,'',0] - 0 is legal
+                if (!val && val !== 0) {
+                    this.clear(triggerChange);
+                    return;
+                }
+                if (this.opts.initSelection === undefined) {
+                    throw new Error("cannot call val() if initSelection() is not defined");
+                }
+                this.opts.element.val(val);
+                this.opts.initSelection(this.opts.element, function(data){
+                    self.opts.element.val(!data ? "" : self.id(data));
+                    self.updateSelection(data);
+                    self.setPlaceholder();
+                    if (triggerChange) {
+                        self.triggerChange({added: data, removed:oldData});
+                    }
+                });
+            }
+        },
+
+        // single
+        clearSearch: function () {
+            this.search.val("");
+            this.focusser.val("");
+        },
+
+        // single
+        data: function(value) {
+            var data,
+                triggerChange = false;
+
+            if (arguments.length === 0) {
+                data = this.selection.data("select2-data");
+                if (data == undefined) data = null;
+                return data;
+            } else {
+                if (this.opts.debug && console && console.warn) {
+                    console.warn(
+                        'Select2: The `select2("data")` method can no longer set selected values in 4.0.0, ' +
+                        'consider using the `.val()` method instead.'
+                    );
+                }
+
+                if (arguments.length > 1) {
+                    triggerChange = arguments[1];
+                }
+                if (!value) {
+                    this.clear(triggerChange);
+                } else {
+                    data = this.data();
+                    this.opts.element.val(!value ? "" : this.id(value));
+                    this.updateSelection(value);
+                    if (triggerChange) {
+                        this.triggerChange({added: value, removed:data});
+                    }
+                }
+            }
+        }
+    });
+
+    MultiSelect2 = clazz(AbstractSelect2, {
+
+        // multi
+        createContainer: function () {
+            var container = $(document.createElement("div")).attr({
+                "class": "select2-container select2-container-multi"
+            }).html([
+                "<ul class='select2-choices'>",
+                "  <li class='select2-search-field'>",
+                "    <label for='' class='select2-offscreen'></label>",
+                "    <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>",
+                "  </li>",
+                "</ul>",
+                "<div class='select2-drop select2-drop-multi select2-display-none'>",
+                "   <ul class='select2-results'>",
+                "   </ul>",
+                "</div>"].join(""));
+            return container;
+        },
+
+        // multi
+        prepareOpts: function () {
+            var opts = this.parent.prepareOpts.apply(this, arguments),
+                self=this;
+
+            // TODO validate placeholder is a string if specified
+            if (opts.element.get(0).tagName.toLowerCase() === "select") {
+                // install the selection initializer
+                opts.initSelection = function (element, callback) {
+
+                    var data = [];
+
+                    element.find("option").filter(function() { return this.selected && !this.disabled }).each2(function (i, elm) {
+                        data.push(self.optionToData(elm));
+                    });
+                    callback(data);
+                };
+            } else if ("data" in opts) {
+                // install default initSelection when applied to hidden input and data is local
+                opts.initSelection = opts.initSelection || function (element, callback) {
+                    var ids = splitVal(element.val(), opts.separator, opts.transformVal);
+                    //search in data by array of ids, storing matching items in a list
+                    var matches = [];
+                    opts.query({
+                        matcher: function(term, text, el){
+                            var is_match = $.grep(ids, function(id) {
+                                return equal(id, opts.id(el));
+                            }).length;
+                            if (is_match) {
+                                matches.push(el);
+                            }
+                            return is_match;
+                        },
+                        callback: !$.isFunction(callback) ? $.noop : function() {
+                            // reorder matches based on the order they appear in the ids array because right now
+                            // they are in the order in which they appear in data array
+                            var ordered = [];
+                            for (var i = 0; i < ids.length; i++) {
+                                var id = ids[i];
+                                for (var j = 0; j < matches.length; j++) {
+                                    var match = matches[j];
+                                    if (equal(id, opts.id(match))) {
+                                        ordered.push(match);
+                                        matches.splice(j, 1);
+                                        break;
+                                    }
+                                }
+                            }
+                            callback(ordered);
+                        }
+                    });
+                };
+            }
+
+            return opts;
+        },
+
+        // multi
+        selectChoice: function (choice) {
+
+            var selected = this.container.find(".select2-search-choice-focus");
+            if (selected.length && choice && choice[0] == selected[0]) {
+
+            } else {
+                if (selected.length) {
+                    this.opts.element.trigger("choice-deselected", selected);
+                }
+                selected.removeClass("select2-search-choice-focus");
+                if (choice && choice.length) {
+                    this.close();
+                    choice.addClass("select2-search-choice-focus");
+                    this.opts.element.trigger("choice-selected", choice);
+                }
+            }
+        },
+
+        // multi
+        destroy: function() {
+            $("label[for='" + this.search.attr('id') + "']")
+                .attr('for', this.opts.element.attr("id"));
+            this.parent.destroy.apply(this, arguments);
+
+            cleanupJQueryElements.call(this,
+                "searchContainer",
+                "selection"
+            );
+        },
+
+        // multi
+        initContainer: function () {
+
+            var selector = ".select2-choices", selection;
+
+            this.searchContainer = this.container.find(".select2-search-field");
+            this.selection = selection = this.container.find(selector);
+
+            var _this = this;
+            this.selection.on("click", ".select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)", function (e) {
+                _this.search[0].focus();
+                _this.selectChoice($(this));
+            });
+
+            // rewrite labels from original element to focusser
+            this.search.attr("id", "s2id_autogen"+nextUid());
+
+            this.search.prev()
+                .text($("label[for='" + this.opts.element.attr("id") + "']").text())
+                .attr('for', this.search.attr('id'));
+            this.opts.element.on('focus.select2', this.bind(function () { this.focus(); }));
+
+            this.search.on("input paste", this.bind(function() {
+                if (this.search.attr('placeholder') && this.search.val().length == 0) return;
+                if (!this.isInterfaceEnabled()) return;
+                if (!this.opened()) {
+                    this.open();
+                }
+            }));
+
+            this.search.attr("tabindex", this.elementTabIndex);
+
+            this.keydowns = 0;
+            this.search.on("keydown", this.bind(function (e) {
+                if (!this.isInterfaceEnabled()) return;
+
+                ++this.keydowns;
+                var selected = selection.find(".select2-search-choice-focus");
+                var prev = selected.prev(".select2-search-choice:not(.select2-locked)");
+                var next = selected.next(".select2-search-choice:not(.select2-locked)");
+                var pos = getCursorInfo(this.search);
+
+                if (selected.length &&
+                    (e.which == KEY.LEFT || e.which == KEY.RIGHT || e.which == KEY.BACKSPACE || e.which == KEY.DELETE || e.which == KEY.ENTER)) {
+                    var selectedChoice = selected;
+                    if (e.which == KEY.LEFT && prev.length) {
+                        selectedChoice = prev;
+                    }
+                    else if (e.which == KEY.RIGHT) {
+                        selectedChoice = next.length ? next : null;
+                    }
+                    else if (e.which === KEY.BACKSPACE) {
+                        if (this.unselect(selected.first())) {
+                            this.search.width(10);
+                            selectedChoice = prev.length ? prev : next;
+                        }
+                    } else if (e.which == KEY.DELETE) {
+                        if (this.unselect(selected.first())) {
+                            this.search.width(10);
+                            selectedChoice = next.length ? next : null;
+                        }
+                    } else if (e.which == KEY.ENTER) {
+                        selectedChoice = null;
+                    }
+
+                    this.selectChoice(selectedChoice);
+                    killEvent(e);
+                    if (!selectedChoice || !selectedChoice.length) {
+                        this.open();
+                    }
+                    return;
+                } else if (((e.which === KEY.BACKSPACE && this.keydowns == 1)
+                    || e.which == KEY.LEFT) && (pos.offset == 0 && !pos.length)) {
+
+                    this.selectChoice(selection.find(".select2-search-choice:not(.select2-locked)").last());
+                    killEvent(e);
+                    return;
+                } else {
+                    this.selectChoice(null);
+                }
+
+                if (this.opened()) {
+                    switch (e.which) {
+                    case KEY.UP:
+                    case KEY.DOWN:
+                        this.moveHighlight((e.which === KEY.UP) ? -1 : 1);
+                        killEvent(e);
+                        return;
+                    case KEY.ENTER:
+                        this.selectHighlighted();
+                        killEvent(e);
+                        return;
+                    case KEY.TAB:
+                        this.selectHighlighted({noFocus:true});
+                        this.close();
+                        return;
+                    case KEY.ESC:
+                        this.cancel(e);
+                        killEvent(e);
+                        return;
+                    }
+                }
+
+                if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e)
+                 || e.which === KEY.BACKSPACE || e.which === KEY.ESC) {
+                    return;
+                }
+
+                if (e.which === KEY.ENTER) {
+                    if (this.opts.openOnEnter === false) {
+                        return;
+                    } else if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
+                        return;
+                    }
+                }
+
+                this.open();
+
+                if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) {
+                    // prevent the page from scrolling
+                    killEvent(e);
+                }
+
+                if (e.which === KEY.ENTER) {
+                    // prevent form from being submitted
+                    killEvent(e);
+                }
+
+            }));
+
+            this.search.on("keyup", this.bind(function (e) {
+                this.keydowns = 0;
+                this.resizeSearch();
+            })
+            );
+
+            this.search.on("blur", this.bind(function(e) {
+                this.container.removeClass("select2-container-active");
+                this.search.removeClass("select2-focused");
+                this.selectChoice(null);
+                if (!this.opened()) this.clearSearch();
+                e.stopImmediatePropagation();
+                this.opts.element.trigger($.Event("select2-blur"));
+            }));
+
+            this.container.on("click", selector, this.bind(function (e) {
+                if (!this.isInterfaceEnabled()) return;
+                if ($(e.target).closest(".select2-search-choice").length > 0) {
+                    // clicked inside a select2 search choice, do not open
+                    return;
+                }
+                this.selectChoice(null);
+                this.clearPlaceholder();
+                if (!this.container.hasClass("select2-container-active")) {
+                    this.opts.element.trigger($.Event("select2-focus"));
+                }
+                this.open();
+                this.focusSearch();
+                e.preventDefault();
+            }));
+
+            this.container.on("focus", selector, this.bind(function () {
+                if (!this.isInterfaceEnabled()) return;
+                if (!this.container.hasClass("select2-container-active")) {
+                    this.opts.element.trigger($.Event("select2-focus"));
+                }
+                this.container.addClass("select2-container-active");
+                this.dropdown.addClass("select2-drop-active");
+                this.clearPlaceholder();
+            }));
+
+            this.initContainerWidth();
+            this.opts.element.hide();
+
+            // set the placeholder if necessary
+            this.clearSearch();
+        },
+
+        // multi
+        enableInterface: function() {
+            if (this.parent.enableInterface.apply(this, arguments)) {
+                this.search.prop("disabled", !this.isInterfaceEnabled());
+            }
+        },
+
+        // multi
+        initSelection: function () {
+            var data;
+            if (this.opts.element.val() === "" && this.opts.element.text() === "") {
+                this.updateSelection([]);
+                this.close();
+                // set the placeholder if necessary
+                this.clearSearch();
+            }
+            if (this.select || this.opts.element.val() !== "") {
+                var self = this;
+                this.opts.initSelection.call(null, this.opts.element, function(data){
+                    if (data !== undefined && data !== null) {
+                        self.updateSelection(data);
+                        self.close();
+                        // set the placeholder if necessary
+                        self.clearSearch();
+                    }
+                });
+            }
+        },
+
+        // multi
+        clearSearch: function () {
+            var placeholder = this.getPlaceholder(),
+                maxWidth = this.getMaxSearchWidth();
+
+            if (placeholder !== undefined  && this.getVal().length === 0 && this.search.hasClass("select2-focused") === false) {
+                this.search.val(placeholder).addClass("select2-default");
+                // stretch the search box to full width of the container so as much of the placeholder is visible as possible
+                // we could call this.resizeSearch(), but we do not because that requires a sizer and we do not want to create one so early because of a firefox bug, see #944
+                this.search.width(maxWidth > 0 ? maxWidth : this.container.css("width"));
+            } else {
+                this.search.val("").width(10);
+            }
+        },
+
+        // multi
+        clearPlaceholder: function () {
+            if (this.search.hasClass("select2-default")) {
+                this.search.val("").removeClass("select2-default");
+            }
+        },
+
+        // multi
+        opening: function () {
+            this.clearPlaceholder(); // should be done before super so placeholder is not used to search
+            this.resizeSearch();
+
+            this.parent.opening.apply(this, arguments);
+
+            this.focusSearch();
+
+            this.prefillNextSearchTerm();
+            this.updateResults(true);
+
+            if (this.opts.shouldFocusInput(this)) {
+                this.search.focus();
+            }
+            this.opts.element.trigger($.Event("select2-open"));
+        },
+
+        // multi
+        close: function () {
+            if (!this.opened()) return;
+            this.parent.close.apply(this, arguments);
+        },
+
+        // multi
+        focus: function () {
+            this.close();
+            this.search.focus();
+        },
+
+        // multi
+        isFocused: function () {
+            return this.search.hasClass("select2-focused");
+        },
+
+        // multi
+        updateSelection: function (data) {
+            var ids = {}, filtered = [], self = this;
+
+            // filter out duplicates
+            $(data).each(function () {
+                if (!(self.id(this) in ids)) {
+                    ids[self.id(this)] = 0;
+                    filtered.push(this);
+                }
+            });
+
+            this.selection.find(".select2-search-choice").remove();
+            this.addSelectedChoice(filtered);
+            self.postprocessResults();
+        },
+
+        // multi
+        tokenize: function() {
+            var input = this.search.val();
+            input = this.opts.tokenizer.call(this, input, this.data(), this.bind(this.onSelect), this.opts);
+            if (input != null && input != undefined) {
+                this.search.val(input);
+                if (input.length > 0) {
+                    this.open();
+                }
+            }
+
+        },
+
+        // multi
+        onSelect: function (data, options) {
+
+            if (!this.triggerSelect(data) || data.text === "") { return; }
+
+            this.addSelectedChoice(data);
+
+            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
+
+            // keep track of the search's value before it gets cleared
+            this.lastSearchTerm = this.search.val();
+
+            this.clearSearch();
+            this.updateResults();
+
+            if (this.select || !this.opts.closeOnSelect) this.postprocessResults(data, false, this.opts.closeOnSelect===true);
+
+            if (this.opts.closeOnSelect) {
+                this.close();
+                this.search.width(10);
+            } else {
+                if (this.countSelectableResults()>0) {
+                    this.search.width(10);
+                    this.resizeSearch();
+                    if (this.getMaximumSelectionSize() > 0 && this.val().length >= this.getMaximumSelectionSize()) {
+                        // if we reached max selection size repaint the results so choices
+                        // are replaced with the max selection reached message
+                        this.updateResults(true);
+                    } else {
+                        // initializes search's value with nextSearchTerm and update search result
+                        if (this.prefillNextSearchTerm()) {
+                            this.updateResults();
+                        }
+                    }
+                    this.positionDropdown();
+                } else {
+                    // if nothing left to select close
+                    this.close();
+                    this.search.width(10);
+                }
+            }
+
+            // since its not possible to select an element that has already been
+            // added we do not need to check if this is a new element before firing change
+            this.triggerChange({ added: data });
+
+            if (!options || !options.noFocus)
+                this.focusSearch();
+        },
+
+        // multi
+        cancel: function () {
+            this.close();
+            this.focusSearch();
+        },
+
+        addSelectedChoice: function (data) {
+            var val = this.getVal(), self = this;
+            $(data).each(function () {
+                val.push(self.createChoice(this));
+            });
+            this.setVal(val);
+        },
+
+        createChoice: function (data) {
+            var enableChoice = !data.locked,
+                enabledItem = $(
+                    "<li class='select2-search-choice'>" +
+                    "    <div></div>" +
+                    "    <a href='#' class='select2-search-choice-close' tabindex='-1'></a>" +
+                    "</li>"),
+                disabledItem = $(
+                    "<li class='select2-search-choice select2-locked'>" +
+                    "<div></div>" +
+                    "</li>");
+            var choice = enableChoice ? enabledItem : disabledItem,
+                id = this.id(data),
+                formatted,
+                cssClass;
+
+            formatted=this.opts.formatSelection(data, choice.find("div"), this.opts.escapeMarkup);
+            if (formatted != undefined) {
+                choice.find("div").replaceWith($("<div></div>").html(formatted));
+            }
+            cssClass=this.opts.formatSelectionCssClass(data, choice.find("div"));
+            if (cssClass != undefined) {
+                choice.addClass(cssClass);
+            }
+
+            if(enableChoice){
+              choice.find(".select2-search-choice-close")
+                  .on("mousedown", killEvent)
+                  .on("click dblclick", this.bind(function (e) {
+                  if (!this.isInterfaceEnabled()) return;
+
+                  this.unselect($(e.target));
+                  this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
+                  killEvent(e);
+                  this.close();
+                  this.focusSearch();
+              })).on("focus", this.bind(function () {
+                  if (!this.isInterfaceEnabled()) return;
+                  this.container.addClass("select2-container-active");
+                  this.dropdown.addClass("select2-drop-active");
+              }));
+            }
+
+            choice.data("select2-data", data);
+            choice.insertBefore(this.searchContainer);
+
+            return id;
+        },
+
+        // multi
+        unselect: function (selected) {
+            var val = this.getVal(),
+                data,
+                index;
+            selected = selected.closest(".select2-search-choice");
+
+            if (selected.length === 0) {
+                throw "Invalid argument: " + selected + ". Must be .select2-search-choice";
+            }
+
+            data = selected.data("select2-data");
+
+            if (!data) {
+                // prevent a race condition when the 'x' is clicked really fast repeatedly the event can be queued
+                // and invoked on an element already removed
+                return;
+            }
+
+            var evt = $.Event("select2-removing");
+            evt.val = this.id(data);
+            evt.choice = data;
+            this.opts.element.trigger(evt);
+
+            if (evt.isDefaultPrevented()) {
+                return false;
+            }
+
+            while((index = indexOf(this.id(data), val)) >= 0) {
+                val.splice(index, 1);
+                this.setVal(val);
+                if (this.select) this.postprocessResults();
+            }
+
+            selected.remove();
+
+            this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
+            this.triggerChange({ removed: data });
+
+            return true;
+        },
+
+        // multi
+        postprocessResults: function (data, initial, noHighlightUpdate) {
+            var val = this.getVal(),
+                choices = this.results.find(".select2-result"),
+                compound = this.results.find(".select2-result-with-children"),
+                self = this;
+
+            choices.each2(function (i, choice) {
+                var id = self.id(choice.data("select2-data"));
+                if (indexOf(id, val) >= 0) {
+                    choice.addClass("select2-selected");
+                    // mark all children of the selected parent as selected
+                    choice.find(".select2-result-selectable").addClass("select2-selected");
+                }
+            });
+
+            compound.each2(function(i, choice) {
+                // hide an optgroup if it doesn't have any selectable children
+                if (!choice.is('.select2-result-selectable')
+                    && choice.find(".select2-result-selectable:not(.select2-selected)").length === 0) {
+                    choice.addClass("select2-selected");
+                }
+            });
+
+            if (this.highlight() == -1 && noHighlightUpdate !== false && this.opts.closeOnSelect === true){
+                self.highlight(0);
+            }
+
+            //If all results are chosen render formatNoMatches
+            if(!this.opts.createSearchChoice && !choices.filter('.select2-result:not(.select2-selected)').length > 0){
+                if(!data || data && !data.more && this.results.find(".select2-no-results").length === 0) {
+                    if (checkFormatter(self.opts.formatNoMatches, "formatNoMatches")) {
+                        this.results.append("<li class='select2-no-results'>" + evaluate(self.opts.formatNoMatches, self.opts.element, self.search.val()) + "</li>");
+                    }
+                }
+            }
+
+        },
+
+        // multi
+        getMaxSearchWidth: function() {
+            return this.selection.width() - getSideBorderPadding(this.search);
+        },
+
+        // multi
+        resizeSearch: function () {
+            var minimumWidth, left, maxWidth, containerLeft, searchWidth,
+                sideBorderPadding = getSideBorderPadding(this.search);
+
+            minimumWidth = measureTextWidth(this.search) + 10;
+
+            left = this.search.offset().left;
+
+            maxWidth = this.selection.width();
+            containerLeft = this.selection.offset().left;
+
+            searchWidth = maxWidth - (left - containerLeft) - sideBorderPadding;
+
+            if (searchWidth < minimumWidth) {
+                searchWidth = maxWidth - sideBorderPadding;
+            }
+
+            if (searchWidth < 40) {
+                searchWidth = maxWidth - sideBorderPadding;
+            }
+
+            if (searchWidth <= 0) {
+              searchWidth = minimumWidth;
+            }
+
+            this.search.width(Math.floor(searchWidth));
+        },
+
+        // multi
+        getVal: function () {
+            var val;
+            if (this.select) {
+                val = this.select.val();
+                return val === null ? [] : val;
+            } else {
+                val = this.opts.element.val();
+                return splitVal(val, this.opts.separator, this.opts.transformVal);
+            }
+        },
+
+        // multi
+        setVal: function (val) {
+            if (this.select) {
+                this.select.val(val);
+            } else {
+                var unique = [], valMap = {};
+                // filter out duplicates
+                $(val).each(function () {
+                    if (!(this in valMap)) {
+                        unique.push(this);
+                        valMap[this] = 0;
+                    }
+                });
+                this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator));
+            }
+        },
+
+        // multi
+        buildChangeDetails: function (old, current) {
+            var current = current.slice(0),
+                old = old.slice(0);
+
+            // remove intersection from each array
+            for (var i = 0; i < current.length; i++) {
+                for (var j = 0; j < old.length; j++) {
+                    if (equal(this.opts.id(current[i]), this.opts.id(old[j]))) {
+                        current.splice(i, 1);
+                        i--;
+                        old.splice(j, 1);
+                        break;
+                    }
+                }
+            }
+
+            return {added: current, removed: old};
+        },
+
+
+        // multi
+        val: function (val, triggerChange) {
+            var oldData, self=this;
+
+            if (arguments.length === 0) {
+                return this.getVal();
+            }
+
+            oldData=this.data();
+            if (!oldData.length) oldData=[];
+
+            // val is an id. !val is true for [undefined,null,'',0] - 0 is legal
+            if (!val && val !== 0) {
+                this.opts.element.val("");
+                this.updateSelection([]);
+                this.clearSearch();
+                if (triggerChange) {
+                    this.triggerChange({added: this.data(), removed: oldData});
+                }
+                return;
+            }
+
+            // val is a list of ids
+            this.setVal(val);
+
+            if (this.select) {
+                this.opts.initSelection(this.select, this.bind(this.updateSelection));
+                if (triggerChange) {
+                    this.triggerChange(this.buildChangeDetails(oldData, this.data()));
+                }
+            } else {
+                if (this.opts.initSelection === undefined) {
+                    throw new Error("val() cannot be called if initSelection() is not defined");
+                }
+
+                this.opts.initSelection(this.opts.element, function(data){
+                    var ids=$.map(data, self.id);
+                    self.setVal(ids);
+                    self.updateSelection(data);
+                    self.clearSearch();
+                    if (triggerChange) {
+                        self.triggerChange(self.buildChangeDetails(oldData, self.data()));
+                    }
+                });
+            }
+            this.clearSearch();
+        },
+
+        // multi
+        onSortStart: function() {
+            if (this.select) {
+                throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");
+            }
+
+            // collapse search field into 0 width so its container can be collapsed as well
+            this.search.width(0);
+            // hide the container
+            this.searchContainer.hide();
+        },
+
+        // multi
+        onSortEnd:function() {
+
+            var val=[], self=this;
+
+            // show search and move it to the end of the list
+            this.searchContainer.show();
+            // make sure the search container is the last item in the list
+            this.searchContainer.appendTo(this.searchContainer.parent());
+            // since we collapsed the width in dragStarted, we resize it here
+            this.resizeSearch();
+
+            // update selection
+            this.selection.find(".select2-search-choice").each(function() {
+                val.push(self.opts.id($(this).data("select2-data")));
+            });
+            this.setVal(val);
+            this.triggerChange();
+        },
+
+        // multi
+        data: function(values, triggerChange) {
+            var self=this, ids, old;
+            if (arguments.length === 0) {
+                 return this.selection
+                     .children(".select2-search-choice")
+                     .map(function() { return $(this).data("select2-data"); })
+                     .get();
+            } else {
+                old = this.data();
+                if (!values) { values = []; }
+                ids = $.map(values, function(e) { return self.opts.id(e); });
+                this.setVal(ids);
+                this.updateSelection(values);
+                this.clearSearch();
+                if (triggerChange) {
+                    this.triggerChange(this.buildChangeDetails(old, this.data()));
+                }
+            }
+        }
+    });
+
+    $.fn.select2 = function () {
+
+        var args = Array.prototype.slice.call(arguments, 0),
+            opts,
+            select2,
+            method, value, multiple,
+            allowedMethods = ["val", "destroy", "opened", "open", "close", "focus", "isFocused", "container", "dropdown", "onSortStart", "onSortEnd", "enable", "disable", "readonly", "positionDropdown", "data", "search"],
+            valueMethods = ["opened", "isFocused", "container", "dropdown"],
+            propertyMethods = ["val", "data"],
+            methodsMap = { search: "externalSearch" };
+
+        this.each(function () {
+            if (args.length === 0 || typeof(args[0]) === "object") {
+                opts = args.length === 0 ? {} : $.extend({}, args[0]);
+                opts.element = $(this);
+
+                if (opts.element.get(0).tagName.toLowerCase() === "select") {
+                    multiple = opts.element.prop("multiple");
+                } else {
+                    multiple = opts.multiple || false;
+                    if ("tags" in opts) {opts.multiple = multiple = true;}
+                }
+
+                select2 = multiple ? new window.Select2["class"].multi() : new window.Select2["class"].single();
+                select2.init(opts);
+            } else if (typeof(args[0]) === "string") {
+
+                if (indexOf(args[0], allowedMethods) < 0) {
+                    throw "Unknown method: " + args[0];
+                }
+
+                value = undefined;
+                select2 = $(this).data("select2");
+                if (select2 === undefined) return;
+
+                method=args[0];
+
+                if (method === "container") {
+                    value = select2.container;
+                } else if (method === "dropdown") {
+                    value = select2.dropdown;
+                } else {
+                    if (methodsMap[method]) method = methodsMap[method];
+
+                    value = select2[method].apply(select2, args.slice(1));
+                }
+                if (indexOf(args[0], valueMethods) >= 0
+                    || (indexOf(args[0], propertyMethods) >= 0 && args.length == 1)) {
+                    return false; // abort the iteration, ready to return first matched value
+                }
+            } else {
+                throw "Invalid arguments to select2 plugin: " + args;
+            }
+        });
+        return (value === undefined) ? this : value;
+    };
+
+    // plugin defaults, accessible to users
+    $.fn.select2.defaults = {
+        debug: false,
+        width: "copy",
+        loadMorePadding: 0,
+        closeOnSelect: true,
+        openOnEnter: true,
+        containerCss: {},
+        dropdownCss: {},
+        containerCssClass: "",
+        dropdownCssClass: "",
+        formatResult: function(result, container, query, escapeMarkup) {
+            var markup=[];
+            markMatch(this.text(result), query.term, markup, escapeMarkup);
+            return markup.join("");
+        },
+        transformVal: function(val) {
+            return $.trim(val);
+        },
+        formatSelection: function (data, container, escapeMarkup) {
+            return data ? escapeMarkup(this.text(data)) : undefined;
+        },
+        sortResults: function (results, container, query) {
+            return results;
+        },
+        formatResultCssClass: function(data) {return data.css;},
+        formatSelectionCssClass: function(data, container) {return undefined;},
+        minimumResultsForSearch: 0,
+        minimumInputLength: 0,
+        maximumInputLength: null,
+        maximumSelectionSize: 0,
+        id: function (e) { return e == undefined ? null : e.id; },
+        text: function (e) {
+          if (e && this.data && this.data.text) {
+            if ($.isFunction(this.data.text)) {
+              return this.data.text(e);
+            } else {
+              return e[this.data.text];
+            }
+          } else {
+            return e.text;
+          }
+        },
+        matcher: function(term, text) {
+            return stripDiacritics(''+text).toUpperCase().indexOf(stripDiacritics(''+term).toUpperCase()) >= 0;
+        },
+        separator: ",",
+        tokenSeparators: [],
+        tokenizer: defaultTokenizer,
+        escapeMarkup: defaultEscapeMarkup,
+        blurOnChange: false,
+        selectOnBlur: false,
+        adaptContainerCssClass: function(c) { return c; },
+        adaptDropdownCssClass: function(c) { return null; },
+        nextSearchTerm: function(selectedObject, currentSearchTerm) { return undefined; },
+        searchInputPlaceholder: '',
+        createSearchChoicePosition: 'top',
+        shouldFocusInput: function (instance) {
+            // Attempt to detect touch devices
+            var supportsTouchEvents = (('ontouchstart' in window) ||
+                                       (navigator.msMaxTouchPoints > 0));
+
+            // Only devices which support touch events should be special cased
+            if (!supportsTouchEvents) {
+                return true;
+            }
+
+            // Never focus the input if search is disabled
+            if (instance.opts.minimumResultsForSearch < 0) {
+                return false;
+            }
+
+            return true;
+        }
+    };
+
+    $.fn.select2.locales = [];
+
+    $.fn.select2.locales['en'] = {
+         formatMatches: function (matches) { if (matches === 1) { return "One result is available, press enter to select it."; } return matches + " results are available, use up and down arrow keys to navigate."; },
+         formatNoMatches: function () { return "No matches found"; },
+         formatAjaxError: function (jqXHR, textStatus, errorThrown) { return "Loading failed"; },
+         formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1 ? "" : "s"); },
+         formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1 ? "" : "s"); },
+         formatSelectionTooBig: function (limit) { return "You can only select " + limit + " item" + (limit == 1 ? "" : "s"); },
+         formatLoadMore: function (pageNumber) { return "Loading more results…"; },
+         formatSearching: function () { return "Searching…"; }
+    };
+
+    $.extend($.fn.select2.defaults, $.fn.select2.locales['en']);
+
+    $.fn.select2.ajaxDefaults = {
+        transport: $.ajax,
+        params: {
+            type: "GET",
+            cache: false,
+            dataType: "json"
+        }
+    };
+
+    // exports
+    window.Select2 = {
+        query: {
+            ajax: ajax,
+            local: local,
+            tags: tags
+        }, util: {
+            debounce: debounce,
+            markMatch: markMatch,
+            escapeMarkup: defaultEscapeMarkup,
+            stripDiacritics: stripDiacritics
+        }, "class": {
+            "abstract": AbstractSelect2,
+            "single": SingleSelect2,
+            "multi": MultiSelect2
+        }
+    };
+
+}(jQuery));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/jquery-select2-3.5.4.min.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,1 @@
+!function(e){void 0===e.fn.each2&&e.extend(e.fn,{each2:function(t){for(var s=e([0]),i=-1,n=this.length;++i<n&&(s.context=s[0]=this[i])&&!1!==t.call(s[0],i,s););return this}})}(jQuery),function(e,t){"use strict";function s(t){var s=e(document.createTextNode(""));t.before(s),s.before(t),s.remove()}function i(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return j[e]||e})}function n(e,t){for(var s=0,i=t.length;s<i;s+=1)if(a(e,t[s]))return s;return-1}function o(){var t=e(U);t.appendTo(document.body);var s={width:t.width()-t[0].clientWidth,height:t.height()-t[0].clientHeight};return t.remove(),s}function a(e,s){return e===s||e!==t&&s!==t&&(null!==e&&null!==s&&(e.constructor===String?e+""==s+"":s.constructor===String&&s+""==e+""))}function l(e,t,s){var i,n,o;if(null===e||e.length<1)return[];for(n=0,o=(i=e.split(t)).length;n<o;n+=1)i[n]=s(i[n]);return i}function r(e){return e.outerWidth(!1)-e.width()}function c(s){var i="keyup-change-value";s.on("keydown",function(){e.data(s,i)===t&&e.data(s,i,s.val())}),s.on("keyup",function(){var n=e.data(s,i);n!==t&&s.val()!==n&&(e.removeData(s,i),s.trigger("keyup-change"))})}function h(s){s.on("mousemove",function(s){var i=N;i!==t&&i.x===s.pageX&&i.y===s.pageY||e(s.target).trigger("mousemove-filtered",s)})}function u(e,s,i){i=i||t;var n;return function(){var t=arguments;window.clearTimeout(n),n=window.setTimeout(function(){s.apply(i,t)},e)}}function d(e,t){var s=u(e,function(e){t.trigger("scroll-debounced",e)});t.on("scroll",function(e){n(e.target,t.get())>=0&&s(e)})}function p(e){e[0]!==document.activeElement&&window.setTimeout(function(){var t,s=e[0],i=e.val().length;e.focus(),(s.offsetWidth>0||s.offsetHeight>0)&&s===document.activeElement&&(s.setSelectionRange?s.setSelectionRange(i,i):s.createTextRange&&((t=s.createTextRange()).collapse(!1),t.select()))},0)}function f(t){var s=0,i=0;if("selectionStart"in(t=e(t)[0]))s=t.selectionStart,i=t.selectionEnd-s;else if("selection"in document){t.focus();var n=document.selection.createRange();i=document.selection.createRange().text.length,n.moveStart("character",-t.value.length),s=n.text.length-i}return{offset:s,length:i}}function g(e){e.preventDefault(),e.stopPropagation()}function m(e){e.preventDefault(),e.stopImmediatePropagation()}function v(t){if(!L){var s=t[0].currentStyle||window.getComputedStyle(t[0],null);(L=e(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:s.fontSize,fontFamily:s.fontFamily,fontStyle:s.fontStyle,fontWeight:s.fontWeight,letterSpacing:s.letterSpacing,textTransform:s.textTransform,whiteSpace:"nowrap"})).attr("class","select2-sizer"),e(document.body).append(L)}return L.text(t.val()),L.width()}function b(t,s,i){var n,o,a=[];(n=e.trim(t.attr("class")))&&e((n=""+n).split(/\s+/)).each2(function(){0===this.indexOf("select2-")&&a.push(this)}),(n=e.trim(s.attr("class")))&&e((n=""+n).split(/\s+/)).each2(function(){0!==this.indexOf("select2-")&&(o=i(this))&&a.push(o)}),t.attr("class",a.join(" "))}function w(e,t,s,n){var o=i(e.toUpperCase()).indexOf(i(t.toUpperCase())),a=t.length;o<0?s.push(n(e)):(s.push(n(e.substring(0,o))),s.push("<span class='select2-match'>"),s.push(n(e.substring(o,o+a))),s.push("</span>"),s.push(n(e.substring(o+a,e.length))))}function S(e){var t={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})}function C(s){var i,n=null,o=s.quietMillis||100,a=s.url,l=this;return function(r){window.clearTimeout(i),i=window.setTimeout(function(){var i=s.data,o=a,c=s.transport||e.fn.select2.ajaxDefaults.transport,h={type:s.type||"GET",cache:s.cache||!1,jsonpCallback:s.jsonpCallback||t,dataType:s.dataType||"json"},u=e.extend({},e.fn.select2.ajaxDefaults.params,h);i=i?i.call(l,r.term,r.page,r.context):null,o="function"==typeof o?o.call(l,r.term,r.page,r.context):o,n&&"function"==typeof n.abort&&n.abort(),s.params&&(e.isFunction(s.params)?e.extend(u,s.params.call(l)):e.extend(u,s.params)),e.extend(u,{url:o,dataType:s.dataType,data:i,success:function(e){var t=s.results(e,r.page,r);r.callback(t)},error:function(e,t,s){var i={hasError:!0,jqXHR:e,textStatus:t,errorThrown:s};r.callback(i)}}),n=c.call(l,u)},o)}}function y(t){var s,i,n=t,o=function(e){return""+e.text};e.isArray(n)&&(n={results:i=n}),!1===e.isFunction(n)&&(i=n,n=function(){return i});var a=n();return a.text&&(o=a.text,e.isFunction(o)||(s=a.text,o=function(e){return e[s]})),function(t){var s,i=t.term,a={results:[]};""!==i?(s=function(n,a){var l,r;if((n=n[0]).children){l={};for(r in n)n.hasOwnProperty(r)&&(l[r]=n[r]);l.children=[],e(n.children).each2(function(e,t){s(t,l.children)}),(l.children.length||t.matcher(i,o(l),n))&&a.push(l)}else t.matcher(i,o(n),n)&&a.push(n)},e(n().results).each2(function(e,t){s(t,a.results)}),t.callback(a)):t.callback(n())}}function x(s){var i=e.isFunction(s);return function(n){var o=n.term,a={results:[]},l=i?s(n):s;e.isArray(l)&&(e(l).each(function(){var e=this.text!==t,s=e?this.text:this;(""===o||n.matcher(o,s))&&a.results.push(e?this:{id:this,text:this})}),n.callback(a))}}function T(t,s){if(e.isFunction(t))return!0;if(!t)return!1;if("string"==typeof t)return!0;throw new Error(s+" must be a string, function, or falsy value")}function E(t,s){if(e.isFunction(t)){var i=Array.prototype.slice.call(arguments,2);return t.apply(s,i)}return t}function O(t){var s=0;return e.each(t,function(e,t){t.children?s+=O(t.children):s++}),s}function I(){var t=this;e.each(arguments,function(e,s){t[s].remove(),t[s]=null})}function P(t,s){var i=function(){};return i.prototype=new t,i.prototype.constructor=i,i.prototype.parent=t.prototype,i.prototype=e.extend(i.prototype,s),i}if(window.Select2===t){var k,R,A,D,L,M,H,N={x:0,y:0},F={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(e){switch(e=e.which?e.which:e){case F.LEFT:case F.RIGHT:case F.UP:case F.DOWN:return!0}return!1},isControl:function(e){switch(e.which){case F.SHIFT:case F.CTRL:case F.ALT:return!0}return!!e.metaKey},isFunctionKey:function(e){return(e=e.which?e.which:e)>=112&&e<=123}},U="<div class='select2-measure-scrollbar'></div>",j={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};M=e(document),D=function(){var e=1;return function(){return e++}}(),R=P(k=P(Object,{bind:function(e){var t=this;return function(){e.apply(t,arguments)}},init:function(s){var i,n;this.opts=s=this.prepareOpts(s),this.id=s.id,s.element.data("select2")!==t&&null!==s.element.data("select2")&&s.element.data("select2").destroy(),this.container=this.createContainer(),this.liveRegion=e(".select2-hidden-accessible"),0==this.liveRegion.length&&(this.liveRegion=e("<span>",{role:"status","aria-live":"polite"}).addClass("select2-hidden-accessible").appendTo(document.body)),this.containerId="s2id_"+(s.element.attr("id")||"autogen"+D()),this.containerEventName=this.containerId.replace(/([.])/g,"_").replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.container.attr("title",s.element.attr("title")),this.body=e(document.body),b(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",s.element.attr("style")),this.container.css(E(s.containerCss,this.opts.element)),this.container.addClass(E(s.containerCssClass,this.opts.element)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",g),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),b(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(E(s.dropdownCssClass,this.opts.element)),this.dropdown.data("select2",this),this.dropdown.on("click",g),this.results=i=this.container.find(".select2-results"),this.search=n=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",g),h(this.results),this.dropdown.on("mousemove-filtered",".select2-results",this.bind(this.highlightUnderEvent)),this.dropdown.on("touchstart touchmove touchend",".select2-results",this.bind(function(e){this._touchEvent=!0,this.highlightUnderEvent(e)})),this.dropdown.on("touchmove",".select2-results",this.bind(this.touchMoved)),this.dropdown.on("touchstart touchend",".select2-results",this.bind(this.clearTouchMoved)),this.dropdown.on("click",this.bind(function(e){this._touchEvent&&(this._touchEvent=!1,this.selectHighlighted())})),d(80,this.results),this.dropdown.on("scroll-debounced",".select2-results",this.bind(this.loadMoreIfNeeded)),e(this.container).on("change",".select2-input",function(e){e.stopPropagation()}),e(this.dropdown).on("change",".select2-input",function(e){e.stopPropagation()}),e.fn.mousewheel&&i.mousewheel(function(e,t,s,n){var o=i.scrollTop();n>0&&o-n<=0?(i.scrollTop(0),g(e)):n<0&&i.get(0).scrollHeight-i.scrollTop()+n<=i.height()&&(i.scrollTop(i.get(0).scrollHeight-i.height()),g(e))}),c(n),n.on("keyup-change input paste",this.bind(this.updateResults)),n.on("focus",function(){n.addClass("select2-focused")}),n.on("blur",function(){n.removeClass("select2-focused")}),this.dropdown.on("mouseup",".select2-results",this.bind(function(t){e(t.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(t),this.selectHighlighted(t))})),this.dropdown.on("click mouseup mousedown touchstart touchend focusin",function(e){e.stopPropagation()}),this.lastSearchTerm=t,e.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==s.maximumInputLength&&this.search.attr("maxlength",s.maximumInputLength);var a=s.element.prop("disabled");a===t&&(a=!1),this.enable(!a);var l=s.element.prop("readonly");l===t&&(l=!1),this.readonly(l),H=H||o(),this.autofocus=s.element.prop("autofocus"),s.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.search.attr("placeholder",s.searchInputPlaceholder)},destroy:function(){var e=this.opts.element,s=e.data("select2"),i=this;this.close(),e.length&&e[0].detachEvent&&i._sync&&e.each(function(){i._sync&&this.detachEvent("onpropertychange",i._sync)}),this.propertyObserver&&(this.propertyObserver.disconnect(),this.propertyObserver=null),this._sync=null,s!==t&&(s.container.remove(),s.liveRegion.remove(),s.dropdown.remove(),e.removeData("select2").off(".select2"),e.is("input[type='hidden']")?e.css("display",""):(e.show().prop("autofocus",this.autofocus||!1),this.elementTabIndex?e.attr({tabindex:this.elementTabIndex}):e.removeAttr("tabindex"),e.show())),I.call(this,"container","liveRegion","dropdown","results","search")},optionToData:function(e){return e.is("option")?{id:e.prop("value"),text:e.text(),element:e.get(),css:e.attr("class"),disabled:e.prop("disabled"),locked:a(e.attr("locked"),"locked")||a(e.data("locked"),!0)}:e.is("optgroup")?{text:e.attr("label"),children:[],element:e.get(),css:e.attr("class")}:void 0},prepareOpts:function(s){var i,n,o,r,c=this;if("select"===(i=s.element).get(0).tagName.toLowerCase()&&(this.select=n=s.element),n&&e.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in s)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),s.debug=s.debug||e.fn.select2.defaults.debug,s.debug&&console&&console.warn&&(null!=s.id&&console.warn("Select2: The `id` option has been removed in Select2 4.0.0, consider renaming your `id` property or mapping the property before your data makes it to Select2. You can read more at https://select2.github.io/announcements-4.0.html#changed-id"),null!=s.text&&console.warn("Select2: The `text` option has been removed in Select2 4.0.0, consider renaming your `text` property or mapping the property before your data makes it to Select2. You can read more at https://select2.github.io/announcements-4.0.html#changed-id"),null!=s.sortResults&&console.warn("Select2: the `sortResults` option has been renamed to `sorter` in Select2 4.0.0. "),null!=s.selectOnBlur&&console.warn("Select2: The `selectOnBlur` option has been renamed to `selectOnClose` in Select2 4.0.0."),null!=s.ajax&&null!=s.ajax.results&&console.warn("Select2: The `ajax.results` option has been renamed to `ajax.processResults` in Select2 4.0.0."),null!=s.formatNoResults&&console.warn("Select2: The `formatNoResults` option has been renamed to `language.noResults` in Select2 4.0.0."),null!=s.formatSearching&&console.warn("Select2: The `formatSearching` option has been renamed to `language.searching` in Select2 4.0.0."),null!=s.formatInputTooShort&&console.warn("Select2: The `formatInputTooShort` option has been renamed to `language.inputTooShort` in Select2 4.0.0."),null!=s.formatInputTooLong&&console.warn("Select2: The `formatInputTooLong` option has been renamed to `language.inputTooLong` in Select2 4.0.0."),null!=s.formatLoading&&console.warn("Select2: The `formatLoading` option has been renamed to `language.loadingMore` in Select2 4.0.0."),null!=s.formatSelectionTooBig&&console.warn("Select2: The `formatSelectionTooBig` option has been renamed to `language.maximumSelected` in Select2 4.0.0."),s.element.data("select2Tags")&&console.warn("Select2: The `data-select2-tags` attribute has been renamed to `data-tags` in Select2 4.0.0.")),null!=s.element.data("tags")){var h=s.element.data("tags");e.isArray(h)||(h=[]),s.element.data("select2Tags",h)}if(null!=s.sorter&&(s.sortResults=s.sorter),null!=s.selectOnClose&&(s.selectOnBlur=s.selectOnClose),null!=s.ajax&&e.isFunction(s.ajax.processResults)&&(s.ajax.results=s.ajax.processResults),null!=s.language){var u=s.language;e.isFunction(u.noMatches)&&(s.formatNoMatches=u.noMatches),e.isFunction(u.searching)&&(s.formatSearching=u.searching),e.isFunction(u.inputTooShort)&&(s.formatInputTooShort=u.inputTooShort),e.isFunction(u.inputTooLong)&&(s.formatInputTooLong=u.inputTooLong),e.isFunction(u.loadingMore)&&(s.formatLoading=u.loadingMore),e.isFunction(u.maximumSelected)&&(s.formatSelectionTooBig=u.maximumSelected)}if("function"!=typeof(s=e.extend({},{populateResults:function(i,n,o){var a,l=this.opts.id,r=this.liveRegion;(a=function(i,n,h){var u,d,p,f,g,m,v,b,w,S,C=[];for(u=0,d=(i=s.sortResults(i,n,o)).length;u<d;u+=1)f=!(g=!0===(p=i[u]).disabled)&&l(p)!==t,m=p.children&&p.children.length>0,(v=e("<li></li>")).addClass("select2-results-dept-"+h),v.addClass("select2-result"),v.addClass(f?"select2-result-selectable":"select2-result-unselectable"),g&&v.addClass("select2-disabled"),m&&v.addClass("select2-result-with-children"),v.addClass(c.opts.formatResultCssClass(p)),v.attr("role","presentation"),(b=e(document.createElement("div"))).addClass("select2-result-label"),b.attr("id","select2-result-label-"+D()),b.attr("role","option"),(S=s.formatResult(p,b,o,c.opts.escapeMarkup))!==t&&(b.html(S),v.append(b)),m&&((w=e("<ul></ul>")).addClass("select2-result-sub"),a(p.children,w,h+1),v.append(w)),v.data("select2-data",p),C.push(v[0]);n.append(C),r.text(s.formatMatches(i.length))})(n,i,0)}},e.fn.select2.defaults,s)).id&&(o=s.id,s.id=function(e){return e[o]}),e.isArray(s.element.data("select2Tags"))){if("tags"in s)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+s.element.attr("id");s.tags=s.element.data("select2Tags")}if(n?(s.query=this.bind(function(e){var s,n,o,a={results:[],more:!1},l=e.term;o=function(t,s){var i;t.is("option")?e.matcher(l,t.text(),t)&&s.push(c.optionToData(t)):t.is("optgroup")&&(i=c.optionToData(t),t.children().each2(function(e,t){o(t,i.children)}),i.children.length>0&&s.push(i))},s=i.children(),this.getPlaceholder()!==t&&s.length>0&&(n=this.getPlaceholderOption())&&(s=s.not(n)),s.each2(function(e,t){o(t,a.results)}),e.callback(a)}),s.id=function(e){return e.id}):"query"in s||("ajax"in s?((r=s.element.data("ajax-url"))&&r.length>0&&(s.ajax.url=r),s.query=C.call(s.element,s.ajax)):"data"in s?s.query=y(s.data):"tags"in s&&(s.query=x(s.tags),s.createSearchChoice===t&&(s.createSearchChoice=function(t){return{id:e.trim(t),text:e.trim(t)}}),s.initSelection===t&&(s.initSelection=function(t,i){var n=[];e(l(t.val(),s.separator,s.transformVal)).each(function(){var t={id:this,text:this},i=s.tags;e.isFunction(i)&&(i=i()),e(i).each(function(){if(a(this.id,t.id))return t=this,!1}),n.push(t)}),i(n)}))),"function"!=typeof s.query)throw"query function not defined for Select2 "+s.element.attr("id");if("top"===s.createSearchChoicePosition)s.createSearchChoicePosition=function(e,t){e.unshift(t)};else if("bottom"===s.createSearchChoicePosition)s.createSearchChoicePosition=function(e,t){e.push(t)};else if("function"!=typeof s.createSearchChoicePosition)throw"invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";return s},monitorSource:function(){var s,i=this.opts.element,n=this;i.on("change.select2",this.bind(function(e){!0!==this.opts.element.data("select2-change-triggered")&&this.initSelection()})),this._sync=this.bind(function(){var e=i.prop("disabled");e===t&&(e=!1),this.enable(!e);var s=i.prop("readonly");s===t&&(s=!1),this.readonly(s),this.container&&(b(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(E(this.opts.containerCssClass,this.opts.element))),this.dropdown&&(b(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(E(this.opts.dropdownCssClass,this.opts.element)))}),i.length&&i[0].attachEvent&&i.each(function(){this.attachEvent("onpropertychange",n._sync)}),(s=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver)!==t&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new s(function(t){e.each(t,n._sync)}),this.propertyObserver.observe(i.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(t){var s=e.Event("select2-selecting",{val:this.id(t),object:t,choice:t});return this.opts.element.trigger(s),!s.isDefaultPrevented()},triggerChange:function(t){t=t||{},t=e.extend({},t,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(t),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return!0===this.enabledInterface},enableInterface:function(){var e=this._enabled&&!this._readonly,t=!e;return e!==this.enabledInterface&&(this.container.toggleClass("select2-container-disabled",t),this.close(),this.enabledInterface=e,!0)},enable:function(e){e===t&&(e=!0),this._enabled!==e&&(this._enabled=e,this.opts.element.prop("disabled",!e),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(e){e===t&&(e=!1),this._readonly!==e&&(this._readonly=e,this.opts.element.prop("readonly",e),this.enableInterface())},opened:function(){return!!this.container&&this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var t,s,i,n,o,a=this.dropdown,l=this.container,r=l.offset(),c=l.outerHeight(!1),h=l.outerWidth(!1),u=a.outerHeight(!1),d=e(window),p=d.width(),f=d.height(),g=d.scrollLeft()+p,m=d.scrollTop()+f,v=r.top+c,b=r.left,w=v+u<=m,S=r.top-u>=d.scrollTop(),C=a.outerWidth(!1);a.hasClass("select2-drop-above")?(s=!0,!S&&w&&(i=!0,s=!1)):(s=!1,!w&&S&&(i=!0,s=!0)),i&&(a.hide(),r=this.container.offset(),c=this.container.outerHeight(!1),h=this.container.outerWidth(!1),u=a.outerHeight(!1),g=d.scrollLeft()+p,m=d.scrollTop()+f,v=r.top+c,b=r.left,C=a.outerWidth(!1),a.show(),this.focusSearch()),this.opts.dropdownAutoWidth?(o=e(".select2-results",a)[0],a.addClass("select2-drop-auto-width"),a.css("width",""),(C=a.outerWidth(!1)+(o.scrollHeight===o.clientHeight?0:H.width))>h?h=C:C=h,u=a.outerHeight(!1)):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body.css("position")&&(v-=(t=this.body.offset()).top,b-=t.left),!(b+C<=g)&&r.left+g+l.outerWidth(!1)>C&&(b=r.left+this.container.outerWidth(!1)-C),n={left:b,width:h},s?(this.container.addClass("select2-drop-above"),a.addClass("select2-drop-above"),u=a.outerHeight(!1),n.top=r.top-u,n.bottom="auto"):(n.top=v,n.bottom="auto",this.container.removeClass("select2-drop-above"),a.removeClass("select2-drop-above")),n=e.extend(n,E(this.opts.dropdownCss,this.opts.element)),a.css(n)},shouldOpen:function(){var t;return!this.opened()&&(!1!==this._enabled&&!0!==this._readonly&&(t=e.Event("select2-opening"),this.opts.element.trigger(t),!t.isDefaultPrevented()))},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return!!this.shouldOpen()&&(this.opening(),M.on("mousemove.select2Event",function(e){N.x=e.pageX,N.y=e.pageY}),!0)},opening:function(){var t,i=this.containerEventName,n="scroll."+i,o="resize."+i,a="orientationchange."+i;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body.children().last()[0]&&this.dropdown.detach().appendTo(this.body),0===(t=e("#select2-drop-mask")).length&&((t=e(document.createElement("div"))).attr("id","select2-drop-mask").attr("class","select2-drop-mask"),t.hide(),t.appendTo(this.body),t.on("mousedown touchstart click",function(i){s(t);var n,o=e("#select2-drop");o.length>0&&((n=o.data("select2")).opts.selectOnBlur&&n.selectHighlighted({noFocus:!0}),n.close(),i.preventDefault(),i.stopPropagation())})),this.dropdown.prev()[0]!==t[0]&&this.dropdown.before(t),e("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),t.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var l=this;this.container.parents().add(window).each(function(){e(this).on(o+" "+n+" "+a,function(e){l.opened()&&l.positionDropdown()})})},close:function(){if(this.opened()){var t=this.containerEventName,s="scroll."+t,i="resize."+t,n="orientationchange."+t;this.container.parents().add(window).each(function(){e(this).off(s).off(i).off(n)}),this.clearDropdownAlignmentPreference(),e("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),M.off("mousemove.select2Event"),this.clearSearch(),this.search.removeClass("select2-active"),this.search.removeAttr("aria-activedescendant"),this.opts.element.trigger(e.Event("select2-close"))}},externalSearch:function(e){this.open(),this.search.val(e),this.updateResults(!1)},clearSearch:function(){},prefillNextSearchTerm:function(){if(""!==this.search.val())return!1;var e=this.opts.nextSearchTerm(this.data(),this.lastSearchTerm);return e!==t&&(this.search.val(e),this.search.select(),!0)},getMaximumSelectionSize:function(){return E(this.opts.maximumSelectionSize,this.opts.element)},ensureHighlightVisible:function(){var t,s,i,n,o,a,l,r,c=this.results;(s=this.highlight())<0||(0!=s?(t=this.findHighlightableChoices().find(".select2-result-label"),n=(r=((i=e(t[s])).offset()||{}).top||0)+i.outerHeight(!0),s===t.length-1&&(l=c.find("li.select2-more-results")).length>0&&(n=l.offset().top+l.outerHeight(!0)),n>(o=c.offset().top+c.outerHeight(!1))&&c.scrollTop(c.scrollTop()+(n-o)),(a=r-c.offset().top)<0&&"none"!=i.css("display")&&c.scrollTop(c.scrollTop()+a)):c.scrollTop(0))},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)")},moveHighlight:function(t){for(var s=this.findHighlightableChoices(),i=this.highlight();i>-1&&i<s.length;){var n=e(s[i+=t]);if(n.hasClass("select2-result-selectable")&&!n.hasClass("select2-disabled")&&!n.hasClass("select2-selected")){this.highlight(i);break}}},highlight:function(t){var s,i,o=this.findHighlightableChoices();if(0===arguments.length)return n(o.filter(".select2-highlighted")[0],o.get());t>=o.length&&(t=o.length-1),t<0&&(t=0),this.removeHighlight(),(s=e(o[t])).addClass("select2-highlighted"),this.search.attr("aria-activedescendant",s.find(".select2-result-label").attr("id")),this.ensureHighlightVisible(),this.liveRegion.text(s.text()),(i=s.data("select2-data"))&&this.opts.element.trigger({type:"select2-highlight",val:this.id(i),choice:i})},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},touchMoved:function(){this._touchMoved=!0},clearTouchMoved:function(){this._touchMoved=!1},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(t){var s=e(t.target).closest(".select2-result-selectable");if(s.length>0&&!s.is(".select2-highlighted")){var i=this.findHighlightableChoices();this.highlight(i.index(s))}else 0==s.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var e=this.results,t=e.find("li.select2-more-results"),s=this.resultsPage+1,i=this,n=this.search.val(),o=this.context;0!==t.length&&t.offset().top-e.offset().top-e.height()<=this.opts.loadMorePadding&&(t.addClass("select2-active"),this.opts.query({element:this.opts.element,term:n,page:s,context:o,matcher:this.opts.matcher,callback:this.bind(function(a){i.opened()&&(i.opts.populateResults.call(this,e,a.results,{term:n,page:s,context:o}),i.postprocessResults(a,!1,!1),!0===a.more?(t.detach().appendTo(e).html(i.opts.escapeMarkup(E(i.opts.formatLoadMore,i.opts.element,s+1))),window.setTimeout(function(){i.loadMoreIfNeeded()},10)):t.remove(),i.positionDropdown(),i.resultsPage=s,i.context=a.context,this.opts.element.trigger({type:"select2-loaded",items:a}))})}))},tokenize:function(){},updateResults:function(s){function i(){c.removeClass("select2-active"),d.positionDropdown(),h.find(".select2-no-results,.select2-selection-limit,.select2-searching").length?d.liveRegion.text(h.text()):d.liveRegion.text(d.opts.formatMatches(h.find('.select2-result-selectable:not(".select2-selected")').length))}function n(e){h.html(e),i()}var o,l,r,c=this.search,h=this.results,u=this.opts,d=this,p=c.val(),f=e.data(this.container,"select2-last-term");if((!0===s||!f||!a(p,f))&&(e.data(this.container,"select2-last-term",p),!0===s||!1!==this.showSearchInput&&this.opened())){r=++this.queryCount;var g=this.getMaximumSelectionSize();if(!(g>=1&&(o=this.data(),e.isArray(o)&&o.length>=g&&T(u.formatSelectionTooBig,"formatSelectionTooBig"))))return c.val().length<u.minimumInputLength?(n(T(u.formatInputTooShort,"formatInputTooShort")?"<li class='select2-no-results'>"+E(u.formatInputTooShort,u.element,c.val(),u.minimumInputLength)+"</li>":""),void(s&&this.showSearch&&this.showSearch(!0))):void(u.maximumInputLength&&c.val().length>u.maximumInputLength?n(T(u.formatInputTooLong,"formatInputTooLong")?"<li class='select2-no-results'>"+E(u.formatInputTooLong,u.element,c.val(),u.maximumInputLength)+"</li>":""):(u.formatSearching&&0===this.findHighlightableChoices().length&&n("<li class='select2-searching'>"+E(u.formatSearching,u.element)+"</li>"),c.addClass("select2-active"),this.removeHighlight(),(l=this.tokenize())!=t&&null!=l&&c.val(l),this.resultsPage=1,u.query({element:u.element,term:c.val(),page:this.resultsPage,context:null,matcher:u.matcher,callback:this.bind(function(o){var l;if(r==this.queryCount)if(this.opened())if(o.hasError!==t&&T(u.formatAjaxError,"formatAjaxError"))n("<li class='select2-ajax-error'>"+E(u.formatAjaxError,u.element,o.jqXHR,o.textStatus,o.errorThrown)+"</li>");else{if(this.context=o.context===t?null:o.context,this.opts.createSearchChoice&&""!==c.val()&&(l=this.opts.createSearchChoice.call(d,c.val(),o.results))!==t&&null!==l&&d.id(l)!==t&&null!==d.id(l)&&0===e(o.results).filter(function(){return a(d.id(this),d.id(l))}).length&&this.opts.createSearchChoicePosition(o.results,l),0===o.results.length&&T(u.formatNoMatches,"formatNoMatches"))return n("<li class='select2-no-results'>"+E(u.formatNoMatches,u.element,c.val())+"</li>"),void(this.showSearch&&this.showSearch(c.val()));h.empty(),d.opts.populateResults.call(this,h,o.results,{term:c.val(),page:this.resultsPage,context:null}),!0===o.more&&T(u.formatLoadMore,"formatLoadMore")&&(h.append("<li class='select2-more-results'>"+u.escapeMarkup(E(u.formatLoadMore,u.element,this.resultsPage))+"</li>"),window.setTimeout(function(){d.loadMoreIfNeeded()},10)),this.postprocessResults(o,s),i(),this.opts.element.trigger({type:"select2-loaded",items:o})}else this.search.removeClass("select2-active")})})));n("<li class='select2-selection-limit'>"+E(u.formatSelectionTooBig,u.element,g)+"</li>")}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){p(this.search)},selectHighlighted:function(e){if(this._touchMoved)this.clearTouchMoved();else{var t=this.highlight(),s=this.results.find(".select2-highlighted").closest(".select2-result").data("select2-data");s?(this.highlight(t),this.onSelect(s,e)):e&&e.noFocus&&this.close()}},getPlaceholder:function(){var e;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((e=this.getPlaceholderOption())!==t?e.text():t)},getPlaceholderOption:function(){if(this.select){var s=this.select.children("option").first();if(this.opts.placeholderOption!==t)return"first"===this.opts.placeholderOption&&s||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===e.trim(s.text())&&""===s.val())return s}},initContainerWidth:function(){var t=function(){var t,s,i,n,o,a;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if("string"==typeof(t=this.opts.element.attr("style")))for(n=0,o=(s=t.split(";")).length;n<o;n+=1)if(a=s[n].replace(/\s/g,""),null!==(i=a.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i))&&i.length>=1)return i[1];return"resolve"===this.opts.width?(t=this.opts.element.css("width")).indexOf("%")>0?t:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px":null}return e.isFunction(this.opts.width)?this.opts.width():this.opts.width}.call(this);null!==t&&this.container.css("width",t)}}),{createContainer:function(){return e(document.createElement("div")).attr({class:"select2-container"}).html(["<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>","   <span class='select2-chosen'>&#160;</span><abbr class='select2-search-choice-close'></abbr>","   <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>","</a>","<label for='' class='select2-offscreen'></label>","<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />","<div class='select2-drop select2-display-none'>","   <div class='select2-search'>","       <label for='' class='select2-offscreen'></label>","       <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'","       aria-autocomplete='list' />","   </div>","   <ul class='select2-results' role='listbox'>","   </ul>","</div>"].join(""))},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var t,s,i;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),!1!==this.showSearchInput&&this.search.val(this.focusser.val()),this.opts.shouldFocusInput(this)&&(this.search.focus(),(t=this.search.get(0)).createTextRange?((s=t.createTextRange()).collapse(!1),s.select()):t.setSelectionRange&&(i=this.search.val().length,t.setSelectionRange(i,i))),this.prefillNextSearchTerm(),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(e.Event("select2-open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus()},destroy:function(){e("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),I.call(this,"selection","focusser")},initContainer:function(){var t,i,n=this.container,o=this.dropdown,a=D();this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=t=n.find(".select2-choice"),this.focusser=n.find(".select2-focusser"),t.find(".select2-chosen").attr("id","select2-chosen-"+a),this.focusser.attr("aria-labelledby","select2-chosen-"+a),this.results.attr("id","select2-results-"+a),this.search.attr("aria-owns","select2-results-"+a),this.focusser.attr("id","s2id_autogen"+a),i=e("label[for='"+this.opts.element.attr("id")+"']"),this.opts.element.on("focus.select2",this.bind(function(){this.focus()})),this.focusser.prev().text(i.text()).attr("for",this.focusser.attr("id"));var l=this.opts.element.attr("title");this.opts.element.attr("title",l||i.text()),this.focusser.attr("tabindex",this.elementTabIndex),this.search.attr("id",this.focusser.attr("id")+"_search"),this.search.prev().text(e("label[for='"+this.focusser.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.search.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()&&229!=e.keyCode)if(e.which!==F.PAGE_UP&&e.which!==F.PAGE_DOWN)switch(e.which){case F.UP:case F.DOWN:return this.moveHighlight(e.which===F.UP?-1:1),void g(e);case F.ENTER:return this.selectHighlighted(),void g(e);case F.TAB:return void this.selectHighlighted({noFocus:!0});case F.ESC:return this.cancel(e),void g(e)}else g(e)})),this.search.on("blur",this.bind(function(e){document.activeElement===this.body.get(0)&&window.setTimeout(this.bind(function(){this.opened()&&this.results&&this.results.length>1&&this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()&&e.which!==F.TAB&&!F.isControl(e)&&!F.isFunctionKey(e)&&e.which!==F.ESC){if(!1!==this.opts.openOnEnter||e.which!==F.ENTER){if(e.which==F.DOWN||e.which==F.UP||e.which==F.ENTER&&this.opts.openOnEnter){if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return;return this.open(),void g(e)}return e.which==F.DELETE||e.which==F.BACKSPACE?(this.opts.allowClear&&this.clear(),void g(e)):void 0}g(e)}})),c(this.focusser),this.focusser.on("keyup-change input",this.bind(function(e){if(this.opts.minimumResultsForSearch>=0){if(e.stopPropagation(),this.opened())return;this.open()}})),t.on("mousedown touchstart","abbr",this.bind(function(e){this.isInterfaceEnabled()&&(this.clear(),m(e),this.close(),this.selection&&this.selection.focus())})),t.on("mousedown touchstart",this.bind(function(i){s(t),this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),g(i)})),o.on("mousedown touchstart",this.bind(function(){this.opts.shouldFocusInput(this)&&this.search.focus()})),t.on("focus",this.bind(function(e){g(e)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(e.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.hide(),this.setPlaceholder()},clear:function(t){var s=this.selection.data("select2-data");if(s){var i=e.Event("select2-clearing");if(this.opts.element.trigger(i),i.isDefaultPrevented())return;var n=this.getPlaceholderOption();this.opts.element.val(n?n.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),!1!==t&&(this.opts.element.trigger({type:"select2-removed",val:this.id(s),choice:s}),this.triggerChange({removed:s}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var e=this;this.opts.initSelection.call(null,this.opts.element,function(s){s!==t&&null!==s&&(e.updateSelection(s),e.close(),e.setPlaceholder(),e.lastSearchTerm=e.search.val())})}},isPlaceholderOptionSelected:function(){var e;return this.getPlaceholder()!==t&&((e=this.getPlaceholderOption())!==t&&e.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===t||null===this.opts.element.val())},prepareOpts:function(){var t=this.parent.prepareOpts.apply(this,arguments),s=this;return"select"===t.element.get(0).tagName.toLowerCase()?t.initSelection=function(e,t){var i=e.find("option").filter(function(){return this.selected&&!this.disabled});t(s.optionToData(i))}:"data"in t&&(t.initSelection=t.initSelection||function(s,i){var n=s.val(),o=null;t.query({matcher:function(e,s,i){var l=a(n,t.id(i));return l&&(o=i),l},callback:e.isFunction(i)?function(){i(o)}:e.noop})}),t},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===t?t:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var e=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&e!==t){if(this.select&&this.getPlaceholderOption()===t)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(e)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(e,t,s){var i=0,n=this;if(this.findHighlightableChoices().each2(function(e,t){if(a(n.id(t.data("select2-data")),n.opts.element.val()))return i=e,!1}),!1!==s&&(!0===t&&i>=0?this.highlight(i):this.highlight(0)),!0===t){var o=this.opts.minimumResultsForSearch;o>=0&&this.showSearch(O(e.results)>=o)}},showSearch:function(t){this.showSearchInput!==t&&(this.showSearchInput=t,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!t),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!t),e(this.dropdown,this.container).toggleClass("select2-with-searchbox",t))},onSelect:function(e,t){if(this.triggerSelect(e)){var s=this.opts.element.val(),i=this.data();this.opts.element.val(this.id(e)),this.updateSelection(e),this.opts.element.trigger({type:"select2-selected",val:this.id(e),choice:e}),this.lastSearchTerm=this.search.val(),this.close(),t&&t.noFocus||!this.opts.shouldFocusInput(this)||this.focusser.focus(),a(s,this.id(e))||this.triggerChange({added:e,removed:i})}},updateSelection:function(e){var s,i,n=this.selection.find(".select2-chosen");this.selection.data("select2-data",e),n.empty(),null!==e&&(s=this.opts.formatSelection(e,n,this.opts.escapeMarkup)),s!==t&&n.append(s),(i=this.opts.formatSelectionCssClass(e,n))!==t&&n.addClass(i),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==t&&this.container.addClass("select2-allowclear")},val:function(){var e,s=!1,i=null,n=this,o=this.data();if(0===arguments.length)return this.opts.element.val();if(e=arguments[0],arguments.length>1&&(s=arguments[1],this.opts.debug&&console&&console.warn&&console.warn('Select2: The second option to `select2("val")` is not supported in Select2 4.0.0. The `change` event will always be triggered in 4.0.0.')),this.select)this.opts.debug&&console&&console.warn&&console.warn('Select2: Setting the value on a <select> using `select2("val")` is no longer supported in 4.0.0. You can use the `.val(newValue).trigger("change")` method provided by jQuery instead.'),this.select.val(e).find("option").filter(function(){return this.selected}).each2(function(e,t){return i=n.optionToData(t),!1}),this.updateSelection(i),this.setPlaceholder(),s&&this.triggerChange({added:i,removed:o});else{if(!e&&0!==e)return void this.clear(s);if(this.opts.initSelection===t)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(e),this.opts.initSelection(this.opts.element,function(e){n.opts.element.val(e?n.id(e):""),n.updateSelection(e),n.setPlaceholder(),s&&n.triggerChange({added:e,removed:o})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(e){var s,i=!1;if(0===arguments.length)return(s=this.selection.data("select2-data"))==t&&(s=null),s;this.opts.debug&&console&&console.warn&&console.warn('Select2: The `select2("data")` method can no longer set selected values in 4.0.0, consider using the `.val()` method instead.'),arguments.length>1&&(i=arguments[1]),e?(s=this.data(),this.opts.element.val(e?this.id(e):""),this.updateSelection(e),i&&this.triggerChange({added:e,removed:s})):this.clear(i)}}),A=P(k,{createContainer:function(){return e(document.createElement("div")).attr({class:"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>","  <li class='select2-search-field'>","    <label for='' class='select2-offscreen'></label>","    <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>","  </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>","   <ul class='select2-results'>","   </ul>","</div>"].join(""))},prepareOpts:function(){var t=this.parent.prepareOpts.apply(this,arguments),s=this;return"select"===t.element.get(0).tagName.toLowerCase()?t.initSelection=function(e,t){var i=[];e.find("option").filter(function(){return this.selected&&!this.disabled}).each2(function(e,t){i.push(s.optionToData(t))}),t(i)}:"data"in t&&(t.initSelection=t.initSelection||function(s,i){var n=l(s.val(),t.separator,t.transformVal),o=[];t.query({matcher:function(s,i,l){var r=e.grep(n,function(e){return a(e,t.id(l))}).length;return r&&o.push(l),r},callback:e.isFunction(i)?function(){for(var e=[],s=0;s<n.length;s++)for(var l=n[s],r=0;r<o.length;r++){var c=o[r];if(a(l,t.id(c))){e.push(c),o.splice(r,1);break}}i(e)}:e.noop})}),t},selectChoice:function(e){var t=this.container.find(".select2-search-choice-focus");t.length&&e&&e[0]==t[0]||(t.length&&this.opts.element.trigger("choice-deselected",t),t.removeClass("select2-search-choice-focus"),e&&e.length&&(this.close(),e.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",e)))},destroy:function(){e("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),I.call(this,"searchContainer","selection")},initContainer:function(){var t,s=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=t=this.container.find(s);var i=this;this.selection.on("click",".select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)",function(t){i.search[0].focus(),i.selectChoice(e(this))}),this.search.attr("id","s2id_autogen"+D()),this.search.prev().text(e("label[for='"+this.opts.element.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.opts.element.on("focus.select2",this.bind(function(){this.focus()})),this.search.on("input paste",this.bind(function(){this.search.attr("placeholder")&&0==this.search.val().length||this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()){++this.keydowns;var s=t.find(".select2-search-choice-focus"),i=s.prev(".select2-search-choice:not(.select2-locked)"),n=s.next(".select2-search-choice:not(.select2-locked)"),o=f(this.search);if(s.length&&(e.which==F.LEFT||e.which==F.RIGHT||e.which==F.BACKSPACE||e.which==F.DELETE||e.which==F.ENTER)){var a=s;return e.which==F.LEFT&&i.length?a=i:e.which==F.RIGHT?a=n.length?n:null:e.which===F.BACKSPACE?this.unselect(s.first())&&(this.search.width(10),a=i.length?i:n):e.which==F.DELETE?this.unselect(s.first())&&(this.search.width(10),a=n.length?n:null):e.which==F.ENTER&&(a=null),this.selectChoice(a),g(e),void(a&&a.length||this.open())}if((e.which===F.BACKSPACE&&1==this.keydowns||e.which==F.LEFT)&&0==o.offset&&!o.length)return this.selectChoice(t.find(".select2-search-choice:not(.select2-locked)").last()),void g(e);if(this.selectChoice(null),this.opened())switch(e.which){case F.UP:case F.DOWN:return this.moveHighlight(e.which===F.UP?-1:1),void g(e);case F.ENTER:return this.selectHighlighted(),void g(e);case F.TAB:return this.selectHighlighted({noFocus:!0}),void this.close();case F.ESC:return this.cancel(e),void g(e)}if(e.which!==F.TAB&&!F.isControl(e)&&!F.isFunctionKey(e)&&e.which!==F.BACKSPACE&&e.which!==F.ESC){if(e.which===F.ENTER){if(!1===this.opts.openOnEnter)return;if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return}this.open(),e.which!==F.PAGE_UP&&e.which!==F.PAGE_DOWN||g(e),e.which===F.ENTER&&g(e)}}})),this.search.on("keyup",this.bind(function(e){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(t){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),t.stopImmediatePropagation(),this.opts.element.trigger(e.Event("select2-blur"))})),this.container.on("click",s,this.bind(function(t){this.isInterfaceEnabled()&&(e(t.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.open(),this.focusSearch(),t.preventDefault()))})),this.container.on("focus",s,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.hide(),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var e=this;this.opts.initSelection.call(null,this.opts.element,function(s){s!==t&&null!==s&&(e.updateSelection(s),e.close(),e.clearSearch())})}},clearSearch:function(){var e=this.getPlaceholder(),s=this.getMaxSearchWidth();e!==t&&0===this.getVal().length&&!1===this.search.hasClass("select2-focused")?(this.search.val(e).addClass("select2-default"),this.search.width(s>0?s:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.prefillNextSearchTerm(),this.updateResults(!0),this.opts.shouldFocusInput(this)&&this.search.focus(),this.opts.element.trigger(e.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(t){var s={},i=[],n=this;e(t).each(function(){n.id(this)in s||(s[n.id(this)]=0,i.push(this))}),this.selection.find(".select2-search-choice").remove(),this.addSelectedChoice(i),n.postprocessResults()},tokenize:function(){var e=this.search.val();null!=(e=this.opts.tokenizer.call(this,e,this.data(),this.bind(this.onSelect),this.opts))&&e!=t&&(this.search.val(e),e.length>0&&this.open())},onSelect:function(e,t){this.triggerSelect(e)&&""!==e.text&&(this.addSelectedChoice(e),this.opts.element.trigger({type:"selected",val:this.id(e),choice:e}),this.lastSearchTerm=this.search.val(),this.clearSearch(),this.updateResults(),!this.select&&this.opts.closeOnSelect||this.postprocessResults(e,!1,!0===this.opts.closeOnSelect),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()?this.updateResults(!0):this.prefillNextSearchTerm()&&this.updateResults(),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:e}),t&&t.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(t){var s=this.getVal(),i=this;e(t).each(function(){s.push(i.createChoice(this))}),this.setVal(s)},createChoice:function(s){var i,n,o=!s.locked,a=e("<li class='select2-search-choice'>    <div></div>    <a href='#' class='select2-search-choice-close' tabindex='-1'></a></li>"),l=e("<li class='select2-search-choice select2-locked'><div></div></li>"),r=o?a:l,c=this.id(s);return(i=this.opts.formatSelection(s,r.find("div"),this.opts.escapeMarkup))!=t&&r.find("div").replaceWith(e("<div></div>").html(i)),(n=this.opts.formatSelectionCssClass(s,r.find("div")))!=t&&r.addClass(n),o&&r.find(".select2-search-choice-close").on("mousedown",g).on("click dblclick",this.bind(function(t){this.isInterfaceEnabled()&&(this.unselect(e(t.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),g(t),this.close(),this.focusSearch())})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),r.data("select2-data",s),r.insertBefore(this.searchContainer),c},unselect:function(t){var s,i,o=this.getVal();if(0===(t=t.closest(".select2-search-choice")).length)throw"Invalid argument: "+t+". Must be .select2-search-choice";if(s=t.data("select2-data")){var a=e.Event("select2-removing");if(a.val=this.id(s),a.choice=s,this.opts.element.trigger(a),a.isDefaultPrevented())return!1;for(;(i=n(this.id(s),o))>=0;)o.splice(i,1),this.setVal(o),this.select&&this.postprocessResults();return t.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(s),choice:s}),this.triggerChange({removed:s}),!0}},postprocessResults:function(e,t,s){var i=this.getVal(),o=this.results.find(".select2-result"),a=this.results.find(".select2-result-with-children"),l=this;o.each2(function(e,t){n(l.id(t.data("select2-data")),i)>=0&&(t.addClass("select2-selected"),t.find(".select2-result-selectable").addClass("select2-selected"))}),a.each2(function(e,t){t.is(".select2-result-selectable")||0!==t.find(".select2-result-selectable:not(.select2-selected)").length||t.addClass("select2-selected")}),-1==this.highlight()&&!1!==s&&!0===this.opts.closeOnSelect&&l.highlight(0),!this.opts.createSearchChoice&&!o.filter(".select2-result:not(.select2-selected)").length>0&&(!e||e&&!e.more&&0===this.results.find(".select2-no-results").length)&&T(l.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+E(l.opts.formatNoMatches,l.opts.element,l.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-r(this.search)},resizeSearch:function(){var e,t,s,i,n=r(this.search);e=v(this.search)+10,t=this.search.offset().left,(i=(s=this.selection.width())-(t-this.selection.offset().left)-n)<e&&(i=s-n),i<40&&(i=s-n),i<=0&&(i=e),this.search.width(Math.floor(i))},getVal:function(){var e;return this.select?null===(e=this.select.val())?[]:e:(e=this.opts.element.val(),l(e,this.opts.separator,this.opts.transformVal))},setVal:function(t){if(this.select)this.select.val(t);else{var s=[],i={};e(t).each(function(){this in i||(s.push(this),i[this]=0)}),this.opts.element.val(0===s.length?"":s.join(this.opts.separator))}},buildChangeDetails:function(e,t){for(var t=t.slice(0),e=e.slice(0),s=0;s<t.length;s++)for(var i=0;i<e.length;i++)if(a(this.opts.id(t[s]),this.opts.id(e[i]))){t.splice(s,1),s--,e.splice(i,1);break}return{added:t,removed:e}},val:function(s,i){var n,o=this;if(0===arguments.length)return this.getVal();if((n=this.data()).length||(n=[]),!s&&0!==s)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),void(i&&this.triggerChange({added:this.data(),removed:n}));if(this.setVal(s),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),i&&this.triggerChange(this.buildChangeDetails(n,this.data()));else{if(this.opts.initSelection===t)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(t){var s=e.map(t,o.id);o.setVal(s),o.updateSelection(t),o.clearSearch(),i&&o.triggerChange(o.buildChangeDetails(n,o.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var t=[],s=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){t.push(s.opts.id(e(this).data("select2-data")))}),this.setVal(t),this.triggerChange()},data:function(t,s){var i,n,o=this;if(0===arguments.length)return this.selection.children(".select2-search-choice").map(function(){return e(this).data("select2-data")}).get();n=this.data(),t||(t=[]),i=e.map(t,function(e){return o.opts.id(e)}),this.setVal(i),this.updateSelection(t),this.clearSearch(),s&&this.triggerChange(this.buildChangeDetails(n,this.data()))}}),e.fn.select2=function(){var s,i,o,a,l,r=Array.prototype.slice.call(arguments,0),c=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],h=["opened","isFocused","container","dropdown"],u=["val","data"],d={search:"externalSearch"};return this.each(function(){if(0===r.length||"object"==typeof r[0])(s=0===r.length?{}:e.extend({},r[0])).element=e(this),"select"===s.element.get(0).tagName.toLowerCase()?l=s.element.prop("multiple"):(l=s.multiple||!1,"tags"in s&&(s.multiple=l=!0)),(i=l?new window.Select2.class.multi:new window.Select2.class.single).init(s);else{if("string"!=typeof r[0])throw"Invalid arguments to select2 plugin: "+r;if(n(r[0],c)<0)throw"Unknown method: "+r[0];if(a=t,(i=e(this).data("select2"))===t)return;if("container"===(o=r[0])?a=i.container:"dropdown"===o?a=i.dropdown:(d[o]&&(o=d[o]),a=i[o].apply(i,r.slice(1))),n(r[0],h)>=0||n(r[0],u)>=0&&1==r.length)return!1}}),a===t?this:a},e.fn.select2.defaults={debug:!1,width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(e,t,s,i){var n=[];return w(this.text(e),s.term,n,i),n.join("")},transformVal:function(t){return e.trim(t)},formatSelection:function(e,s,i){return e?i(this.text(e)):t},sortResults:function(e,t,s){return e},formatResultCssClass:function(e){return e.css},formatSelectionCssClass:function(e,s){return t},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(e){return e==t?null:e.id},text:function(t){return t&&this.data&&this.data.text?e.isFunction(this.data.text)?this.data.text(t):t[this.data.text]:t.text},matcher:function(e,t){return i(""+t).toUpperCase().indexOf(i(""+e).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:function(e,s,i,n){var o,l,r,c,h,u=e,d=!1;if(!n.createSearchChoice||!n.tokenSeparators||n.tokenSeparators.length<1)return t;for(;;){for(l=-1,r=0,c=n.tokenSeparators.length;r<c&&(h=n.tokenSeparators[r],!((l=e.indexOf(h))>=0));r++);if(l<0)break;if(o=e.substring(0,l),e=e.substring(l+h.length),o.length>0&&(o=n.createSearchChoice.call(this,o,s))!==t&&null!==o&&n.id(o)!==t&&null!==n.id(o)){for(d=!1,r=0,c=s.length;r<c;r++)if(a(n.id(o),n.id(s[r]))){d=!0;break}d||i(o)}}return u!==e?e:void 0},escapeMarkup:S,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(e){return e},adaptDropdownCssClass:function(e){return null},nextSearchTerm:function(e,s){return t},searchInputPlaceholder:"",createSearchChoicePosition:"top",shouldFocusInput:function(e){return!("ontouchstart"in window||navigator.msMaxTouchPoints>0)||!(e.opts.minimumResultsForSearch<0)}},e.fn.select2.locales=[],e.fn.select2.locales.en={formatMatches:function(e){return 1===e?"One result is available, press enter to select it.":e+" results are available, use up and down arrow keys to navigate."},formatNoMatches:function(){return"No matches found"},formatAjaxError:function(e,t,s){return"Loading failed"},formatInputTooShort:function(e,t){var s=t-e.length;return"Please enter "+s+" or more character"+(1==s?"":"s")},formatInputTooLong:function(e,t){var s=e.length-t;return"Please delete "+s+" character"+(1==s?"":"s")},formatSelectionTooBig:function(e){return"You can only select "+e+" item"+(1==e?"":"s")},formatLoadMore:function(e){return"Loading more results…"},formatSearching:function(){return"Searching…"}},e.extend(e.fn.select2.defaults,e.fn.select2.locales.en),e.fn.select2.ajaxDefaults={transport:e.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:C,local:y,tags:x},util:{debounce:u,markMatch:w,escapeMarkup:S,stripDiacritics:i},class:{abstract:k,single:R,multi:A}}}}(jQuery);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/js-cookie.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,165 @@
+/*!
+ * JavaScript Cookie v2.2.0
+ * https://github.com/js-cookie/js-cookie
+ *
+ * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
+ * Released under the MIT license
+ */
+;(function (factory) {
+	var registeredInModuleLoader = false;
+	if (typeof define === 'function' && define.amd) {
+		define(factory);
+		registeredInModuleLoader = true;
+	}
+	if (typeof exports === 'object') {
+		module.exports = factory();
+		registeredInModuleLoader = true;
+	}
+	if (!registeredInModuleLoader) {
+		var OldCookies = window.Cookies;
+		var api = window.Cookies = factory();
+		api.noConflict = function () {
+			window.Cookies = OldCookies;
+			return api;
+		};
+	}
+}(function () {
+	function extend () {
+		var i = 0;
+		var result = {};
+		for (; i < arguments.length; i++) {
+			var attributes = arguments[ i ];
+			for (var key in attributes) {
+				result[key] = attributes[key];
+			}
+		}
+		return result;
+	}
+
+	function init (converter) {
+		function api (key, value, attributes) {
+			var result;
+			if (typeof document === 'undefined') {
+				return;
+			}
+
+			// Write
+
+			if (arguments.length > 1) {
+				attributes = extend({
+					path: '/'
+				}, api.defaults, attributes);
+
+				if (typeof attributes.expires === 'number') {
+					var expires = new Date();
+					expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
+					attributes.expires = expires;
+				}
+
+				// We're using "expires" because "max-age" is not supported by IE
+				attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
+
+				try {
+					result = JSON.stringify(value);
+					if (/^[\{\[]/.test(result)) {
+						value = result;
+					}
+				} catch (e) {}
+
+				if (!converter.write) {
+					value = encodeURIComponent(String(value))
+						.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
+				} else {
+					value = converter.write(value, key);
+				}
+
+				key = encodeURIComponent(String(key));
+				key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
+				key = key.replace(/[\(\)]/g, escape);
+
+				var stringifiedAttributes = '';
+
+				for (var attributeName in attributes) {
+					if (!attributes[attributeName]) {
+						continue;
+					}
+					stringifiedAttributes += '; ' + attributeName;
+					if (attributes[attributeName] === true) {
+						continue;
+					}
+					stringifiedAttributes += '=' + attributes[attributeName];
+				}
+				return (document.cookie = key + '=' + value + stringifiedAttributes);
+			}
+
+			// Read
+
+			if (!key) {
+				result = {};
+			}
+
+			// To prevent the for loop in the first place assign an empty array
+			// in case there are no cookies at all. Also prevents odd result when
+			// calling "get()"
+			var cookies = document.cookie ? document.cookie.split('; ') : [];
+			var rdecode = /(%[0-9A-Z]{2})+/g;
+			var i = 0;
+
+			for (; i < cookies.length; i++) {
+				var parts = cookies[i].split('=');
+				var cookie = parts.slice(1).join('=');
+
+				if (!this.json && cookie.charAt(0) === '"') {
+					cookie = cookie.slice(1, -1);
+				}
+
+				try {
+					var name = parts[0].replace(rdecode, decodeURIComponent);
+					cookie = converter.read ?
+						converter.read(cookie, name) : converter(cookie, name) ||
+						cookie.replace(rdecode, decodeURIComponent);
+
+					if (this.json) {
+						try {
+							cookie = JSON.parse(cookie);
+						} catch (e) {}
+					}
+
+					if (key === name) {
+						result = cookie;
+						break;
+					}
+
+					if (!key) {
+						result[name] = cookie;
+					}
+				} catch (e) {}
+			}
+
+			return result;
+		}
+
+		api.set = api;
+		api.get = function (key) {
+			return api.call(api, key);
+		};
+		api.getJSON = function () {
+			return api.apply({
+				json: true
+			}, [].slice.call(arguments));
+		};
+		api.defaults = {};
+
+		api.remove = function (key, attributes) {
+			api(key, '', extend(attributes, {
+				expires: -1
+			}));
+		};
+
+		api.withConverter = init;
+
+		return api;
+	}
+
+	return init(function () {});
+}));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/resources/js/ext/js-cookie.min.js	Mon Jun 04 12:32:38 2018 +0200
@@ -0,0 +1,1 @@
+!function(e){var n=!1;if("function"==typeof define&&define.amd&&(define(e),n=!0),"object"==typeof exports&&(module.exports=e(),n=!0),!n){var o=window.Cookies,t=window.Cookies=e();t.noConflict=function(){return window.Cookies=o,t}}}(function(){function e(){for(var e=0,n={};e<arguments.length;e++){var o=arguments[e];for(var t in o)n[t]=o[t]}return n}function n(o){function t(n,r,i){var c;if("undefined"!=typeof document){if(arguments.length>1){if("number"==typeof(i=e({path:"/"},t.defaults,i)).expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*i.expires),i.expires=a}i.expires=i.expires?i.expires.toUTCString():"";try{c=JSON.stringify(r),/^[\{\[]/.test(c)&&(r=c)}catch(e){}r=o.write?o.write(r,n):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),n=(n=(n=encodeURIComponent(String(n))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);var s="";for(var f in i)i[f]&&(s+="; "+f,!0!==i[f]&&(s+="="+i[f]));return document.cookie=n+"="+r+s}n||(c={});for(var p=document.cookie?document.cookie.split("; "):[],d=/(%[0-9A-Z]{2})+/g,u=0;u<p.length;u++){var l=p[u].split("="),C=l.slice(1).join("=");this.json||'"'!==C.charAt(0)||(C=C.slice(1,-1));try{var g=l[0].replace(d,decodeURIComponent);if(C=o.read?o.read(C,g):o(C,g)||C.replace(d,decodeURIComponent),this.json)try{C=JSON.parse(C)}catch(e){}if(n===g){c=C;break}n||(c[g]=C)}catch(e){}}return c}}return t.set=t,t.get=function(e){return t.call(t,e)},t.getJSON=function(){return t.apply({json:!0},[].slice.call(arguments))},t.defaults={},t.remove=function(n,o){t(n,"",e(o,{expires:-1}))},t.withConverter=n,t}return n(function(){})});
--- a/src/ztfy/myams/resources/js/myams.js	Mon Jun 04 12:32:06 2018 +0200
+++ b/src/ztfy/myams/resources/js/myams.js	Mon Jun 04 12:32:38 2018 +0200
@@ -10,10 +10,10 @@
  * ©2014-2016 Thierry Florac <tflorac@ulthar.net>
  */
 
+"use strict";
+
 (function($, globals) {
 
-	"use strict";
-
 	var console = globals.console;
 
 	/**
@@ -90,6 +90,13 @@
 
 	/**
 	 * JQuery filter on parents class
+	 * This filter is often combined with ":not()" to select DOM objects which don't have
+	 * parents of a given class.
+	 * For example:
+	 *
+	 *   $('.hint:not(:parents(.nohints))', element);
+	 *
+	 * will select all elements with ".hint" class which don't have a parent with '.nohints' class.
 	 */
 	$.expr[':'].parents = function(obj, index, meta /*, stack*/) {
 		return $(obj).parents(meta[3]).length > 0;
@@ -98,7 +105,7 @@
 
 	/**
 	 * JQuery 'scrollbarWidth' function
-	 * Get width of vertical scrollbar
+	 * Get width of default vertical scrollbar
 	 */
 	if ($.scrollbarWidth === undefined) {
 		$.scrollbarWidth = function() {
@@ -116,16 +123,16 @@
 	 */
 	$.fn.extend({
 
-		/*
+		/**
 		 * Check if current object is empty or not
 		 */
 		exists: function() {
 			return $(this).length > 0;
 		},
 
-		/*
+		/**
 		 * Get object if it supports given CSS class,
-		 * otherwise looks for parents
+		 * otherwise look for parents
 		 */
 		objectOrParentWithClass: function(klass) {
 			if (this.hasClass(klass)) {
@@ -135,7 +142,7 @@
 			}
 		},
 
-		/*
+		/**
 		 * Build an array of attributes of the given selection
 		 */
 		listattr: function(attr) {
@@ -146,7 +153,7 @@
 			return result;
 		},
 
-		/*
+		/**
 		 * CSS style function
 		 * Code from Aram Kocharyan on stackoverflow.com
 		 */
@@ -176,7 +183,7 @@
 			}
 		},
 
-		/*
+		/**
 		 * Remove CSS classes starting with a given prefix
 		 */
 		removeClassPrefix: function (prefix) {
@@ -189,7 +196,7 @@
 			return this;
 		},
 
-		/*
+		/**
 		 * Context menu handler
 		 */
 		contextMenu: function(settings) {
@@ -216,7 +223,7 @@
 					if (e.ctrlKey) {
 						return;
 					}
-					//open menu
+					// open menu
 					$(settings.menuSelector).data("invokedOn", $(e.target))
 											.show()
 											.css({
@@ -235,7 +242,7 @@
 					return false;
 				});
 
-				//make sure menu closes on any click
+				// make sure menu closes on any click
 				$(document).click(function () {
 					$(settings.menuSelector).hide();
 				});
@@ -576,9 +583,9 @@
 	};
 
 	/**
-	 * Get script or CSS file using browser cache
-	 * Script or CSS URLs can include variable names, given between braces, as in
-	 * {MyAMS.baseURL}
+	 * Get target URL matching given source
+	 *
+	 * Given URL can include variable names (with their namespace), given between braces, as in {MyAMS.baseURL}
 	 */
 	MyAMS.getSource = function(url) {
 		return url.replace(/{[^{}]*}/g, function(match) {
@@ -586,6 +593,13 @@
 		});
 	};
 
+	/**
+	 * Script loader function
+	 *
+	 * @param url: script URL
+	 * @param callback: a callback to be called after script loading
+	 * @param options: a set of options to be added to AJAX call
+	 */
 	MyAMS.getScript = function(url, callback, options) {
 		if (typeof(callback) === 'object') {
 			options = callback;
@@ -606,19 +620,44 @@
 		return $.ajax(settings);
 	};
 
-	MyAMS.getCSS = function(url, id) {
+	/**
+	 * CSS file loader function
+	 * Cross-browser code copied from Stoyan Stefanov blog to be able to
+	 * call a callback when CSS is realy loaded.
+	 * See: https://www.phpied.com/when-is-a-stylesheet-really-loaded
+	 *
+	 * @param url: CSS file URL
+	 * @param id: a unique ID given to CSS file
+	 * @param callback: optional callback function to be called when CSS file is loaded. If set, callback is called
+	 *   with a 'first_load' boolean argument to indicate is CSS was already loaded (*false* value) or not (*true*
+	 *   value).
+	 * @param options: callback options
+	 */
+	MyAMS.getCSS = function(url, id, callback, options) {
+		if (callback) {
+			callback = ams.getFunctionByName(callback);
+		}
 		var head = $('HEAD');
-		var css = $('link[data-ams-id="' + id + '"]', head);
-		if (css.length === 0) {
-			var source = ams.getSource(url);
-			if (ams.devmode) {
-				source += '?_=' + new Date().getTime();
-			}
-			$('<link />').attr({rel: 'stylesheet',
-								type: 'text/css',
-								href: source,
-								'data-ams-id': id})
-						 .appendTo(head);
+		var style = $('style[data-ams-id="' + id + '"]', head);
+		if (style.length === 0) {
+			style = $('<style>').attr('data-ams-id', id)
+								.text('@import "' + ams.getSource(url) + '";');
+			if (callback) {
+				var styleInterval = setInterval(function() {
+					try {
+						var _check = style[0].sheet.cssRules;  // Is only populated when file is loaded
+						callback.call(window, true, options);
+						clearInterval(styleInterval);
+					} catch (e) {
+						// CSS is not loaded yet...
+					}
+				}, 10);
+			}
+			style.appendTo(head);
+		} else {
+			if (callback) {
+				callback.call(window, false, options);
+			}
 		}
 	};
 
@@ -628,11 +667,14 @@
 	 */
 	MyAMS.event = {
 
+		/**
+		 * Stop current event propagation
+		 */
 		stop: function(event) {
 			if (!event) {
 				event = window.event;
 			}
-			if (event) {
+			if (event && (typeof(event) !== 'string')) {
 				if (event.stopPropagation) {
 					event.stopPropagation();
 					event.preventDefault();
@@ -650,6 +692,9 @@
 	 */
 	MyAMS.browser = {
 
+		/**
+		 * Get IE version
+		 */
 		getInternetExplorerVersion: function() {
 			var rv = -1;
 			if (navigator.appName === "Microsoft Internet Explorer") {
@@ -662,6 +707,9 @@
 			return rv;
 		},
 
+		/**
+		 * Display alert for old IE version
+		 */
 		checkVersion: function() {
 			var msg = "You're not using Windows Internet Explorer.";
 			var ver = this.getInternetExplorerVersion();
@@ -677,6 +725,9 @@
 			}
 		},
 
+		/**
+		 * Check if IE is in version 8 or lower
+		 */
 		isIE8orlower: function() {
 			var msg = "0";
 			var ver = this.getInternetExplorerVersion();
@@ -691,6 +742,14 @@
 		},
 
 
+		/**
+		 * Copy selection to clipboard
+		 *
+		 * If 'text' argument is provided, given text is copied to clipboard.
+		 * Otherwise, text ou event's source is copied.
+		 * Several methods are tested to do clipboard copy (based on browser features); il copy can't be done,
+		 * a prompt is displayed to allow user to make a manual copy. 
+		 */
 		copyToClipboard: function(text) {
 
 			function doCopy(text) {
@@ -722,7 +781,7 @@
 											  ? ams.i18n.CLIPBOARD_TEXT_COPY_OK
 											  : ams.i18n.CLIPBOARD_CHARACTER_COPY_OK,
 										  icon: 'fa fa-fw fa-info-circle font-xs align-top margin-top-10',
-										  timeout: 1000
+										  timeout: 3000
 									  });
 				} else if (globals.prompt) {
 					globals.prompt(MyAMS.i18n.CLIPBOARD_COPY, text);
@@ -812,12 +871,12 @@
 		/**
 		 * Check for given feature and download script if necessary
 		 *
-		 * @checker: pointer to a javascript object which will be downloaded in undefined
-		 * @source: URL of a javascript file containing requested feature
-		 * @callback: pointer to a function which will be called after the script is downloaded. The first
+		 * @param checker: pointer to a javascript object which will be downloaded in undefined
+		 * @param source: URL of a javascript file containing requested feature
+		 * @param callback: pointer to a function which will be called after the script is downloaded. The first
 		 *   argument of this callback is a boolean value indicating if the script was just downloaded (true)
 		 *   or if the requested object was already loaded (false)
-		 * @options: callback options
+		 * @param options: callback options
 		 */
 		check: function(checker, source, callback, options) {
 
@@ -1142,8 +1201,7 @@
 				message = result.message;
 				if (typeof(message) === 'string') {
 					if ((status === 'info') || (status === 'success')) {
-						ams.skin.smallBox(status,
-										  {
+						ams.skin.smallBox(status, {
 											  title: message,
 											  icon: 'fa fa-fw fa-info-circle font-xs align-top margin-top-10',
 											  timeout: 3000
@@ -1160,16 +1218,25 @@
 				}
 			}
 			if (result.smallbox) {
-				ams.skin.smallBox(result.smallbox_status || status,
-								  {title: result.smallbox,
-								   icon: 'fa fa-fw fa-info-circle font-xs align-top margin-top-10',
-								   timeout: 3000});
+				message = result.smallbox;
+				if (typeof(message) === 'string') {
+					ams.skin.smallBox(result.smallbox_status || status, {
+						title: result.smallbox,
+						icon: result.smallbox_icon || 'fa fa-fw fa-info-circle font-xs align-top margin-top-10',
+						timeout: result.smallbox_timeout || 3000
+					});
+				} else {
+					ams.skin.smallBox(message.status || status, {
+						title: message.message,
+						icon: message.icon || 'fa fa-fw fa-info-circle font-xs align-top margin-top-10',
+						timeout: message.timeout || 3000
+					});
+				}
 			}
 			if (result.messagebox) {
 				message = result.messagebox;
 				if (typeof(message) === 'string') {
-					ams.skin.messageBox('info',
-										{
+					ams.skin.messageBox('info', {
 											title: ams.i18n.ERROR_OCCURED,
 											content: message,
 											timeout: 10000
@@ -1179,12 +1246,13 @@
 					if (messageStatus === 'error' && form && target) {
 						ams.executeFunctionByName(form.data('ams-form-submit-error') || 'MyAMS.form.finalizeSubmitOnError', form, target);
 					}
-					ams.skin.messageBox(messageStatus,
-										{title: message.title || ams.i18n.ERROR_OCCURED,
-										 content: message.content,
-										 icon: message.icon,
-										 number: message.number,
-										 timeout: message.timeout === null ? undefined : (message.timeout || 10000)});
+					ams.skin.messageBox(messageStatus, {
+											title: message.title || ams.i18n.ERROR_OCCURED,
+											content: message.content,
+											icon: message.icon,
+											number: message.number,
+											timeout: message.timeout === null ? undefined : (message.timeout || 10000)
+										});
 				}
 			}
 			if (result.event) {
@@ -1197,6 +1265,9 @@
 				}
 				for (index  =0; index < result.events.length; index++) {
 					event = result.events[index];
+					if (event === null) {
+						continue;
+					}
 					if (typeof(event) === 'string') {
 						form.trigger(event, result.events_options);
 					} else {
@@ -2117,14 +2188,16 @@
 							widget = $('[name="' + widgetData.name + ':list"]', form);
 						}
 						if (widget.exists()) {
+							// Update widget state
 							widget.parents('label:first')
 								  .removeClassPrefix('state-')
 								  .addClass('state-error')
 								  .after('<span for="name" class="state-error">' + widgetData.message + '</span>');
-						}
-						// complete form alert message
-						if (widgetData.label) {
-							message.push(widgetData.label + ' : ' + widgetData.message);
+						} else {
+							// complete form alert message
+							if (widgetData.label) {
+								message.push(widgetData.label + ' : ' + widgetData.message);
+							}
 						}
 						// mark parent tab (if any) with error status
 						var tabIndex = widget.parents('.tab-pane').index() + 1;
@@ -2136,7 +2209,7 @@
 						}
 					}
 				}
-				ams.skin.alert($('fieldset:first', form), errors.error_level || 'error', header, message, errors.error_message);
+				ams.skin.alert($('.form-group:first', form), errors.error_level || 'error', header, message, errors.error_message);
 			}
 		}
 	};
@@ -2459,21 +2532,16 @@
 
 		/** Select2 selection formatter */
 		select2FormatSelection: function(object, container) {
-			if (object instanceof Array) {
-				$(object).each(function() {
-					if (typeof(this) === 'object') {
-						container.append(this.text);
-					} else {
-						container.append(this);
-					}
-				});
-			} else {
-				if (typeof(object) === 'object') {
-					container.append(object.text);
+			if (!(object instanceof Array)) {
+				object = [object];
+			}
+			$(object).each(function() {
+				if (typeof(this) === 'object') {
+					container.append(this.text);
 				} else {
-					container.append(object);
+					container.append(this);
 				}
-			}
+			});
 		},
 
 		/** Select2 'select-all' helper */
@@ -2538,6 +2606,48 @@
 			}
 		},
 
+		/** Select2 helper to automate selection change */
+		select2ChangeHelper: function() {
+			var source = $(this);
+			var data = source.data();
+			var target = $(data.amsSelect2HelperTarget);
+			switch (data.amsSelect2HelperType) {
+				case 'html':
+					target.html('<div class="text-center"><i class="fa fa-2x fa-gear fa-spin"></i></div>');
+					var params = {};
+					params[data.amsSelect2HelperArgument || 'value'] = source.val();
+					$.get(data.amsSelect2HelperUrl, params,
+						ams.getFunctionByName(data.amsSelect2HelperCallback) || function(result) {
+							if (result) {
+								target.html(result);
+								ams.initContent(target);
+							} else {
+								target.empty();
+							}
+						});
+					break;
+				case 'json-rpc':
+					target.html('<div class="text-center"><i class="fa fa-2x fa-gear fa-spin"></i></div>');
+					ams.jsonrpc.post(data.amsSelect2HelperMethod,
+									 {value: source.val()},
+									 {url: data.amsSelect2HelperUrl},
+									 ams.getFunctionByName(data.amsSelect2HelperCallback) || function(result) {
+										if (result.result) {
+											target.html(result.result);
+											ams.initContent(target);
+										} else {
+											target.empty();
+										}
+									 });
+					break;
+				default:
+					var callback = data.amsSelect2HelperCallback;
+					if (callback) {
+						ams.executeFunctionByName(callback, source, data);
+					}
+			}
+		},
+
 		/** Context menu handler */
 		contextMenuHandler: function(target, menu) {
 			var menuData = menu.data();
@@ -2590,6 +2700,23 @@
 		/** Datetimepicker dialog cleaner callback */
 		datetimepickerDialogHiddenCallback: function() {
 			$('.datepicker, .timepicker, .datetimepicker', this).datetimepicker('destroy');
+		},
+
+		/** Set SEO status */
+		setSEOStatus: function() {
+			var input = $(this);
+			var progress = input.siblings('.progress').children('.progress-bar');
+			var length = Math.min(input.val().length, 100);
+			var status = 'success';
+			if (length < 20 || length > 80) {
+				status = 'danger';
+			} else if (length < 40 || length > 66) {
+				status = 'warning';
+			}
+			progress.removeClassPrefix('progress-bar')
+					.addClass('progress-bar')
+					.addClass('progress-bar-' + status)
+					.css('width', length + '%');
 		}
 	};
 
@@ -2881,30 +3008,31 @@
 				if (hints.length > 0) {
 					ams.ajax.check($.fn.tipsy,
 								   ams.baseURL + 'ext/jquery-tipsy' + ams.devext + '.js',
-								   function () {
+								   function() {
 									   ams.getCSS(ams.baseURL + '../css/ext/jquery-tipsy' + ams.devext + '.css',
-												  'jquery-tipsy');
-									   hints.each(function () {
-										   var hint = $(this);
-										   var data = hint.data();
-										   var dataOptions = {
-											   html: data.amsHintHtml,
-											   title: ams.getFunctionByName(data.amsHintTitleGetter) || function () {
-												   var hint = $(this);
-												   var result = hint.attr('original-title') ||
-																hint.attr(data.amsHintTitleAttr || 'title') ||
-																(data.amsHintHtml ? hint.html() : hint.text());
-												   result = result.replace(/\?_="/, '?_=' + new Date().getTime() + '"');
-												   return result;
-											   },
-											   opacity: data.amsHintOpacity || 0.95,
-											   gravity: data.amsHintGravity || 'sw',
-											   offset: data.amsHintOffset || 0
-										   };
-										   var settings = $.extend({}, dataOptions, data.amsHintOptions);
-										   settings = ams.executeFunctionByName(data.amsHintInitCallback, hint, settings) || settings;
-										   var plugin = hint.tipsy(settings);
-										   ams.executeFunctionByName(data.amsHintAfterInitCallback, hint, plugin, settings);
+												  'jquery-tipsy', function() {
+										   hints.each(function () {
+											   var hint = $(this);
+											   var data = hint.data();
+											   var dataOptions = {
+												   html: data.amsHintHtml === undefined ? (hint.attr('title') || '').startsWith('<') : data.amsHintHtml,
+												   title: ams.getFunctionByName(data.amsHintTitleGetter) || function () {
+													   var hint = $(this);
+													   var result = hint.attr('original-title') ||
+																	hint.attr(data.amsHintTitleAttr || 'title') ||
+																	(data.amsHintHtml ? hint.html() : hint.text());
+													   result = result.replace(/\?_="/, '?_=' + new Date().getTime() + '"');
+													   return result;
+												   },
+												   opacity: data.amsHintOpacity || 0.95,
+												   gravity: data.amsHintGravity || 'sw',
+												   offset: data.amsHintOffset || 0
+											   };
+											   var settings = $.extend({}, dataOptions, data.amsHintOptions);
+											   settings = ams.executeFunctionByName(data.amsHintInitCallback, hint, settings) || settings;
+											   var plugin = hint.tipsy(settings);
+											   ams.executeFunctionByName(data.amsHintAfterInitCallback, hint, plugin, settings);
+										   });
 									   });
 								   });
 				}
@@ -3032,6 +3160,7 @@
 									if (isChecked) {
 										if (data.amsCheckerMode === 'disable') {
 											fieldset.removeAttr('disabled');
+											$('.select2', fieldset).removeAttr('disabled');
 										} else {
 											fieldset.removeClass('switched');
 										}
@@ -3043,6 +3172,7 @@
 									} else {
 										if (data.amsCheckerMode === 'disable') {
 											fieldset.prop('disabled', 'disabled');
+											$('.select2', fieldset).attr('disabled', 'disabled');
 										} else {
 											fieldset.addClass('switched');
 										}
@@ -3066,6 +3196,7 @@
 						} else {
 							if (data.amsCheckerMode === 'disable') {
 								fieldset.attr('disabled', 'disabled');
+								$('.select2', fieldset).attr('disabled', 'disabled');
 							} else {
 								fieldset.addClass('switched');
 							}
@@ -3108,7 +3239,9 @@
 						var draggable = $(this);
 						var data = draggable.data();
 						var dataOptions = {
+							cursor: data.amsDraggableCursor || 'move',
 							containment: data.amsDraggableContainment,
+							connectToSortable: data.amsDraggableConnectSortable,
 							helper: ams.getFunctionByName(data.amsDraggableHelper) || data.amsDraggableHelper,
 							start: ams.getFunctionByName(data.amsDraggableStart),
 							stop: ams.getFunctionByName(data.amsDraggableStop)
@@ -3123,6 +3256,27 @@
 			},
 
 			/**
+			 * Droppable plug-in
+			 */
+			droppable: function(element) {
+				var droppables = $('.droppable', element);
+				if (droppables.length > 0) {
+					droppables.each(function() {
+						var droppable = $(this);
+						var data = droppable.data();
+						var dataOptions = {
+							accept: data.amsdroppableAccept,
+							drop: ams.getFunctionByName(data.amsDroppableDrop)
+						};
+						var settings = $.extend({}, dataOptions, data.amsDroppableOptions);
+						settings = ams.executeFunctionByName(data.amsDroppableInitCallback, droppable, settings) || settings;
+						var plugin = droppable.droppable(settings);
+						ams.executeFunctionByName(data.amsDroppableAfterInitCallback, droppable, plugin, settings);
+					});
+				}
+			},
+
+			/**
 			 * Sortable plug-in
 			 */
 			sortable: function(element) {
@@ -3200,17 +3354,85 @@
 			},
 
 			/**
+			 * Treeview plug-in
+			 */
+			treeview: function(element) {
+				var treeviews = $('.treeview', element);
+				if (treeviews.length > 0) {
+					ams.ajax.check($.fn.treview,
+								   ams.baseURL + 'ext/bootstrap-treeview' + ams.devext + '.js',
+								   function() {
+										ams.getCSS(ams.baseURL + '../css/ext/bootstrap-treeview' + ams.devext + '.css',
+												   'bootstrap-treeview',
+												   function() {
+													   treeviews.each(function () {
+														   var treeview = $(this);
+														   var data = treeview.data();
+														   var dataOptions = {
+															   data: data.amsTreeviewData,
+															   levels: data.amsTreeviewLevels,
+															   injectStyle: data.amsTreeviewInjectStyle,
+															   expandIcon: data.amsTreeviewExpandIcon || 'fa fa-fw fa-plus-square-o',
+															   collapseIcon: data.amsTreeviewCollaspeIcon || 'fa fa-fw fa-minus-square-o',
+															   emptyIcon: data.amsTreeviewEmptyIcon || 'fa fa-fw',
+															   nodeIcon: data.amsTreeviewNodeIcon,
+															   selectedIcon: data.amsTreeviewSelectedIcon,
+															   checkedIcon: data.amsTreeviewCheckedIcon || 'fa fa-fw fa-check-square-o',
+															   uncheckedIcon: data.amsTreeviewUncheckedIcon || 'fa fa-fw fa-square-o',
+															   color: data.amsTreeviewColor,
+															   backColor: data.amsTreeviewBackColor,
+															   borderColor: data.amsTreeviewBorderColor,
+															   onHoverColor: data.amsTreeviewHoverColor,
+															   selectedColor: data.amsTreeviewSelectedColor,
+															   selectedBackColor: data.amsTreeviewSelectedBackColor,
+															   unselectableColor: data.amsTreeviewUnselectableColor || 'rgba(1,1,1,0.25)',
+															   unselectableBackColor: data.amsTreeviewUnselectableBackColor || 'rgba(1,1,1,0.25)',
+															   enableLinks: data.amsTreeviewEnableLinks,
+															   highlightSelected: data.amsTreeviewHighlightSelected,
+															   highlightSearchResults: data.amsTreeviewhighlightSearchResults,
+															   showBorder: data.amsTreeviewShowBorder,
+															   showIcon: data.amsTreeviewShowIcon,
+															   showCheckbox: data.amsTreeviewShowCheckbox,
+															   showTags: data.amsTreeviewShowTags,
+															   toggleUnselectable: data.amsTreeviewToggleUnselectable,
+															   multiSelect: data.amsTreeviewMultiSelect,
+															   onNodeChecked: ams.getFunctionByName(data.amsTreeviewNodeChecked),
+															   onNodeCollapsed: ams.getFunctionByName(data.amsTreeviewNodeCollapsed),
+															   onNodeDisabled: ams.getFunctionByName(data.amsTreeviewNodeDisabled),
+															   onNodeEnabled: ams.getFunctionByName(data.amsTreeviewNodeEnabled),
+															   onNodeExpanded: ams.getFunctionByName(data.amsTreeviewNodeExpanded),
+															   onNodeSelected: ams.getFunctionByName(data.amsTreeviewNodeSelected),
+															   onNodeUnchecked: ams.getFunctionByName(data.amsTreeviewNodeUnchecked),
+															   onNodeUnselected: ams.getFunctionByName(data.amsTreeviewNodeUnselected),
+															   onSearchComplete: ams.getFunctionByName(data.amsTreeviewSearchComplete),
+															   onSearchCleared: ams.getFunctionByName(data.amsTreeviewSearchCleared)
+														   };
+														   var settings = $.extend({}, dataOptions, data.amsTreeviewOptions);
+														   settings = ams.executeFunctionByName(data.amsTreeviewInitcallback, treeview, settings) || settings;
+														   var plugin = treeview.treeview(settings);
+														   ams.executeFunctionByName(data.amsTreeviewAfterInitCallback, treeview, plugin, settings);
+													   });
+												   });
+								   });
+				}
+			},
+
+			/**
 			 * Select2 plug-in
 			 */
 			select2: function(element) {
 				var selects = $('.select2', element);
 				if (selects.length > 0) {
 					ams.ajax.check($.fn.select2,
-								   ams.baseURL + 'ext/jquery-select2-3.5.2' + ams.devext + '.js',
+								   ams.baseURL + 'ext/jquery-select2-3.5.4' + ams.devext + '.js',
 								   function() {
 										selects.each(function() {
 											var select = $(this);
 											var data = select.data();
+											if (data.select2) {
+												// Already initialized
+												return;
+											}
 											var dataOptions = {
 												placeholder: data.amsSelect2Placeholder,
 												multiple: data.amsSelect2Multiple,
@@ -3459,26 +3681,29 @@
 								   ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js',
 								   function(first_load) {
 										if (first_load) {
-											ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', 'jquery-datetimepicker');
 											ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback);
 										}
-										datepickers.each(function() {
-											var input = $(this);
-											var data = input.data();
-											var dataOptions = {
-												lang: data.amsDatetimepickerLang || ams.lang,
-												format: data.amsDatetimepickerFormat || 'd/m/y',
-												datepicker: true,
-												dayOfWeekStart: 1,
-												timepicker: false,
-												closeOnDateSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect,
-												weeks: data.amsDatetimepickerWeeks
-											};
-											var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions);
-											settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings;
-											var plugin = input.datetimepicker(settings);
-											ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings);
-										});
+										ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css',
+												   'jquery-datetimepicker',
+												   function () {
+													   datepickers.each(function () {
+														   var input = $(this);
+														   var data = input.data();
+														   var dataOptions = {
+															   lang: data.amsDatetimepickerLang || ams.lang,
+															   format: data.amsDatetimepickerFormat || 'd/m/y',
+															   datepicker: true,
+															   dayOfWeekStart: 1,
+															   timepicker: false,
+															   closeOnDateSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect,
+															   weeks: data.amsDatetimepickerWeeks
+														   };
+														   var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions);
+														   settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings;
+														   var plugin = input.datetimepicker(settings);
+														   ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings);
+													   });
+												   });
 								   });
 				}
 			},
@@ -3493,27 +3718,30 @@
 								   ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js',
 								   function(first_load) {
 										if (first_load) {
-											ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', 'jquery-datetimepicker');
 											ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback);
 										}
-										datetimepickers.each(function() {
-											var input = $(this);
-											var data = input.data();
-											var dataOptions = {
-												lang: data.amsDatetimepickerLang || ams.lang,
-												format: data.amsDatetimepickerFormat || 'd/m/y H:i',
-												datepicker: true,
-												dayOfWeekStart: 1,
-												timepicker: true,
-												closeOnDateSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect,
-												closeOnTimeSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect,
-												weeks: data.amsDatetimepickerWeeks
-											};
-											var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions);
-											settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings;
-											var plugin = input.datetimepicker(settings);
-											ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings);
-										});
+										ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css',
+												   'jquery-datetimepicker',
+												   function () {
+													   datetimepickers.each(function () {
+														   var input = $(this);
+														   var data = input.data();
+														   var dataOptions = {
+															   lang: data.amsDatetimepickerLang || ams.lang,
+															   format: data.amsDatetimepickerFormat || 'd/m/y H:i',
+															   datepicker: true,
+															   dayOfWeekStart: 1,
+															   timepicker: true,
+															   closeOnDateSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect,
+															   closeOnTimeSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect,
+															   weeks: data.amsDatetimepickerWeeks
+														   };
+														   var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions);
+														   settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings;
+														   var plugin = input.datetimepicker(settings);
+														   ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings);
+													   });
+												   });
 								   });
 				}
 			},
@@ -3528,24 +3756,27 @@
 								   ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js',
 								   function(first_load) {
 										if (first_load) {
-											ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', 'jquery-datetimepicker');
 											ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback);
 										}
-										timepickers.each(function() {
-											var input = $(this);
-											var data = input.data();
-											var dataOptions = {
-												lang: data.amsDatetimepickerLang || ams.lang,
-												format: data.amsDatetimepickerFormat || 'H:i',
-												datepicker: false,
-												timepicker: true,
-												closeOnTimeSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect
-											};
-											var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions);
-											settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings;
-											var plugin = input.datetimepicker(settings);
-											ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings);
-										});
+										ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css',
+												   'jquery-datetimepicker',
+												   function() {
+													   timepickers.each(function () {
+														   var input = $(this);
+														   var data = input.data();
+														   var dataOptions = {
+															   lang: data.amsDatetimepickerLang || ams.lang,
+															   format: data.amsDatetimepickerFormat || 'H:i',
+															   datepicker: false,
+															   timepicker: true,
+															   closeOnTimeSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect
+														   };
+														   var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions);
+														   settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings;
+														   var plugin = input.datetimepicker(settings);
+														   ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings);
+													   });
+												   });
 								   });
 				}
 			},
@@ -3558,21 +3789,52 @@
 				if (colorpickers.length > 0) {
 					ams.ajax.check($.fn.minicolors,
 								   ams.baseURL + 'ext/jquery-minicolors' + ams.devext + '.js',
-								   function(first_load) {
-										if (first_load) {
-											ams.getCSS(ams.baseURL + '../css/ext/jquery-minicolors' + ams.devext + '.css', 'jquery-minicolors');
-										}
-										colorpickers.each(function() {
-											var input = $(this);
-											var data = input.data();
-											var dataOptions = {
-												position: data.amsColorpickerPosition || input.closest('label.input').data('ams-colorpicker-position') || 'bottom left'
-											};
-											var settings = $.extend({}, dataOptions, data.amsColorpickerOptions);
-											settings = ams.executeFunctionByName(data.amsColorpickerInitCallback, input, settings) || settings;
-											var plugin = input.minicolors(settings);
-											ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings);
-										});
+								   function() {
+										ams.getCSS(ams.baseURL + '../css/ext/jquery-minicolors' + ams.devext + '.css',
+												   'jquery-minicolors',
+												   function () {
+													   colorpickers.each(function () {
+														   var input = $(this);
+														   var data = input.data();
+														   var dataOptions = {
+															   position: data.amsColorpickerPosition || input.closest('label.input').data('ams-colorpicker-position') || 'bottom left'
+														   };
+														   var settings = $.extend({}, dataOptions, data.amsColorpickerOptions);
+														   settings = ams.executeFunctionByName(data.amsColorpickerInitCallback, input, settings) || settings;
+														   var plugin = input.minicolors(settings);
+														   ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings);
+													   });
+												   });
+								   });
+				}
+			},
+
+			/**
+			 * Drag & drop upload plug-in
+			 */
+			dndupload: function(element) {
+				var uploads = $('.dndupload', element);
+				if (uploads.length > 0) {
+					ams.ajax.check($.fn.dndupload,
+								   ams.baseURL + 'ext/jquery-dndupload' + ams.devext + '.js',
+								   function() {
+										ams.getCSS(ams.baseURL + '../css/ext/jquery-dndupload' + ams.devext + '.css',
+												   'jquery-dndupload',
+												   function () {
+													   uploads.each(function () {
+														   var upload = $(this);
+														   var data = upload.data();
+														   var dataOptions = {
+															   action: data.amsDnduploadAction || upload.attr('action') || 'upload-files',
+															   fieldname: data.amsDnduploadFieldname || 'files',
+															   autosubmit: data.amsDnduploadAutosubmit
+														   };
+														   var settings = $.extend({}, dataOptions, data.amsDnduploadOptions);
+														   settings = ams.executeFunctionByName(data.amsDnduploadInitCallback, upload, settings) || settings;
+														   var plugin = upload.dndupload(settings);
+														   ams.executeFunctionByName(data.amsDnduploadAfterInitcallback, upload, plugin, settings);
+													   });
+												   });
 								   });
 				}
 			},
@@ -3680,7 +3942,7 @@
 				if (tables.length > 0) {
 					ams.ajax.check($.fn.dataTable,
 								   ams.baseURL + 'ext/jquery-dataTables-1.9.4' + ams.devext + '.js',
-								   function(first_load) {
+								   function() {
 										ams.ajax.check($.fn.dataTableExt.oPagination.bootstrap_full,
 													   ams.baseURL + 'myams-dataTables' + ams.devext + '.js',
 													   function() {
@@ -3724,8 +3986,10 @@
 																   var sortable = sortables[index];
 																   if (sortable !== undefined) {
 																	   column = columns[index] || {};
-																	   column.bSortable = sortable;
+																	   column.bSortable = typeof(sortable) === 'string' ? JSON.parse(sortable) : sortable;
 																	   columns[index] = column;
+																   } else {
+																	   columns[index] = columns[index] || {};
 																   }
 															   }
 															   // Check columns types
@@ -3736,11 +4000,16 @@
 																	   column = columns[index] || {};
 																	   column.sType = sortType;
 																	   columns[index] = column;
+																   } else {
+																	   columns[index] = columns[index] || {};
 																   }
 															   }
 															   // Set options
 															   var dataOptions = {
 																   bJQueryUI: false,
+																   bServerSide: data.amsDatatableServerSide || false,
+																   sAjaxSource: data.amsDatatableServerSide === true ? data.amsDatatableAjaxSource : undefined,
+																   sServerMethod: data.amsDatatableServerSide === true ? 'POST' : undefined,
 																   bFilter: data.amsDatatableGlobalFilter !== false || extensions.indexOf('columnfilter') >= 0,
 																   bPaginate: data.amsDatatablePagination !== false,
 																   bInfo: data.amsDatatableInfo !== false,
@@ -3812,7 +4081,7 @@
 																			   sources.push(ams.baseURL + 'ext/jquery-dataTables-keyTable' + ams.devext + '.js');
 																			   break;
 																		   case 'rowgrouping':
-																			   checkers.push($.fn.rowGrouping());
+																			   checkers.push($.fn.rowGrouping);
 																			   sources.push(ams.baseURL + 'ext/jquery-dataTables-rowGrouping' + ams.devext + '.js');
 																			   break;
 																		   case 'rowreordering':
@@ -3934,7 +4203,7 @@
 				if (tables.length > 0) {
 					ams.ajax.check($.fn.tableDnD,
 								   ams.baseURL + 'ext/jquery-tablednd' + ams.devext + '.js',
-								   function(first_load) {
+								   function() {
 										tables.each(function() {
 											var table = $(this);
 											var data = table.data();
@@ -3958,29 +4227,32 @@
 													if (target) {
 														// Disable row click handler
 														$(row).data('ams-disabled-handlers', 'click');
-														var rows = [];
-														$(dnd_table.rows).each(function() {
-															var rowId = $(this).data('ams-element-name');
-															if (rowId) {
-																rows.push(rowId);
+														try {
+															var rows = [];
+															$(dnd_table.rows).each(function() {
+																var rowId = $(this).data('ams-element-name');
+																if (rowId) {
+																	rows.push(rowId);
+																}
+															});
+															var localTarget = ams.getFunctionByName(target);
+															if (typeof(localTarget) === 'function') {
+																localTarget.call(table, dnd_table, rows);
+															} else {
+																if (!target.startsWith(window.location.protocol)) {
+																	var location = data.amsLocation;
+																	if (location) {
+																		target = location + '/' + target;
+																	}
+																}
+																ams.ajax.post(target, {names: JSON.stringify(rows)});
 															}
-														});
-														var localTarget = ams.getFunctionByName(target);
-														if (typeof(localTarget) === 'function') {
-															localTarget.call(table, dnd_table, rows);
-														} else {
-															if (!target.startsWith(window.location.protocol)) {
-																var location = data.amsLocation;
-																if (location) {
-																	target = location + '/' + target;
-																}
-															}
-															ams.ajax.post(target, {names: JSON.stringify(rows)});
+														} finally {
+															// Restore row click handler
+															setTimeout(function() {
+																$(row).removeData('ams-disabled-handlers');
+															}, 50);
 														}
-														// Restore row click handler
-														setTimeout(function() {
-															$(row).removeData('ams-disabled-handlers');
-														}, 50);
 													}
 													return false;
 												}
@@ -4002,7 +4274,7 @@
 				if (wizards.length > 0) {
 					ams.ajax.check($.fn.bootstrapWizard,
 								   ams.baseURL + 'ext/bootstrap-wizard-1.4.2' + ams.devext + '.js',
-								   function(first_load) {
+								   function() {
 										wizards.each(function() {
 											var wizard = $(this);
 											var data = wizard.data();
@@ -4064,14 +4336,22 @@
 												var dataOptions = {
 													theme: data.amsTinymceTheme || "modern",
 													language: ams.lang,
-													plugins: [
-														"advlist autosave autolink lists link image charmap print preview hr anchor pagebreak",
+													menubar: data.amsTinymceMenubar !== false,
+													statusbar: data.amsTinymceStatusbar !== false,
+													plugins: data.amsTinymcePlugins || [
+														"advlist autosave autolink lists link charmap print preview hr anchor pagebreak",
 														"searchreplace wordcount visualblocks visualchars code fullscreen",
-														"insertdatetime media nonbreaking save table contextmenu directionality",
+														"insertdatetime nonbreaking save table contextmenu directionality",
 														"emoticons paste textcolor colorpicker textpattern autoresize"
 													],
-													toolbar1: data.amsTinymceToolbar1 || "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",
-													toolbar2: data.amsTinymceToolbar2 || "forecolor backcolor emoticons | charmap link image media | fullscreen preview print | code",
+													toolbar: data.amsTinymceToolbar,
+													toolbar1: data.amsTinymceToolbar1 === false ? false : data.amsTinymceToolbar1 ||
+														"undo redo | styleselect | bold italic | alignleft " +
+														"aligncenter alignright alignjustify | bullist numlist " +
+														"outdent indent",
+													toolbar2: data.amsTinymceToolbar2 === false ? false : data.amsTinymceToolbar2 ||
+														"forecolor backcolor emoticons | charmap link image media | " +
+														"fullscreen preview print | code",
 													content_css: data.amsTinymceContentCss,
 													formats: data.amsTinymceFormats,
 													style_formats: data.amsTinymceStyleFormats,
@@ -4091,6 +4371,9 @@
 												if (data.amsTinymceExternalPlugins) {
 													var names = data.amsTinymceExternalPlugins.split(/\s+/);
 													for (var index in names) {
+														if (!names.hasOwnProperty(index)) {
+															continue;
+														}
 														var pluginSrc = editor.data('ams-tinymce-plugin-' + names[index]);
 														tinymce.PluginManager.load(names[index], ams.getSource(pluginSrc));
 													}
@@ -4124,44 +4407,45 @@
 				if (images.length > 0) {
 					ams.ajax.check($.fn.imgAreaSelect,
 								   ams.baseURL + 'ext/jquery-imgareaselect-0.9.11-rc1' + ams.devext + '.js',
-								   function(first_load) {
-									   if (first_load) {
-										   ams.getCSS(ams.baseURL + '../css/ext/jquery-imgareaselect' + ams.devext + '.css');
-									   }
-									   images.each(function() {
-										   var image = $(this);
-										   var data = image.data();
-										   var parent = data.amsImgareaselectParent ? image.parents(data.amsImgareaselectParent) : 'body';
-										   var dataOptions = {
-											   instance: true,
-											   handles: true,
-											   parent: parent,
-											   x1: data.amsImgareaselectX1 || 0,
-											   y1: data.amsImgareaselectY1 || 0,
-											   x2: data.amsImgareaselectX2 || data.amsImgareaselectImageWidth,
-											   y2: data.amsImgareaselectY2 || data.amsImgareaselectImageHeight,
-											   imageWidth: data.amsImgareaselectImageWidth,
-											   imageHeight: data.amsImgareaselectImageHeight,
-											   minWidth: 128,
-											   minHeight: 128,
-											   aspectRatio: data.amsImgareaselectRatio,
-											   onSelectEnd: ams.getFunctionByName(data.amsImgareaselectSelectEnd) || function(img, selection) {
-												   var target = data.amsImgareaselectTargetField || 'image_';
-												   $('input[name="' + target + 'x1"]', parent).val(selection.x1);
-												   $('input[name="' + target + 'y1"]', parent).val(selection.y1);
-												   $('input[name="' + target + 'x2"]', parent).val(selection.x2);
-												   $('input[name="' + target + 'y2"]', parent).val(selection.y2);
-											   }
-										   };
-										   var settings = $.extend({}, dataOptions, data.amsImgareaselectOptions);
-										   settings = ams.executeFunctionByName(data.amsImgareaselectInitCallback, image, settings) || settings;
-										   var plugin = image.imgAreaSelect(settings);
-										   ams.executeFunctionByName(data.amsImgareaselectAfterInitCallback, image, plugin, settings);
-										   // Add update timeout when plug-in is displayed into a modal dialog
-										   setTimeout(function() {
-											   plugin.update();
-										   }, 250);
-									   });
+								   function() {
+										ams.getCSS(ams.baseURL + '../css/ext/jquery-imgareaselect' + ams.devext + '.css',
+												  'jquery-imgareaselect',
+												   function() {
+													   images.each(function () {
+														   var image = $(this);
+														   var data = image.data();
+														   var parent = data.amsImgareaselectParent ? image.parents(data.amsImgareaselectParent) : 'body';
+														   var dataOptions = {
+															   instance: true,
+															   handles: true,
+															   parent: parent,
+															   x1: data.amsImgareaselectX1 || 0,
+															   y1: data.amsImgareaselectY1 || 0,
+															   x2: data.amsImgareaselectX2 || data.amsImgareaselectImageWidth,
+															   y2: data.amsImgareaselectY2 || data.amsImgareaselectImageHeight,
+															   imageWidth: data.amsImgareaselectImageWidth,
+															   imageHeight: data.amsImgareaselectImageHeight,
+															   minWidth: 128,
+															   minHeight: 128,
+															   aspectRatio: data.amsImgareaselectRatio,
+															   onSelectEnd: ams.getFunctionByName(data.amsImgareaselectSelectEnd) || function (img, selection) {
+																   var target = data.amsImgareaselectTargetField || 'image_';
+																   $('input[name="' + target + 'x1"]', parent).val(selection.x1);
+																   $('input[name="' + target + 'y1"]', parent).val(selection.y1);
+																   $('input[name="' + target + 'x2"]', parent).val(selection.x2);
+																   $('input[name="' + target + 'y2"]', parent).val(selection.y2);
+															   }
+														   };
+														   var settings = $.extend({}, dataOptions, data.amsImgareaselectOptions);
+														   settings = ams.executeFunctionByName(data.amsImgareaselectInitCallback, image, settings) || settings;
+														   var plugin = image.imgAreaSelect(settings);
+														   ams.executeFunctionByName(data.amsImgareaselectAfterInitCallback, image, plugin, settings);
+														   // Add update timeout when plug-in is displayed into a modal dialog
+														   setTimeout(function () {
+															   plugin.update();
+														   }, 250);
+													   });
+												   });
 								   });
 				}
 			},
@@ -4174,90 +4458,141 @@
 				if (fancyboxes.length > 0) {
 					ams.ajax.check($.fn.fancybox,
 								   ams.baseURL + 'ext/jquery-fancybox-2.1.5' + ams.devext + '.js',
-								   function(first_load) {
-										if (first_load) {
-											ams.getCSS(ams.baseURL + '../css/ext/jquery-fancybox-2.1.5' + ams.devext + '.css');
-										}
-										fancyboxes.each(function() {
-											var fancybox = $(this);
-											var data = fancybox.data();
-											var elements = fancybox;
-											if (data.amsFancyboxElements) {
-												elements = $(data.amsFancyboxElements, fancybox);
+								   function() {
+										ams.getCSS(ams.baseURL + '../css/ext/jquery-fancybox-2.1.5' + ams.devext + '.css',
+											'jquery-fancybox',
+											function() {
+												fancyboxes.each(function () {
+													var fancybox = $(this);
+													var data = fancybox.data();
+													var elements = fancybox;
+													var index,
+														helper;
+													if (data.amsFancyboxElements) {
+														elements = $(data.amsFancyboxElements, fancybox);
+													}
+													var helpers = (data.amsFancyboxHelpers || '').split(/\s+/);
+													if (helpers.length > 0) {
+														for (index = 0; index < helpers.length; index++) {
+															helper = helpers[index];
+															switch (helper) {
+																case 'buttons':
+																	ams.ajax.check($.fancybox.helpers.buttons,
+																		ams.baseURL + 'ext/fancybox-helpers/fancybox-buttons' + ams.devext + '.js');
+																	break;
+																case 'thumbs':
+																	ams.ajax.check($.fancybox.helpers.thumbs,
+																		ams.baseURL + 'ext/fancybox-helpers/fancybox-thumbs' + ams.devext + '.js');
+																	break;
+																case 'media':
+																	ams.ajax.check($.fancybox.helpers.media,
+																		ams.baseURL + 'ext/fancybox-helpers/fancybox-media' + ams.devext + '.js');
+																	break;
+																default:
+																	break;
+															}
+														}
+													}
+													var dataOptions = {
+														type: data.amsFancyboxType,
+														padding: data.amsFancyboxPadding || 10,
+														margin: data.amsFancyboxMargin || 10,
+														loop: data.amsFancyboxLoop,
+														beforeLoad: ams.getFunctionByName(data.amsFancyboxBeforeLoad) || function () {
+															var title;
+															if (data.amsFancyboxTitleGetter) {
+																title = ams.executeFunctionByName(data.amsFancyboxTitleGetter, this);
+															}
+															if (!title) {
+																var content = $('*:first', this.element);
+																title = content.attr('original-title') || content.attr('title');
+																if (!title) {
+																	title = $(this.element).attr('original-title') || $(this.element).attr('title');
+																}
+															}
+															this.title = title;
+														},
+														afterLoad: ams.getFunctionByName(data.amsFancyboxAfterLoad),
+														helpers: {
+															title: {
+																type: 'inside'
+															}
+														}
+													};
+													if (helpers.length > 0) {
+														for (index = 0; index < helpers.length; index++) {
+															helper = helpers[index];
+															switch (helper) {
+																case 'buttons':
+																	dataOptions.helpers.buttons = {
+																		position: data.amsFancyboxButtonsPosition || 'top'
+																	};
+																	break;
+																case 'thumbs':
+																	dataOptions.helpers.thumbs = {
+																		width: data.amsFancyboxThumbsWidth || 50,
+																		height: data.amsFancyboxThumbsHeight || 50
+																	};
+																	break;
+																case 'media':
+																	dataOptions.helpers.media = true;
+																	break;
+															}
+														}
+													}
+													var settings = $.extend({}, dataOptions, data.amsFancyboxOptions);
+													settings = ams.executeFunctionByName(data.amsFancyboxInitCallback, fancybox, settings) || settings;
+													var plugin = elements.fancybox(settings);
+													ams.executeFunctionByName(data.amsFancyboxAfterInitCallback, fancybox, plugin, settings);
+												});
+											});
+								   });
+				}
+			},
+
+			/**
+			 * Flot charts
+			 */
+			chart: function(element) {
+				var charts = $('.chart', element);
+				if (charts.length > 0) {
+					ams.ajax.check($.fn.plot,
+								   ams.baseURL + 'flot/jquery.flot' + ams.devext + '.js',
+								   function() {
+										charts.each(function() {
+
+											function checkPlugin(plugin) {
+												for (var index in $.plot.plugins) {
+													if ($.plot.plugins.hasOwnProperty(index)) {
+														var pluginInfo = $.plot.plugins[index];
+														if (pluginInfo.name === plugin) {
+															return pluginInfo;
+														}
+													}
+												}
+												return null;
 											}
-											var helpers = (data.amsFancyboxHelpers || '').split(/\s+/);
-											if (helpers.length > 0) {
-												for (var index=0; index < helpers.length; index++) {
-													var helper = helpers[index];
-													switch (helper) {
-														case 'buttons':
-															ams.ajax.check($.fancybox.helpers.buttons,
-																		   ams.baseURL + 'ext/fancybox-helpers/fancybox-buttons' + ams.devext + '.js');
-															break;
-														case 'thumbs':
-															ams.ajax.check($.fancybox.helpers.thumbs,
-																		   ams.baseURL + 'ext/fancybox-helpers/fancybox-thumbs' + ams.devext + '.js');
-															break;
-														case 'media':
-															ams.ajax.check($.fancybox.helpers.media,
-																		   ams.baseURL + 'ext/fancybox-helpers/fancybox-media' + ams.devext + '.js');
-															break;
-														default:
-															break;
+
+											var chart = $(this);
+											var data = chart.data();
+											var dataOptions = {};
+											var plugins = (data.amsChartPlugins || '').split(/\s+/);
+											if (plugins.length > 0) {
+												for (var index in plugins) {
+													if (plugins.hasOwnProperty(index)) {
+														var pluginName = plugins[index];
+														if (!checkPlugin(pluginName)) {
+															ams.getScript(ams.baseURL + 'flot/jquery.flot.' + pluginName + ams.devext + '.js');
+														}
 													}
 												}
 											}
-											var dataOptions = {
-												type: data.amsFancyboxType,
-												padding: data.amsFancyboxPadding || 10,
-												margin: data.amsFancyboxMargin || 10,
-												loop: data.amsFancyboxLoop,
-												beforeLoad: ams.getFunctionByName(data.amsFancyboxBeforeLoad) || function() {
-													var title;
-													if (data.amsFancyboxTitleGetter) {
-														title = ams.executeFunctionByName(data.amsFancyboxTitleGetter, this);
-													}
-													if (!title) {
-														var content = $('*:first', this.element);
-														title = content.attr('original-title') || content.attr('title');
-														if (!title) {
-															title = $(this.element).attr('original-title') || $(this.element).attr('title');
-														}
-													}
-													this.title = title;
-												},
-												afterLoad: ams.getFunctionByName(data.amsFancyboxAfterLoad),
-												helpers: {
-													title: {
-														type: 'inside'
-													}
-												}
-											};
-											if (helpers.length > 0) {
-												for (index = 0; index < helpers.length; index++) {
-													helper = helpers[index];
-													switch (helper) {
-														case 'buttons':
-															dataOptions.helpers.buttons = {
-																position: data.amsFancyboxButtonsPosition || 'top'
-															};
-															break;
-														case 'thumbs':
-															dataOptions.helpers.thumbs = {
-																width: data.amsFancyboxThumbsWidth || 50,
-																height: data.amsFancyboxThumbsHeight || 50
-															};
-															break;
-														case 'media':
-															dataOptions.helpers.media = true;
-															break;
-													}
-												}
-											}
-											var settings = $.extend({}, dataOptions, data.amsFancyboxOptions);
-											settings = ams.executeFunctionByName(data.amsFancyboxInitCallback, fancybox, settings) || settings;
-											var plugin = elements.fancybox(settings);
-											ams.executeFunctionByName(data.amsFancyboxAfterInitCallback, fancybox, plugin, settings);
+											var settings = $.extend({}, dataOptions, data.amsChartOptions);
+											settings = ams.executeFunctionByName(data.amsChartInitCallback, chart, settings) || settings;
+											var chartData = data.amsChartData;
+											chartData = ams.executeFunctionByName(data.amsChartInitData, chart, chartData) || chartData;
+											var plugin = chart.plot(chartData, settings);
+											ams.executeFunctionByName(data.amsChartAfterInitCallback, chart, plugin, settings);
 										});
 								   });
 				}
@@ -4288,22 +4623,22 @@
 								   function() {
 										ams.ajax.check($.fn.mCustomScrollbar,
 													   ams.baseURL + 'ext/jquery-mCustomScrollbar' + ams.devext + '.js',
-													   function(first_load) {
-															if (first_load) {
-																ams.getCSS(ams.baseURL + '../css/ext/jquery-mCustomScrollbar.css',
-																		   'jquery-mCustomScrollbar');
-															}
-															scrollbars.each(function() {
-																var scrollbar = $(this);
-																var data = scrollbar.data();
-																var dataOptions = {
-																	theme: data.amsScrollbarTheme || 'light'
-																};
-																var settings = $.extend({}, dataOptions, data.amsScrollbarOptions);
-																settings = ams.executeFunctionByName(data.amsScrollbarInitCallback, scrollbar, settings) || settings;
-																var plugin = scrollbar.mCustomScrollbar(settings);
-																ams.executeFunctionByName(data.amsScrollbarAfterInitCallback, scrollbar, plugin, settings);
-															});
+													   function() {
+															ams.getCSS(ams.baseURL + '../css/ext/jquery-mCustomScrollbar.css',
+																	   'jquery-mCustomScrollbar',
+																	   function () {
+																		   scrollbars.each(function () {
+																			   var scrollbar = $(this);
+																			   var data = scrollbar.data();
+																			   var dataOptions = {
+																				   theme: data.amsScrollbarTheme || 'light'
+																			   };
+																			   var settings = $.extend({}, dataOptions, data.amsScrollbarOptions);
+																			   settings = ams.executeFunctionByName(data.amsScrollbarInitCallback, scrollbar, settings) || settings;
+																			   var plugin = scrollbar.mCustomScrollbar(settings);
+																			   ams.executeFunctionByName(data.amsScrollbarAfterInitCallback, scrollbar, plugin, settings);
+																		   });
+																	   });
 													   });
 									});
 				}
@@ -4483,10 +4818,9 @@
 		/**
 		 * Delete an element from a container table
 		 *
-		 * @param element
 		 * @returns {Function}
 		 */
-		deleteElement: function(element) {
+		deleteElement: function() {
 			return function() {
 				var link = $(this);
 				MyAMS.skin.bigBox({
@@ -4496,12 +4830,15 @@
 					buttons: ams.i18n.BTN_OK_CANCEL
 				}, function(button) {
 					if (button === ams.i18n.BTN_OK) {
-						var table = link.parents('table').first();
-						var location = table.data('ams-location') || '';
 						var tr = link.parents('tr').first();
+						var table = tr.parents('table').first();
+						var location = tr.data('ams-location') || table.data('ams-location') || '';
+						if (location) {
+							location += '/';
+						}
 						var deleteTarget = tr.data('ams-delete-target') || table.data('ams-delete-target') || 'delete-element.json';
 						var objectName = tr.data('ams-element-name');
-						MyAMS.ajax.post(location + '/' + deleteTarget, {'object_name': objectName}, function(result, status) {
+						MyAMS.ajax.post(location + deleteTarget, {'object_name': objectName}, function(result, status) {
 							if (result.status === 'success') {
 								if (table.hasClass('datatable')) {
 									table.dataTable().fnDeleteRow(tr[0]);
@@ -4518,6 +4855,251 @@
 					}
 				});
 			};
+		},
+
+		/**
+		 * Switch element visibility
+		 */
+		switchElementVisibility: function() {
+			return function() {
+				var source = $(this);
+				var element = source.parents('tr').first();
+				var container = element.parents('table');
+				ams.ajax.post(container.data('ams-location') + '/' +
+							  container.data('ams-visibility-switcher'),
+					{object_name: element.data('ams-element-name')},
+					function(result, status) {
+						if (result.visible) {
+							$('i', source).attr('class', 'fa fa-fw fa-eye');
+						} else {
+							$('i', source).attr('class', 'fa fa-fw fa-eye-slash text-danger');
+						}
+					});
+			}
+		}
+	};
+
+
+	/**
+	 * Tree management
+	 */
+	MyAMS.tree = {
+
+		/**
+		 * Open close tree node inside a table
+		 */
+		switchTableNode: function() {
+
+			function removeChildNodes(node_id) {
+				$('tr[data-ams-tree-node-parent-id="' + node_id + '"]').each(function() {
+					var row = $(this);
+					removeChildNodes(row.data('ams-tree-node-id'));
+					row.remove();
+				})
+			}
+
+			var node = $(this);
+			var switcher = $('i.switch', node);
+			var tr = node.parents('tr').first();
+			var table = tr.parents('table').first();
+			if (switcher.hasClass('fa-minus-square-o')) {
+				removeChildNodes(tr.data('ams-tree-node-id'));
+				switcher.removeClass('fa-minus-square-o')
+						.addClass('fa-plus-square-o');
+			} else {
+				var location = tr.data('ams-location') || table.data('ams-location') || '';
+				var treeNodesTarget = tr.data('ams-tree-nodes-target') || table.data('ams-tree-nodes-target') || 'get-tree-nodes.json';
+				var sourceName = tr.data('ams-element-name');
+				switcher.removeClass('fa-plus-square-o')
+						.addClass('fa-cog fa-spin');
+				MyAMS.ajax.post(location + '/' + sourceName + '/' + treeNodesTarget, {
+					can_sort: !$('td.sorter', tr).is(':empty')
+				}, function(result, status) {
+					if (result.length > 0) {
+						var old_row = tr;
+						for (var index = 0; index < result.length; index++) {
+							var new_row = $(result[index]);
+							new_row.insertAfter(old_row)
+								   .addClass('no-drag-handle');
+							ams.initContent(new_row);
+							old_row = new_row;
+						}
+						if (table.hasClass('table-dnd')) {
+							table.tableDnDUpdate();
+						}
+					}
+					switcher.removeClass('fa-cog fa-spin')
+							.addClass('fa-minus-square-o');
+				});
+			}
+		},
+
+		/**
+		 * Open close all tree nodes
+		 */
+		switchTree: function() {
+			var th = $(this);
+			var switcher = $('i.switch', th);
+			var table = $(this).parents('table').first();
+			var tableID = table.data('ams-tree-node-id');
+			if (switcher.hasClass('fa-minus-square-o')) {
+				$('tr[data-ams-tree-node-parent-id]').filter('tr[data-ams-tree-node-parent-id!="' + tableID + '"]').remove();
+				$('i.switch', table).removeClass('fa-minus-square-o')
+									.addClass('fa-plus-square-o');
+			} else {
+				var tr = $('tbody tr', table).first();
+				var location = table.data('ams-location') || '';
+				var target = table.data('ams-tree-nodes-target') || 'get-tree.json';
+				switcher.removeClass('fa-plus-square-o')
+						.addClass('fa-cog fa-spin');
+				MyAMS.ajax.post(location + '/' + target, {
+					can_sort: !$('td.sorter', tr).is(':empty')
+				}, function(result, status) {
+					$('tr[data-ams-tree-node-id]', table).remove();
+					var old_row = null;
+					for (var index = 0; index < result.length; index++) {
+						var new_row = $(result[index]);
+						if (old_row === null) {
+							new_row.appendTo($('tbody', table));
+						} else {
+							new_row.insertAfter(old_row);
+						}
+						new_row.addClass('no-drag-handle');
+						ams.initContent(new_row);
+						old_row = new_row;
+					}
+					if (table.hasClass('table-dnd')) {
+						table.tableDnDUpdate();
+					}
+					$('i.switch', table).removeClass('fa-plus-square-o')
+										.addClass('fa-minus-square-o');
+					switcher.removeClass('fa-cog fa-spin')
+							.addClass('fa-minus-square-o');
+				});
+			}
+		},
+
+		/**
+		 * Sort and re-parent tree elements
+		 */
+		sortTree: function(dnd_table, row) {
+			var data = $(dnd_table).data();
+			var target = data.amsTabledndDropTarget;
+			if (target) {
+				// Disable row click handler
+				row = $(row);
+				row.data('ams-disabled-handlers', 'click');
+				try {
+					// Get root ID
+					var tableID = row.parents('table').first().data('ams-tree-node-id');
+					// Get moved row ID
+					var rowID = row.data('ams-tree-node-id');
+					var rowParentID = row.data('ams-tree-node-parent-id');
+					// Get new parent ID
+					var parent = row.prev('tr');
+					if (parent.exists()) {
+						// Move below an existing row
+						var parentID = parent.data('ams-tree-node-id');
+						// Check switcher state
+						var switcher = $('.switch', parent);
+						if (switcher.hasClass('fa-minus-square-o')) {
+							// Opened folder: move as child
+							if (rowParentID === parentID) {
+								// Don't change parent
+								var action = 'reorder';
+							} else {
+								// Change parent
+								action = 'reparent';
+							}
+						} else {
+							// Closed folder or simple item: move as sibling
+							parentID = parent.data('ams-tree-node-parent-id');
+							if (rowParentID === parentID) {
+								// Don't change parent
+								action = 'reorder';
+							} else {
+								// Change parent
+								action = 'reparent';
+							}
+						}
+					} else {
+						// Move to site root
+						parentID = tableID;
+						switcher = null;
+						if (rowParentID === parentID) {
+							// Already child of site root
+							action = 'reorder';
+						} else {
+							// Move from inner folder to site root
+							action = 'reparent';
+						}
+					}
+					// Call ordering target
+					var localTarget = ams.getFunctionByName(target);
+					if (typeof(localTarget) === 'function') {
+						localTarget.call(table, dnd_table, post_data);
+					} else {
+						if (!target.startsWith(window.location.protocol)) {
+							var location = data.amsLocation;
+							if (location) {
+								target = location + '/' + target;
+							}
+						}
+						var post_data = {
+							action: action,
+							child: rowID,
+							parent: parentID,
+							order: JSON.stringify($('tr[data-ams-tree-node-id]').listattr('data-ams-tree-node-id')),
+							can_sort: !$('td.sorter', row).is(':empty')
+						};
+						ams.ajax.post(target, post_data, function(result) {
+
+							function removeChildRows(rowID) {
+								var childs = $('tr[data-ams-tree-node-parent-id="' + rowID + '"]');
+								childs.each(function() {
+									var childRow = $(this);
+									var childID = childRow.attr('data-ams-tree-node-id');
+									removeChildRows(childID);
+									childRow.remove();
+								});
+							}
+
+							if (result.status) {
+								ams.ajax.handleJSON(result);
+							} else {
+								// Remove moved row childrens
+								var body = $(row).parents('tbody').first();
+								removeChildRows(rowID);
+								if (post_data.action === 'reparent') {
+									// Remove new parent childrens
+									removeChildRows(parentID);
+									row.remove();
+									var old_row = $('tr[data-ams-tree-node-id="' + parentID + '"]');
+									for (var index = 0; index < result.length; index++) {
+										var new_row = $(result[index]);
+										if (old_row.exists()) {
+											new_row.insertAfter(old_row)
+												.addClass('no-drag-handle');
+										} else {
+											new_row.prependTo(body)
+												.addClass('no-drag-handle');
+										}
+										ams.initContent(new_row);
+										old_row = new_row;
+									}
+								}
+								$('tr').parents('table').tableDnDUpdate();
+							}
+						});
+					}
+				} finally {
+					// Restore row click handler
+					setTimeout(function() {
+						$(row).removeData('ams-disabled-handlers');
+					}, 50);
+				}
+			}
+			return false;
 		}
 	};
 
@@ -4595,6 +5177,89 @@
 		},
 
 		/**
+		 * Replace given form with new content
+		 */
+		refreshContent: function(changes) {
+			var target = $('[id="' + changes.object_id + '"]');
+			target.replaceWith($(changes.content));
+			target = $('[id="' + changes.object_id + '"]');
+			MyAMS.initContent(target);
+			return target;
+		},
+
+		/**
+		 * Replace given widget with given content
+		 */
+		refreshWidget: function(changes) {
+			var target = $('[id="' + changes.parent_id + '"]');
+			var widget = $('[name="' + changes.widget_name + '"]', target);
+			if (!widget.exists()) {
+				widget = $('[name="' + changes.widget_name + ':list"]', target);
+			}
+			var label = widget.parents('label.input').last();
+			label.html(changes.content);
+			MyAMS.initContent(label);
+			return label;
+		},
+
+		/**
+		 * Replace given table with new content
+		 */
+		refreshTable: function(changes) {
+			var widget = $('[id="' + changes.object_id + '"]').parents('.ams-widget:first');
+			widget.replaceWith($(changes.table));
+			widget = $('[id="' + changes.object_id + '"]').parents('.ams-widget:first');
+			MyAMS.initContent(widget);
+			return widget;
+		},
+
+		/**
+		 * Replace given table with new content
+		 * If table is located inside a switched fieldset, fieldset is opened
+		 *
+		 * @param changes
+		 */
+		refreshSwitchedTable: function(changes) {
+			var widget = ams.skin.refreshTable(changes);
+			var legend = widget.siblings('legend');
+			if (legend.parents('fieldset:first').hasClass('switched')) {
+				legend.click();
+			}
+		},
+
+		/**
+		 * Replace given row with new content
+		 */
+		refreshRow: function(changes) {
+			var tr = $('tr[id="' + changes.object_id + '"]');
+			var table = tr.parents('table').first();
+			var new_tr = $(changes.row);
+			tr.replaceWith(new_tr);
+			MyAMS.initContent(new_tr);
+			if (table.hasClass('table-dnd')) {
+				new_tr.addClass('no-drag-handle');
+				table.tableDnDUpdate();
+			}
+			return new_tr;
+		},
+
+		/**
+		 * Replace given row cell with new content
+		 */
+		refreshRowCell: function(changes) {
+			var tr = $('tr[id="' + changes.object_id + '"]');
+			var table = tr.parents('table').first();
+			var headRow = $('tr', $('thead', table));
+			var headCell = $('th[data-ams-column-name="' + changes.col_name + '"]', headRow);
+			var index = $('th', headRow).index(headCell);
+			if (index > -1) {
+				var cell = $($('td', tr).get(index));
+				cell.html(changes.cell);
+				MyAMS.initContent(cell);
+			}
+		},
+
+		/**
 		 * Initialize desktop and mobile widgets
 		 */
 		_initDesktopWidgets: function(element) {
@@ -4661,13 +5326,9 @@
 				content += '</ul>';
 			}
 			content += '</div>';
-			var alert = $(content).prependTo(parent);
+			$(content).insertBefore(parent);
 			if (parent.exists) {
-				ams.ajax.check($.scrollTo,
-							   ams.baseURL + 'ext/jquery-scrollTo.min.js',
-							   function() {
-								   $.scrollTo(parent, {offset: {top: -50}});
-							   });
+				ams.skin.scrollTo(parent, {offset: {top: -50}});
 			}
 		},
 
@@ -4745,6 +5406,29 @@
 		},
 
 		/**
+		 * Scroll to given element
+		 *
+		 * @param element: the element to which to scroll
+		 * @param options: scroll options
+		 */
+		scrollTo: function(element, options) {
+			ams.ajax.check($.scrollTo,
+						   ams.baseURL + 'ext/jquery-scrollto-2.1.2' + ams.devext + '.js',
+						   function() {
+								var body = $('body');
+								var offset = options.offset || 0;
+								if (body.hasClass('fixed-header')) {
+									offset -= $('#header').height();
+								}
+								if (body.hasClass('fixed-ribbon')) {
+									offset -= $('#ribbon').height();
+								}
+								options = $.extend({}, options, {offset: offset});
+								$.scrollTo(element, options);
+						   });
+		},
+
+		/**
 		 * Initialize breadcrumbs based on active menu position
 		 */
 		_drawBreadCrumb: function() {
@@ -4934,10 +5618,13 @@
 						ams.stats.logPageview();
 					}
 				},
-				error: function(request, options, error) {
+				error: function(request, errorOptions, error) {
 					container.html('<h3 class="error"><i class="fa fa-warning txt-color-orangeDark"></i> ' +
 								   ams.i18n.ERROR + error + '</h3>' +
 								   request.responseText);
+					if (options && options.afterErrorCallback) {
+						ams.executeFunctionByName(options.afterErrorCallback, this);
+					}
 				},
 				async: options.async === undefined ? true : options.async
 			};
@@ -4948,7 +5635,7 @@
 		/**
 		 * Change user language
 		 */
-		setLanguage: function(options) {
+		setLanguage: function(event, options) {
 			var lang = options.lang;
 			var handlerType = options.handler_type || 'json';
 			switch (handlerType) {
@@ -5067,7 +5754,7 @@
 		}
 
 		// Hide menu button
-		$('#hide-menu >:first-child > A').click(function(e) {
+		$('#hide-menu').find('>:first-child >A').click(function(e) {
 			body.toggleClass("hidden-menu");
 			e.preventDefault();
 		});
@@ -5326,7 +6013,7 @@
 		});
 
 		// Initialize custom click handlers
-		$(document).on('click', '[data-ams-click-handler]', function(e) {
+		$(document).on('click', '[data-ams-click-handler]', function(event) {
 			var source = $(this);
 			var handlers = source.data('ams-disabled-handlers');
 			if ((handlers === true) || (handlers === 'click') || (handlers === 'all')) {
@@ -5335,20 +6022,20 @@
 			var data = source.data();
 			if (data.amsClickHandler) {
 				if ((data.amsStopPropagation === true) || (data.amsClickStopPropagation === true)) {
-					e.stopPropagation();
+					event.stopPropagation();
 				}
 				if (data.amsClickKeepDefault !== true) {
-					e.preventDefault();
+					event.preventDefault();
 				}
 				var callback = ams.getFunctionByName(data.amsClickHandler);
 				if (callback !== undefined) {
-					callback.call(source, data.amsClickHandlerOptions);
+					callback.call(source, event, data.amsClickHandlerOptions);
 				}
 			}
 		});
 
 		// Initialize custom change handlers
-		$(document).on('change', '[data-ams-change-handler]', function(e) {
+		$(document).on('change', '[data-ams-change-handler]', function(event) {
 			var source = $(this);
 			// Disable change handlers for readonly inputs
 			// These change handlers are activated by IE!!!
@@ -5361,16 +6048,26 @@
 			}
 			var data = source.data();
 			if (data.amsChangeHandler) {
+				if ((data.amsStopPropagation === true) || (data.amsChangeStopPropagation === true)) {
+					event.stopPropagation();
+				}
 				if (data.amsChangeKeepDefault !== true) {
-					e.preventDefault();
+					event.preventDefault();
 				}
 				var callback = ams.getFunctionByName(data.amsChangeHandler);
 				if (callback !== undefined) {
-					callback.call(source, data.amsChangeHandlerOptions);
+					callback.call(source, event, data.amsChangeHandlerOptions);
 				}
 			}
 		});
 
+		// Submit form when CTRL+Enter key is pressed in textarea
+		$(document).on('keydown', 'textarea', function(e) {
+			if ((e.keyCode === 10 || e.keyCode === 13) && (e.ctrlKey || e.metaKey)) {
+				$(this).closest('form').submit();
+			}
+		});
+
 		// Notify reset to update Select2 widgets
 		$(document).on('reset', 'form', function(e) {
 			var form = $(this);
@@ -5380,7 +6077,10 @@
 				$('INPUT.select2[type="hidden"]', form).each(function() {
 					var input = $(this);
 					var select = input.data('select2');
-					input.select2('val', input.data('ams-select2-input-value').split(select.opts.separator));
+					var value = input.data('ams-select2-input-value');
+					if (value) {
+						input.select2('val', value.split(select.opts.separator));
+					}
 				});
 				form.find('.select2').trigger('change');
 				$('[data-ams-reset-callback]', form).each(function() {
@@ -5410,6 +6110,12 @@
 			}
 		});
 
+		// Initialize custom event on click
+		$(document).on('click', '[data-ams-click-event]', function(e) {
+			var source = $(this);
+			$(e.target).trigger(source.data('ams-click-event'), source.data('ams-click-event-options'));
+		});
+
 		// Handle update on file upload placeholder
 		$(document).on('change', 'input[type="file"]', function(e) {
 			e.preventDefault();
@@ -5420,6 +6126,11 @@
 			}
 		});
 
+		// Always blur readonly inputs
+		$(document).on('focus', 'input[readonly="readonly"]', function() {
+			$(this).blur();
+		});
+
 		// Prevent bootstrap dialog from blocking TinyMCE focus
 		$(document).on('focusin', function(e) {
 			if ($(e.target).closest('.mce-window').length) {
@@ -5428,32 +6139,52 @@
 		});
 
 		// Disable clicks on disabled tabs
-		$("a[data-toggle=tab]", ".nav-tabs").on("click", function(e) {
+		$(document).on("click", '.nav-tabs a[data-toggle=tab]', function(e) {
 			if ($(this).parent('li').hasClass("disabled")) {
 				e.preventDefault();
 				return false;
 			}
 		});
 
+		// Automatically set orientation of dropdown menus
+		$(document).on('show.bs.dropdown', '.btn-group', function() {
+			var menu = $(this);
+			var ul = menu.children('.dropdown-menu');
+			var menuRect = menu.get(0).getBoundingClientRect();
+			var position = menuRect.top;
+			var buttonHeight = menuRect.height;
+			var menuHeight = ul.outerHeight();
+			if (position > menuHeight && $(window).height() - position < buttonHeight + menuHeight) {
+				menu.addClass("dropup");
+			}
+		}).on('hidden.bs.dropdown', '.btn-group', function() {
+			// always reset after close
+			$(this).removeClass('dropup');
+		});
+
 		// Enable tabs dynamic loading
 		$(document).on('show.bs.tab', function(e) {
 			var link = $(e.target);
+			if (link.exists() && (link.get(0).tagName !== 'A')) {
+				link = $('a[href]', link);
+			}
 			var data = link.data();
 			if (data.amsUrl) {
 				if (data.amsTabLoaded) {
 					return;
 				}
-				try {
-					link.append('<i class="fa fa-spin fa-cog margin-left-5"></i>');
-					ams.skin.loadURL(data.amsUrl, link.attr('href'), {afterLoadCallback: function() {
+				link.append('<i class="fa fa-spin fa-cog margin-left-5"></i>');
+				ams.skin.loadURL(data.amsUrl, link.attr('href'), {
+					afterLoadCallback: function() {
 						if (data.amsTabLoadOnce) {
 							link.data('ams-tab-loaded', true);
 						}
-					}});
-				}
-				finally {
-					$('i', link).remove();
-				}
+						$('i', link).remove();
+					},
+					afterErrorCallback: function() {
+						$('i', link).remove();
+					}
+				});
 			}
 		});
 
@@ -5471,6 +6202,11 @@
 			});
 		});
 
+		// Enable custom MyAMS refresh events
+		$(document).on('myams.refresh', function(event, settings) {
+			MyAMS.executeFunctionByName(settings.handler || MyAMS.skin.refreshContent, event.target, settings);
+		});
+
 		// Init page content
 		ams.initContent(document);
 		if (ams.ajaxNav && nav.exists()) {
@@ -5593,6 +6329,18 @@
 			CLOSE: "Close",
 			NEXT: "Next",
 			PREVIOUS: "Previous"
+		},
+		dndupload: {
+			FILES_SELECTED: '{count} files selected',
+			CHOOSE_FILE: 'Select file(s)',
+			ADD_INFO: 'to add them to current folder,',
+			DRAG_FILE: 'or drag and drop them here!',
+			UPLOAD: 'Upload',
+			UPLOADING: 'Uploading&hellip;',
+			DONE: 'Done!',
+			UPLOAD_MORE: 'Upload more?',
+			ERROR: 'Error!',
+			TRY_AGAIN: 'Try again?'
 		}
 	};
 
@@ -5600,6 +6348,8 @@
 	$(document).ready(function() {
 		$ = jQuery.noConflict();
 		var html = $('HTML');
+		html.removeClass('no-js')
+			.addClass('js');
 		var lang = html.attr('lang') || html.attr('xml:lang');
 		if (lang && !lang.startsWith('en')) {
 			MyAMS.lang = lang;
--- a/src/ztfy/myams/resources/js/myams.min.js	Mon Jun 04 12:32:06 2018 +0200
+++ b/src/ztfy/myams/resources/js/myams.min.js	Mon Jun 04 12:32:38 2018 +0200
@@ -1,1 +1,1 @@
-!function(e,a){"use strict";var t=a.console;String.prototype.startsWith=function(e){var a=this.length,t=e.length;return!(a<t)&&this.substr(0,t)===e},String.prototype.endsWith=function(e){var a=this.length,t=e.length;return!(a<t)&&this.substr(a-t)===e},Array.prototype.indexOf||(Array.prototype.indexOf=function(e,a){var t=this.length;for((a=(a=Number(a)||0)<0?Math.ceil(a):Math.floor(a))<0&&(a+=t);a<t;a++)if(a in this&&this[a]===e)return a;return-1}),e.expr[":"].hasvalue=function(a,t,n){return""!==e(a).val()},e.expr[":"].econtains=function(a,t,n){return(a.textContent||a.innerText||e(a).text()||"").toLowerCase()===n[3].toLowerCase()},e.expr[":"].withtext=function(a,t,n){return(a.textContent||a.innerText||e(a).text()||"")===n[3]},e.expr[":"].parents=function(a,t,n){return e(a).parents(n[3]).length>0},void 0===e.scrollbarWidth&&(e.scrollbarWidth=function(){var a=e('<div style="width: 50px; height: 50px; overflow: auto"><div/></div>').appendTo("body"),t=a.children(),n=t.innerWidth()-t.height(99).innerWidth();return a.remove(),n}),e.fn.extend({exists:function(){return e(this).length>0},objectOrParentWithClass:function(e){return this.hasClass(e)?this:this.parents("."+e)},listattr:function(a){var t=[];return this.each(function(){t.push(e(this).attr(a))}),t},style:function(e,a,t){if(void 0!==this.get(0)){var n=this.get(0).style;return void 0!==e?void 0!==a?(t=void 0!==t?t:"",n.setProperty(e,a,t),this):n.getPropertyValue(e):n}},removeClassPrefix:function(a){return this.each(function(t,n){var i=n.className.split(" ").map(function(e){return e.startsWith(a)?"":e});n.className=e.trim(i.join(" "))}),this},contextMenu:function(a){function t(t,n,i){var s=e(window)[n](),r=e(a.menuSelector)[n](),o=t;return t+r>s&&r<t&&(o-=r),o}return this.each(function(){e("a",e(a.menuSelector)).each(function(){e(this).data("ams-context-menu",!0)}),e(this).on("contextmenu",function(n){if(!n.ctrlKey)return e(a.menuSelector).data("invokedOn",e(n.target)).show().css({position:"fixed",left:t(n.clientX,"width")-10,top:t(n.clientY,"height")-10}).off("click").on("click",function(t){e(this).hide();var n=e(this).data("invokedOn"),s=e(t.target);a.menuSelected.call(this,n,s),i.event.stop(t)}),!1}),e(document).click(function(){e(a.menuSelector).hide()})})},myams_menu:function(a){var t=e.extend({},{accordion:!0,speed:200,closedSign:'<em class="fa fa-angle-down"></em>',openedSign:'<em class="fa fa-angle-up"></em>'},a),n=e(this);n.find("LI").each(function(){var a=e(this);if(a.find("UL").size()>0){a.find("A:first").append("<b class='collapse-sign'>"+t.closedSign+"</b>");var n=a.find("A:first");"#"===n.attr("href")&&n.click(function(){return!1})}}),n.find("LI.active").each(function(){var a=e(this).parents("UL"),n=a.parent("LI");a.slideDown(t.speed),n.find("b:first").html(t.openedSign),n.addClass("open")}),n.find("LI A").on("click",function(){var a=e(this);if(!a.hasClass("active")){var i=a.attr("href").replace(/^#/,""),s=a.parent().find("UL");if(t.accordion){var r=a.parent().parents("UL"),o=n.find("UL:visible");o.each(function(a){var n=!0;if(r.each(function(e){if(r[e]===o[a])return n=!1,!1}),n&&s!==o[a]){var c=e(o[a]);!i&&c.hasClass("active")||c.slideUp(t.speed,function(){e(this).parent("LI").removeClass("open").find("B:first").delay(t.speed).html(t.closedSign)})}})}var c=a.parent().find("UL:first");i||!c.is(":visible")||c.hasClass("active")?c.slideDown(t.speed,function(){a.parent("LI").addClass("open").find("B:first").delay(t.speed).html(t.openedSign)}):c.slideUp(t.speed,function(){a.parent("LI").removeClass("open").find("B:first").delay(t.speed).html(t.closedSign)})}})}}),e.UTF8={encode:function(e){e=e.replace(/\r\n/g,"\n");for(var a="",t=0;t<e.length;t++){var n=e.charCodeAt(t);n<128?a+=String.fromCharCode(n):n>127&&n<2048?(a+=String.fromCharCode(n>>6|192),a+=String.fromCharCode(63&n|128)):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128),a+=String.fromCharCode(63&n|128))}return a},decode:function(e){for(var a="",t=0,n=0,i=0,s=0;t<e.length;)(n=e.charCodeAt(t))<128?(a+=String.fromCharCode(n),t++):n>191&&n<224?(i=e.charCodeAt(t+1),a+=String.fromCharCode((31&n)<<6|63&i),t+=2):(i=e.charCodeAt(t+1),s=e.charCodeAt(t+2),a+=String.fromCharCode((15&n)<<12|(63&i)<<6|63&s),t+=3);return a}},void 0===a.MyAMS&&(a.MyAMS={devmode:!0,devext:"",lang:"en",throttleDelay:350,menuSpeed:235,navbarHeight:49,ajaxNav:!0,enableWidgets:!0,enableMobile:!1,enableFastclick:!1,warnOnFormChange:!1,ismobile:/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())});var n=a.MyAMS,i=n;n.baseURL=function(){var a=e('script[src*="/myams.js"], script[src*="/myams.min.js"]').attr("src");return i.devmode=a.indexOf(".min.js")<0,i.devext=i.devmode?"":".min",a.substring(0,a.lastIndexOf("/")+1)}(),n.log=function(){t&&t.debug&&t.debug(this,arguments)},n.getQueryVar=function(e,a){if(e.indexOf("?")<0)return!1;e.endsWith("&")||(e+="&");var t=new RegExp(".*?[&\\?]"+a+"=(.*?)&.*"),n=e.replace(t,"$1");return n!==e&&n},n.rgb2hex=function(a){return"#"+e.map(a.match(/\b(\d+)\b/g),function(e){return("0"+parseInt(e).toString(16)).slice(-2)}).join("")},n.generateId=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+e()+e()},n.generateUUID=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var t=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===a?t:3&t|8).toString(16)})},n.getObject=function(e,a){if(e){if("string"!=typeof e)return e;var t=e.split(".");a=void 0===a||null===a?window:a;for(var n=0;n<t.length;n++)try{a=a[t[n]]}catch(e){return}return a}},n.getFunctionByName=function(e,a){if(void 0!==e){if("function"==typeof e)return e;var t=e.split("."),n=t.pop();a=void 0===a||null===a?window:a;for(var i=0;i<t.length;i++)try{a=a[t[i]]}catch(e){return}try{return a[n]}catch(e){return}}},n.executeFunctionByName=function(e,a){var t=i.getFunctionByName(e,window);if("function"==typeof t){var n=Array.prototype.slice.call(arguments,2);return t.apply(a,n)}},n.isInDOM=function(t){return!!(t=e(t)).exists()&&a.document.body.contains(t[0])},n.getSource=function(e){return e.replace(/{[^{}]*}/g,function(e){return i.getFunctionByName(e.substr(1,e.length-2))})},n.getScript=function(a,t,n){"object"==typeof t&&(n=t,t=null),void 0===n&&(n={});var s={dataType:"script",url:i.getSource(a),success:t,error:i.error.show,cache:!i.devmode,async:void 0===n.async?"function"==typeof t:n.async},r=e.extend({},s,n);return e.ajax(r)},n.getCSS=function(a,t){var n=e("HEAD");if(0===e('link[data-ams-id="'+t+'"]',n).length){var s=i.getSource(a);i.devmode&&(s+="?_="+(new Date).getTime()),e("<link />").attr({rel:"stylesheet",type:"text/css",href:s,"data-ams-id":t}).appendTo(n)}},n.event={stop:function(e){e||(e=window.event),e&&(e.stopPropagation?(e.stopPropagation(),e.preventDefault()):(e.cancelBubble=!0,e.returnValue=!1))}},n.browser={getInternetExplorerVersion:function(){var e=-1;if("Microsoft Internet Explorer"===navigator.appName){var a=navigator.userAgent;null!==new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(a)&&(e=parseFloat(RegExp.$1))}return e},checkVersion:function(){var e="You're not using Windows Internet Explorer.",t=this.getInternetExplorerVersion();t>-1&&(e=t>=8?"You're using a recent copy of Windows Internet Explorer.":"You should upgrade your copy of Windows Internet Explorer."),a.alert&&a.alert(e)},isIE8orlower:function(){var e="0",a=this.getInternetExplorerVersion();return a>-1&&(e=a>=9?0:1),e},copyToClipboard:function(s){function r(s){var r=!1;if(window.clipboardData&&window.clipboardData.setData)r=clipboardData.setData("Text",s);else if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var o=e("<textarea>");o.val(s),o.css("position","fixed"),o.appendTo(e("body")),o.get(0).select();try{document.execCommand("copy"),r=!0}catch(e){t&&t.warn&&t.warn("Copy to clipboard failed.",e)}finally{o.remove()}}r?i.skin.smallBox("success",{title:s.length>1?i.i18n.CLIPBOARD_TEXT_COPY_OK:i.i18n.CLIPBOARD_CHARACTER_COPY_OK,icon:"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:1e3}):a.prompt&&a.prompt(n.i18n.CLIPBOARD_COPY,s)}if(void 0===s)return function(){var a=e(this),t=a.text();a.parents(".btn-group").removeClass("open"),r(t)};r(s)}},n.error={ajax:function(e,a,n,s){if(!("abort"===s||a&&a.statusText&&"OK"===a.statusText.toUpperCase())){if("json"===(a=i.ajax.getResponse(a)).contentType)i.ajax.handleJSON(a.data);else{var r=e.statusText||e.type,o=a.responseText;i.skin.messageBox("error",{title:i.i18n.ERROR_OCCURED,content:"<h4>"+r+"</h4><p>"+(o||"")+"</p>",icon:"fa fa-warning animated shake",timeout:1e4})}t&&(t.error&&t.error(e),t.debug&&t.debug(a))}},show:function(e,a,n){if(n){var s=i.ajax.getResponse(e);"json"===s.contentType?i.ajax.handleJSON(s.data):i.skin.messageBox("error",{title:i.i18n.ERRORS_OCCURED,content:"<h4>"+a+"</h4><p>"+n+"</p>",icon:"fa fa-warning animated shake",timeout:1e4}),t&&(t.error&&t.error(n),t.debug&&t.debug(e))}}},n.ajax={check:function(a,t,n,s){function r(e,a){if(void 0!==n){n instanceof Array||(n=[n]);for(var t=0;t<n.length;t++){var s=i.getFunctionByName(n[t]);"function"==typeof s&&s(e,a)}}}n instanceof Array||"object"==typeof n&&(s=n,n=void 0);var o={async:"function"==typeof n},c=e.extend({},o,s);if(a instanceof Array){for(var l=[],d=0;d<a.length;d++)void 0===a[d]&&l.push(i.getScript(t[d],{async:!0}));l.length>0?e.when.apply(e,l).then(function(){r(!0,s)}):r(!1,s)}else void 0===a?"string"==typeof t&&i.getScript(t,function(){r(!0,s)},c):r(!1,s)},getAddr:function(a){var t=a||e("HTML HEAD BASE").attr("href")||window.location.href;return t.substr(0,t.lastIndexOf("/")+1)},start:function(){e("#ajax-gear").show()},stop:function(){e("#ajax-gear").hide()},progress:function(e){e.lengthComputable&&(e.loaded>=e.total||t&&t.log&&t.log(parseInt(e.loaded/e.total*100,10)+"%"))},post:function(a,t,n,s){var r;r=a.startsWith(window.location.protocol)?a:this.getAddr()+a,"function"==typeof n?(s=n,n={}):n||(n={}),void 0===s&&(s=n.callback),"string"==typeof s&&(s=i.getFunctionByName(s)),delete n.callback;var o,c={url:r,type:"post",cache:!1,async:"function"==typeof s,data:e.param(t),dataType:"json",success:s||function(e){o=e.result}},l=e.extend({},c,n);return e.ajax(l),o},getResponse:function(e){var a,t,n=e.getResponseHeader("content-type");if(n)if(n.startsWith("application/javascript"))a="script",t=e.responseText;else if(n.startsWith("text/html"))a="html",t=e.responseText;else if(n.startsWith("text/xml"))a="xml",t=e.responseText;else if(t=e.responseJSON)a="json";else try{t=JSON.parse(e.responseText),a="json"}catch(n){t=e.responseText,a="text"}else a="json",t={status:"alert",alert:{title:i.i18n.ERROR_OCCURED,content:i.i18n.NO_SERVER_RESPONSE}};return{contentType:a,data:t}},handleJSON:function(n,s,r){var o,c=n.status;switch(c){case"alert":a.alert&&a.alert(n.alert.title+"\n\n"+n.alert.content);break;case"error":i.form.showErrors(s,n);break;case"info":case"success":void 0!==s&&(i.form.resetChanged(s),!1!==n.close_form&&i.dialog.close(s));break;case"message":case"messagebox":break;case"notify":case"callback":case"callbacks":void 0!==s&&(i.form.resetChanged(s),!1!==n.close_form&&i.dialog.close(s));break;case"modal":i.dialog.open(n.location);break;case"reload":void 0!==s&&(i.form.resetChanged(s),!1!==n.close_form&&i.dialog.close(s)),(o=n.location||window.location.hash).startsWith("#")&&(o=o.substr(1));var l=e(n.target||r||"#content");i.skin.loadURL(o,l,{preLoadCallback:i.getFunctionByName(n.pre_reload)||function(){e("[data-ams-pre-reload]",l).each(function(){i.executeFunctionByName(e(this).data("ams-pre-reload"))})},afterLoadCallback:i.getFunctionByName(n.post_reload)||function(){e("[data-ams-post-reload]",l).each(function(){i.executeFunctionByName(e(this).data("ams-post-reload"))})}});break;case"redirect":void 0!==s&&(i.form.resetChanged(s),!0===n.close_form&&i.dialog.close(s)),o=n.location||window.location.href,n.window?window.open(o,n.window,n.options):window.location.href===o?window.location.reload(!0):window.location.href=o;break;default:t&&t.log&&t.log("Unhandled status: "+c)}var d,m,u;if(n.content&&(m=n.content,u=e(m.target||r||s||"#content"),!0===m.raw?u.text(m.text):(u.html(m.html),i.initContent(u)),m.keep_hidden||u.removeClass("hidden")),n.contents){var f=n.contents;for(d=0;d<f.length;d++)m=f[d],u=e(m.target),!0===m.raw?u.text(m.text):(u.html(m.html),i.initContent(u)),m.keep_hidden||u.removeClass("hidden")}var h;if(n.message&&("string"==typeof(h=n.message)?"info"===c||"success"===c?i.skin.smallBox(c,{title:h,icon:"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:3e3}):i.skin.alert(e(s||"#content"),c,h):i.skin.alert(e(h.target||r||s||"#content"),h.status||"success",h.header,h.body,h.subtitle)),n.smallbox&&i.skin.smallBox(n.smallbox_status||c,{title:n.smallbox,icon:"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:3e3}),n.messagebox)if("string"==typeof(h=n.messagebox))i.skin.messageBox("info",{title:i.i18n.ERROR_OCCURED,content:h,timeout:1e4});else{var p=h.status||"info";"error"===p&&s&&r&&i.executeFunctionByName(s.data("ams-form-submit-error")||"MyAMS.form.finalizeSubmitOnError",s,r),i.skin.messageBox(p,{title:h.title||i.i18n.ERROR_OCCURED,content:h.content,icon:h.icon,number:h.number,timeout:null===h.timeout?void 0:h.timeout||1e4})}if(n.event&&s.trigger(n.event,n.event_options),n.events){var g;for(void 0===s&&(s=e(document)),d=0;d<n.events.length;d++)"string"==typeof(g=n.events[d])?s.trigger(g,n.events_options):s.trigger(g.event,g.options)}if(n.callback&&i.executeFunctionByName(n.callback,s,n.options),n.callbacks){var b;for(d=0;d<n.callbacks.length;d++)"function"==typeof(b=n.callbacks[d])?i.executeFunctionByName(b,s,b.options):i.executeFunctionByName(b.callback,s,b.options)}}},n.jsonrpc={getAddr:function(a){var t=(a||e("HTML HEAD BASE").attr("href")||window.location.href).replace(/\+\+skin\+\+\w+\//,"");return t.substr(0,t.lastIndexOf("/")+1)},query:function(a,t,n,s){i.ajax.check(e.jsonRpc,i.baseURL+"ext/jquery-jsonrpc"+i.devext+".js",function(){"function"==typeof n?(s=n,n={}):n||(n={}),"undefined"===s&&(s=n.callback),"string"==typeof s&&(s=i.getFunctionByName(s)),delete n.callback;var r={};"string"==typeof a?r.query=a:"object"==typeof a&&e.extend(r,a),e.extend(r,n);var o,c={url:i.jsonrpc.getAddr(n.url),type:"post",cache:!1,method:t,params:r,async:"function"==typeof s,success:s||function(e){o=e.result},error:i.error.show};return e.jsonRpc(c),o})},post:function(a,t,n,s){i.ajax.check(e.jsonRpc,i.baseURL+"ext/jquery-jsonrpc"+i.devext+".js",function(){"function"==typeof n?(s=n,n={}):n||(n={}),void 0===s&&(s=n.callback),"string"==typeof s&&(s=i.getFunctionByName(s)),delete n.callback;var r,o={url:i.jsonrpc.getAddr(n.url),type:"post",cache:!1,method:a,params:t,async:"function"==typeof s,success:s||function(e){r=e.result},error:i.error.show},c=e.extend({},o,n);return e.jsonRpc(c),r})}},n.xmlrpc={getAddr:function(a){var t=(a||e("HTML HEAD BASE").attr("href")||window.location.href).replace(/\+\+skin\+\+\w+\//,"");return t.substr(0,t.lastIndexOf("/")+1)},post:function(a,t,n,s,r){i.ajax.check(e.xmlrpc,i.baseURL+"ext/jquery-xmlrpc"+i.devext+".js",function(){"function"==typeof s?(r=s,s={}):s||(s={}),void 0===r&&(r=s.callback),"string"==typeof r&&(r=i.getFunctionByName(r)),delete s.callback;var o,c={url:i.xmlrpc.getAddr(a),methodName:t,params:n,success:r||function(e){o=e},error:i.error.show},l=e.extend({},c,s);return e.xmlrpc(l),o})}},n.form={init:function(a){e("FORM",a).each(function(){var a=e(this);e('INPUT.select2[type="hidden"]',a).each(function(){var a=e(this);a.data("ams-select2-input-value",a.val())})});(i.warnOnFormChange?e('FORM[data-ams-warn-on-change!="false"]',a):e('FORM[data-ams-warn-on-change="true"]',a)).each(function(){var a=e(this);e('INPUT[type="text"], INPUT[type="checkbox"], INPUT[type="radio"], SELECT, TEXTAREA, [data-ams-changed-event]',a).each(function(){var a=e(this);if(!0!==a.data("ams-ignore-change")){var t=a.data("ams-changed-event")||"change";a.on(t,function(){i.form.setChanged(e(this).parents("FORM"))})}}),a.on("reset",function(){i.form.resetChanged(e(this))})})},setFocus:function(a){var t=e("[data-ams-focus-target]",a).first();t.exists()||(t=e("input, select",a).first()),t.exists()&&(t.hasClass("select2-input")&&(t=t.parents(".select2")),t.hasClass("select2")?setTimeout(function(){t.select2("focus"),!0===t.data("ams-focus-open")&&t.select2("open")},100):t.focus())},checkBeforeUnload:function(){if(e('FORM[data-ams-form-changed="true"]').exists())return i.i18n.FORM_CHANGED_WARNING},confirmChangedForm:function(t,n,s){"function"==typeof t&&(n=t,t=void 0),e('FORM[data-ams-form-changed="true"]',t).exists()?s?a.confirm(i.i18n.FORM_CHANGED_WARNING,i.i18n.WARNING)?n.call(t):s.call(t):i.skin.bigBox({title:i.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+i.i18n.FORM_CHANGED_WARNING,buttons:i.i18n.BTN_OK_CANCEL},function(e){e===i.i18n.BTN_OK&&n.call(t)}):n.call(t)},setChanged:function(e){e.attr("data-ams-form-changed",!0)},resetChanged:function(a){void 0!==a&&e(a).removeAttr("data-ams-form-changed")},submit:function(t,n,s){if(!(t=e(t)).exists())return!1;if("object"==typeof n&&(s=n,n=void 0),t.data("submitted"))return t.data("ams-form-hide-submitted")||i.skin.messageBox("warning",{title:i.i18n.WAIT,content:i.i18n.FORM_SUBMITTED,icon:"fa fa-save shake animated",timeout:t.data("ams-form-alert-timeout")||5e3}),!1;if(!i.form._checkSubmitValidators(t))return!1;e(".alert-danger, SPAN.state-error",t).not(".persistent").remove(),e(".state-error",t).removeClassPrefix("state-");var r=e(t.data("ams-submit-button"));return r&&!r.data("ams-form-hide-loading")&&(r.data("ams-progress-content",r.html()),r.button("loading")),i.ajax.check(e.fn.ajaxSubmit,i.baseURL+"ext/jquery-form-3.49"+i.devext+".js",function(){function r(t,r){var o,c,l,d,m,u,f,h,p,g=t.data(),b=g.amsFormOptions;if(s&&(m=s.formDataInitCallback),m?delete s.formDataInitCallback:m=g.amsFormDataInitCallback,m){var v={};if(d="function"==typeof m?m.call(t,v):i.executeFunctionByName(m,t,v),v.veto)return(o=t.data("ams-submit-button"))&&o.button("reset"),i.form.finalizeSubmitFooter.call(t),!1}else d=g.amsFormData||{};(o=e(t.data("ams-submit-button")))&&o.exists()?l=(c=o.data()).amsFormSubmitTarget:c={};var x,y=n||c.amsFormHandler||g.amsFormHandler||"";if(y.startsWith(window.location.protocol))x=y;else{var k=c.amsFormAction||t.attr("action").replace(/#/,"");x=k.startsWith(window.location.protocol)?k:i.ajax.getAddr()+k,x+=y}u=c.amsProgressHandler||g.amsProgressHandler||"",f=c.amsProgressInterval||g.amsProgressInterval||1e3,h=c.amsProgressCallback||g.amsProgressCallback,p=c.amsProgressEndCallback||g.amsProgressEndCallback;var C=null;s&&s.initSubmitTarget?i.executeFunctionByName(s.initSubmitTarget,t):g.amsFormInitSubmitTarget?(C=e(l||g.amsFormSubmitTarget||"#content"),i.executeFunctionByName(g.amsFormInitSubmit||"MyAMS.form.initSubmit",t,C)):g.amsFormHideSubmitFooter||i.executeFunctionByName(g.amsFormInitSubmit||"MyAMS.form.initSubmitFooter",t),s&&(d=e.extend({},d,s.form_data));var S;u?d.progress_id=i.generateUUID():(S=void 0!==r.uuid)&&(x.indexOf("X-Progress-ID")<0&&(x+="?X-Progress-ID="+r.uuid),delete r.uuid);var w={url:x,type:"post",cache:!1,data:d,dataType:g.amsFormDatatype,beforeSerialize:function(){void 0!==a.tinyMCE&&a.tinyMCE.triggerSave()},beforeSubmit:function(e,a){a.data("submitted",!0)},error:function(e,a,t,n){C&&i.executeFunctionByName(g.amsFormSubmitError||"MyAMS.form.finalizeSubmitOnError",n,C),i.form.resetAfterSubmit(n)},iframe:S},F=s&&s.downloadTarget||g.amsFormDownloadTarget;if(F){var T=e('iframe[name="'+F+'"]');T.exists()||(T=e("<iframe></iframe>").hide().attr("name",F).appendTo(e("body"))),w=e.extend({},w,{iframe:!0,iframeTarget:T,success:function(a,t,n,s){if(e(s).parents(".modal-dialog").exists())i.dialog.close(s);else{var r,o=s.data("ams-submit-button");o&&(r=o.data("ams-form-submit-callback")),r||(r=i.getFunctionByName(g.amsFormSubmitCallback)||i.form._submitCallback);try{r.call(s,a,t,n,s)}finally{i.form.resetAfterSubmit(s),i.form.resetChanged(s)}}}})}else w=e.extend({},w,{error:function(e,a,t,n){C&&i.executeFunctionByName(g.amsFormSubmitError||"MyAMS.form.finalizeSubmitOnError",n,C),i.form.resetAfterSubmit(n)},success:function(e,a,t,n){var s,r=n.data("ams-submit-button");r&&(s=r.data("ams-form-submit-callback")),s||(s=i.getFunctionByName(g.amsFormSubmitCallback)||i.form._submitCallback);try{s.call(n,e,a,t,n)}finally{i.form.resetAfterSubmit(n),i.form.resetChanged(n)}},iframe:S});var N=e.extend({},w,r,b,s);if(u&&function(e,a){function n(){clearInterval(s),i.form.resetAfterSubmit(t,o),o.html(o.data("ams-progress-content")),i.executeFunctionByName(p,t,o),i.form.resetChanged(t)}var s;o.button("loading"),s=setInterval(function(){i.ajax.post(e,{progress_id:a},{error:n},i.getFunctionByName(h)||function(e,a){if("success"===a)if("running"===e.status)if(e.message)o.text(e.message);else{var t=o.data("ams-progress-text")||i.i18n.PROGRESS;e.current?t+=": "+e.current+"/ "+(e.length||100):t+="...",o.text(t)}else"finished"===e.status&&n();else n()})},f)}(u,d.progress_id),e(t).ajaxSubmit(N),F){var R=e(t).parents(".modal-dialog"),O=R.exists()&&o.exists()&&o.data("ams-keep-modal");R.exists()&&!0!==O?i.dialog.close(t):u||setTimeout(function(){i.form.resetAfterSubmit(t,o),i.form.resetChanged(t)},o.data("ams-form-reset-timeout")||2e3)}}if(!0!==t.data("ams-form-ignore-uploads")&&e('INPUT[type="file"]',t).length>0){i.ajax.check(e.progressBar,i.baseURL+"ext/jquery-progressbar"+i.devext+".js");var o=e.extend({},{uuid:e.progressBar.submit(t)});r(t,o)}else r(t,{})}),!1},initSubmit:function(a,t){var n=e(this),i='<i class="fa fa-3x fa-gear fa-spin"></i>';t||(t=n.data("ams-form-submit-message")),t&&(i+="<strong>"+t+"</strong>"),e(a).html('<div class="row margin-20"><div class="text-center">'+i+"</div></div>"),e(a).parents(".hidden").removeClass("hidden")},resetAfterSubmit:function(e){if(e.is(":visible")){var a=e.data("ams-submit-button");a&&a.button("reset"),i.form.finalizeSubmitFooter.call(e)}e.data("submitted",!1),e.removeData("ams-submit-button")},finalizeSubmitOnError:function(a){e("i",a).removeClass("fa-spin").removeClass("fa-gear").addClass("fa-ambulance")},initSubmitFooter:function(a){var t=e(this),n='<i class="fa fa-3x fa-gear fa-spin"></i>';a||(a=e(this).data("ams-form-submit-message")),a&&(n+='<strong class="submit-message align-top padding-left-10 margin-top-10">'+a+"</strong>");var i=e("footer",t);e("button",i).hide(),i.append('<div class="row"><div class="text-center">'+n+"</div></div>")},finalizeSubmitFooter:function(){var a=e(this),t=e("footer",a);t&&(e(".row",t).remove(),e("button",t).show())},_submitCallback:function(a,t,n,s){var r;s.is(":visible")&&(i.form.finalizeSubmitFooter.call(s),(r=s.data("ams-submit-button"))&&r.button("reset"));var o,c=s.data();if(c.amsFormDatatype)o=c.amsFormDatatype;else{var l=i.ajax.getResponse(n);o=l.contentType,a=l.data}var d;switch(d=e(r?r.data("ams-form-submit-target")||c.amsFormSubmitTarget||"#content":c.amsFormSubmitTarget||"#content"),o){case"json":i.ajax.handleJSON(a,s,d);break;case"script":case"xml":break;case"html":case"text":default:i.form.resetChanged(s),r&&!0!==r.data("ams-keep-modal")&&i.dialog.close(s),d.exists()||(d=e("body")),d.parents(".hidden").removeClass("hidden"),e(".alert",d.parents(".alerts-container")).remove(),d.css({opacity:"0.0"}).html(a).delay(50).animate({opacity:"1.0"},300),i.initContent(d),i.form.setFocus(d)}var m=n.getResponseHeader("X-AMS-Callback");if(m){var u=n.getResponseHeader("X-AMS-Callback-Options");i.executeFunctionByName(m,s,void 0===u?{}:JSON.parse(u),n)}},_getSubmitValidators:function(a){var t=[],n=a.data("ams-form-validator");return n&&t.push([a,n]),e("[data-ams-form-validator]",a).each(function(){var a=e(this);t.push([a,a.data("ams-form-validator")])}),t},_checkSubmitValidators:function(e){var a=i.form._getSubmitValidators(e);if(!a.length)return!0;for(var t=[],n=!0,s=0;s<a.length;s++){var r=a[s],o=r[0],c=r[1],l=i.executeFunctionByName(c,e,o);!1===l?n=!1:"string"==typeof l?t.push(l):n.length&&n.length>0&&(t=t.concat(n))}if(t.length>0){var d=1===t.length?i.i18n.ERROR_OCCURED:i.i18n.ERRORS_OCCURED;return i.skin.alert(e,"danger",d,t),!1}return n},showErrors:function(a,t){var n;if("string"==typeof t)i.skin.alert(a,"error",i.i18n.ERROR_OCCURED,t);else if(t instanceof Array)n=1===t.length?i.i18n.ERROR_OCCURED:i.i18n.ERRORS_OCCURED,i.skin.alert(a,"error",n,t);else{e(".state-error",a).removeClass("state-error"),n=t.error_header||(t.widgets&&t.widgets.length>1?i.i18n.ERRORS_OCCURED:i.i18n.ERROR_OCCURED);var s,r=[];if(t.messages)for(s=0;s<t.messages.length;s++){var o=t.messages[s];o.header?r.push("<strong>"+o.header+"</strong><br />"+o.message):r.push(o.message||o)}if(t.widgets)for(s=0;s<t.widgets.length;s++){var c=t.widgets[s],l=e('[name="'+c.name+'"]',a);l.exists()||(l=e('[name="'+c.name+':list"]',a)),l.exists()&&l.parents("label:first").removeClassPrefix("state-").addClass("state-error").after('<span for="name" class="state-error">'+c.message+"</span>"),c.label&&r.push(c.label+" : "+c.message);var d=l.parents(".tab-pane").index()+1;if(d>0){var m=e(".nav-tabs",e(l).parents(".tabforms"));e("li:nth-child("+d+")",m).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",a).click()}}i.skin.alert(e("fieldset:first",a),t.error_level||"error",n,r,t.error_message)}}},n.dialog={_shown_callbacks:[],registerShownCallback:function(e,a){var t;a&&(t=a.objectOrParentWithClass("modal-dialog"));var n;t&&t.exists()?void 0===(n=t.data("shown-callbacks"))&&(n=[],t.data("shown-callbacks",n)):n=i.dialog._shown_callbacks,n.indexOf(e)<0&&n.push(e)},_hide_callbacks:[],registerHideCallback:function(e,a){var t;a&&(t=a.objectOrParentWithClass("modal-dialog"));var n;t&&t.exists()?void 0===(n=t.data("hide-callbacks"))&&(n=[],t.data("hide-callbacks",n)):n=i.dialog._hide_callbacks,n.indexOf(e)<0&&n.push(e)},open:function(a,t){i.ajax.check(e.fn.modalmanager,i.baseURL+"ext/bootstrap-modalmanager"+i.devext+".js",function(){i.ajax.check(e.fn.modal.defaults,i.baseURL+"ext/bootstrap-modal"+i.devext+".js",function(n){n&&(e(document).off("click.modal"),e.fn.modal.defaults.spinner=e.fn.modalmanager.defaults.spinner='<div class="loading-spinner" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="progress-bar" style="width: 100%;"></div></div></div>');var s,r;if("string"==typeof a)s={},r=a;else{s=a.data(),r=a.attr("href")||s.amsUrl;var o=i.getFunctionByName(r);"function"==typeof o&&(r=o.call(a))}r&&(e("body").modalmanager("loading"),0===r.indexOf("#")?e(r).modal("show"):e.ajax({url:r,type:"get",cache:void 0!==s.amsAllowCache&&s.amsAllowCache,data:t,success:function(t,n,o){e("body").modalmanager("removeLoading");var c=i.ajax.getResponse(o),l=c.contentType,d=c.data;switch(l){case"json":i.ajax.handleJSON(d,e(e(a).data("ams-json-target")||"#content"));break;case"script":case"xml":break;case"html":case"text":default:var m=e(d),u=e(".modal-dialog",m.wrap("<div></div>").parent()),f=u.data(),h={backdrop:"static",overflow:f.amsModalOverflow||".modal-viewport",maxHeight:void 0===f.amsModalMaxHeight?function(){return e(window).height()-e(".modal-header",m).outerHeight(!0)-e("footer",m).outerHeight(!0)-85}:i.getFunctionByName(f.amsModalMaxHeight)},p=e.extend({},h,f.amsModalOptions);p=i.executeFunctionByName(f.amsModalInitCallback,u,p)||p,e("<div>").addClass("modal fade").append(m).modal(p).on("shown",i.dialog.shown).on("hidden",i.dialog.hidden),i.initContent(m),!1!==s.amsLogEvent&&i.stats.logPageview(r)}}}))})})},shown:function(a){function t(a){var t=e(".scrollmarker.top",s),n=s.scrollTop();n>0?t.show():t.hide();var i=e(".scrollmarker.bottom",s);r+n>=s.get(0).scrollHeight?i.hide():i.show()}var n=a.target,s=e(".modal-viewport",n);if(s.exists()){var r=parseInt(s.css("max-height")),o=e.scrollbarWidth();"hidden"!==s.css("overflow")&&s.height()===r?(e("<div></div>").addClass("scrollmarker").addClass("top").css("top",0).css("width",s.width()-o).hide().appendTo(s),e("<div></div>").addClass("scrollmarker").addClass("bottom").css("top",r-20).css("width",s.width()-o).appendTo(s),s.scroll(t),s.off("resize").on("resize",t)):e(".scrollmarker",s).remove()}e("[data-ams-shown-callback]",n).each(function(){var a=i.getFunctionByName(e(this).data("ams-shown-callback"));a&&a.call(n,this)});var c,l=e(".modal-dialog",n).data("shown-callbacks");if(l)for(c=0;c<l.length;c++)l[c].call(n);if(l=i.dialog._shown_callbacks)for(c=0;c<l.length;c++)l[c].call(n);i.form.setFocus(n)},close:function(a){"string"==typeof a&&(a=e(a));var t=a.parents(".modal").data("modal");if(t){var n=e("body").data("modalmanager");n&&n.getOpenModals().indexOf(t)>=0&&t.hide()}},hidden:function(a){var t=a.target;i.skin.cleanContainer(t),e("[data-ams-hidden-callback]",t).each(function(){var a=i.getFunctionByName(e(this).data("ams-hidden-callback"));a&&a.call(t,this)});var n,s=e(".modal-dialog",t).data("hide-callbacks");if(s)for(n=0;n<s.length;n++)s[n].call(t);if(s=i.dialog._hide_callbacks)for(n=0;n<s.length;n++)s[n].call(t)}},n.helpers={sort:function(a,t){t||(t="weight"),a.children().sort(function(a,n){return+e(a).data(t)-+e(n).data(t)}).each(function(){a.append(this)})},select2ClearSelection:function(){var a=e(this),t=a.parents("label"),n=a.data("ams-select2-target");e('[name="'+n+'"]',t).data("select2").val("")},select2FormatSelection:function(a,t){a instanceof Array?e(a).each(function(){"object"==typeof this?t.append(this.text):t.append(this)}):"object"==typeof a?t.append(a.text):t.append(a)},select2SelectAllHelper:function(){var a=e(this).parents("label:first"),t=e(".select2",a);t.select2("data",t.data("ams-select2-data"))},select2QueryUrlResultsCallback:function(a,t,n){switch(a.status){case"error":i.skin.messageBox("error",{title:i.i18n.ERROR_OCCURED,content:"<h4>"+a.error_message+"</h4>",icon:"fa fa-warning animated shake",timeout:1e4});break;case"modal":e(this).data("select2").dropdown.hide(),i.dialog.open(a.location);break;default:return{results:a.results||a,more:a.has_more||!1,context:a.context}}},select2QueryMethodSuccessCallback:function(a,t,n){var s=a.result;if("string"==typeof s)try{s=JSON.parse(s)}catch(e){}switch(s.status){case"error":i.skin.messageBox("error",{title:i.i18n.ERROR_OCCURED,content:"<h4>"+s.error_message+"</h4>",icon:"fa fa-warning animated shake",timeout:1e4});break;case"modal":e(this).data("select2").dropdown.hide(),i.dialog.open(s.location);break;default:n.callback({results:s.results||s,more:s.has_more||!1,context:s.context})}},contextMenuHandler:function(e,a){var t=a.data();if("modal"===t.toggle)i.dialog.open(a);else{var n=a.attr("href")||t.amsUrl;if(!n||n.startsWith("javascript")||a.attr("target"))return;i.event.stop();var s=i.getFunctionByName(n);"function"==typeof s&&(n=s.call(a,e)),"function"==typeof n?n.call(a,e):(n=n.replace(/\%23/,"#"),(e=a.data("ams-target"))?i.form.confirmChangedForm(e,function(){i.skin.loadURL(n,e,a.data("ams-link-options"),a.data("ams-link-callback"))}):i.form.confirmChangedForm(function(){n.startsWith("#")?n!==location.hash&&(i.root.hasClass("mobile-view-activated")?(i.root.removeClass("hidden-menu"),window.setTimeout(function(){window.location.hash=n},150)):window.location.hash=n):window.location=n}))}},datetimepickerDialogHiddenCallback:function(){e(".datepicker, .timepicker, .datetimepicker",this).datetimepicker("destroy")}},n.plugins={init:function(a){function t(e,a){if(o.hasOwnProperty(e)){var t=o[e];t.css=t.css||a.css,t.callbacks.push({callback:a.callback,context:a.context}),a.register&&(t.register=!0),!1===a.async&&(t.async=!1)}else o[e]={src:a.src,css:a.css,callbacks:[{callback:a.callback,context:a.context}],register:a.register,async:a.async};a.css&&i.getCSS(a.css,e+"_css")}function n(e){var t,n,s=c.callbacks;if(s&&s.length){for(t=0;t<s.length;t++)if(n=s[t],n.callback=i.getFunctionByName(n.callback),!1!==c.register){var o=i.plugins.enabled;o.hasOwnProperty(r)?o[r].push(n):o[r]=[n]}}else!1!==c.register&&(i.plugins.enabled[r]=null);if(!0!==e&&s&&s.length&&!1!==c.async)for(t=0;t<s.length;t++)n=s[t],i.executeFunctionByName(n.callback,a,n.context)}i.plugins.initData(a);var s=[];e("[data-ams-plugins-disabled]",a).each(function(){for(var a=e(this).data("ams-plugins-disabled").split(/\s+/),t=0;t<a.length;t++)s.push(a[t])});var r,o={};e("[data-ams-plugins]",a).each(function(){var a=e(this),n=a.data("ams-plugins");if("string"==typeof n)for(var i=a.data("ams-plugins").split(/\s+/),s=0;s<i.length;s++){r=i[s];var o={src:a.data("ams-plugin-"+r+"-src"),css:a.data("ams-plugin-"+r+"-css"),callback:a.data("ams-plugin-"+r+"-callback"),context:a,register:a.data("ams-plugin-"+r+"-register"),async:a.data("ams-plugin-"+r+"-async")};t(r,o)}else for(r in n)n.hasOwnProperty(r)&&t(r,n[r])});var c;for(r in o)o.hasOwnProperty(r)&&(c=o[r],void 0===i.plugins.enabled[r]?i.getScript(c.src,n,{async:void 0===c.async||c.async}):(!function(){var e=i.plugins.enabled[r];for(l=0;l<e.length;l++){var a=e[l];a&&a.context&&!i.isInDOM(a.context)&&(e[l]=null)}}(),n(!0)));for(var l in i.plugins.enabled)if(i.plugins.enabled.hasOwnProperty(l)&&!(s.indexOf(l)>=0)){var d=i.plugins.enabled[l];if(d)switch(typeof d){case"function":d(a);break;default:for(var m=0;m<d.length;m++){var u=d[m];switch(typeof u){case"function":u(a);break;default:u&&u.callback&&u.callback(u.context)}}}}},initData:function(a){e("[data-ams-data]",a).each(function(){var a=e(this),t=a.data("ams-data");if(t)for(var n in t)if(t.hasOwnProperty(n)){var i=t[n];"string"!=typeof i&&(i=JSON.stringify(i)),a.attr("data-"+n,i)}})},register:function(e,a,n){if("function"==typeof a&&(n=a,a=null),a=a||e.name,i.plugins.enabled.indexOf(a)>=0)t&&t.warn&&t.warn("Plugin "+a+" is already registered!");else if("object"==typeof e){var s=e.src;s?i.ajax.check(e.callback,s,function(t){t&&(i.plugins.enabled[a]=i.getFunctionByName(e.callback),e.css&&i.getCSS(e.css,a+"_css"),n&&i.executeFunctionByName(n))}):(i.plugins.enabled[a]=i.getFunctionByName(e.callback),e.css&&i.getCSS(e.css,a+"_css"),n&&i.executeFunctionByName(n))}else"function"==typeof e&&(i.plugins.enabled[a]=e,n&&i.executeFunctionByName(n))},enabled:{hint:function(a){var t=e(".hint:not(:parents(.nohints))",a);t.length>0&&i.ajax.check(e.fn.tipsy,i.baseURL+"ext/jquery-tipsy"+i.devext+".js",function(){i.getCSS(i.baseURL+"../css/ext/jquery-tipsy"+i.devext+".css","jquery-tipsy"),t.each(function(){var a=e(this),t=a.data(),n={html:t.amsHintHtml,title:i.getFunctionByName(t.amsHintTitleGetter)||function(){var a=e(this),n=a.attr("original-title")||a.attr(t.amsHintTitleAttr||"title")||(t.amsHintHtml?a.html():a.text());return n=n.replace(/\?_="/,"?_="+(new Date).getTime()+'"')},opacity:t.amsHintOpacity||.95,gravity:t.amsHintGravity||"sw",offset:t.amsHintOffset||0},s=e.extend({},n,t.amsHintOptions);s=i.executeFunctionByName(t.amsHintInitCallback,a,s)||s;var r=a.tipsy(s);i.executeFunctionByName(t.amsHintAfterInitCallback,a,r,s)})})},contextMenu:function(a){var t=e(".context-menu",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={menuSelector:t.amsContextmenuSelector,menuSelected:i.helpers.contextMenuHandler},s=e.extend({},n,t.amsContextmenuOptions);s=i.executeFunctionByName(t.amsContextmenuInitCallback,a,s)||s;var r=a.contextMenu(s);i.executeFunctionByName(t.amsContextmenuAfterInitCallback,a,r,s)})},switcher:function(a){e("LEGEND.switcher",a).each(function(){var a=e(this),t=a.parent("fieldset"),n=a.data();n.amsSwitcher||(e('<i class="fa fa-fw"></i>').prependTo(e(this)).addClass("open"===n.amsSwitcherState?n.amsSwitcherMinusClass||"fa-minus":n.amsSwitcherPlusClass||"fa-plus"),a.on("click",function(i){i.preventDefault();var s={};if(a.trigger("ams.switcher.before-switch",[a,s]),!s.veto)if(t.hasClass("switched")){t.removeClass("switched"),e(".fa",a).removeClass(n.amsSwitcherPlusClass||"fa-plus").addClass(n.amsSwitcherMinusClass||"fa-minus"),a.trigger("ams.switcher.opened",[a]);var r=a.attr("id");r&&e('legend.switcher[data-ams-switcher-sync="'+r+'"]',t).each(function(){var a=e(this);a.parents("fieldset").hasClass("switched")&&a.click()})}else t.addClass("switched"),e(".fa",a).removeClass(n.amsSwitcherMinusClass||"fa-minus").addClass(n.amsSwitcherPlusClass||"fa-plus"),a.trigger("ams.switcher.closed",[a])}),"open"!==n.amsSwitcherState&&t.addClass("switched"),a.data("ams-switcher","on"))})},checker:function(a){e("LEGEND.checker",a).each(function(){var a=e(this),t=a.parent("fieldset"),n=a.data();if(!n.amsChecker){var s=e('<label class="checkbox"></label>'),r=n.amsCheckerFieldname||"checker_"+i.generateId(),o=r.replace(/\./,"_"),c=n.amsCheckerHiddenPrefix,l=null,d=n.amsCheckerHiddenValueOn||"true",m=n.amsCheckerHiddenValueOff||"false",u=n.amsCheckerMarker||!1;c?l=e('<input type="hidden">').attr("name",c+r).val("on"===n.amsCheckerState?d:m).prependTo(a):u&&e('<input type="hidden">').attr("name",u).attr("value",1).prependTo(a);var f=e('<input type="checkbox">').attr("name",r).attr("id",o).data("ams-checker-hidden-input",l).data("ams-checker-init",!0).val(n.amsCheckerValue||!0).attr("checked","on"===n.amsCheckerState?"checked":null);n.amsCheckerReadonly?f.attr("disabled","disabled"):f.on("change",function(s){s.preventDefault();var r={},o=e(this).is(":checked");if(a.trigger("ams.checker.before-switch",[a,r]),r.veto)e(this).prop("checked",!o);else if(i.executeFunctionByName(n.amsCheckerChangeHandler,a,o),!n.amsCheckerCancelDefault){var c=f.data("ams-checker-hidden-input");o?("disable"===n.amsCheckerMode?t.removeAttr("disabled"):t.removeClass("switched"),c&&c.val(d),e("[data-required]",t).attr("required","required"),a.trigger("ams.checker.opened",[a])):("disable"===n.amsCheckerMode?t.prop("disabled","disabled"):t.addClass("switched"),c&&c.val(m),e("[data-required]",t).removeAttr("required"),a.trigger("ams.checker.closed",[a]))}}),f.appendTo(s),e(">label",a).attr("for",f.attr("id")),s.append("<i></i>").prependTo(a);var h=e("[required]",t);h.attr("data-required",!0),"on"===n.amsCheckerState?f.attr("checked",!0):("disable"===n.amsCheckerMode?t.attr("disabled","disabled"):t.addClass("switched"),h.removeAttr("required")),a.data("ams-checker","on")}})},slider:function(a){var t=e(".slider",a);t.length>0&&i.ajax.check(e.fn.slider,i.baseURL+"ext/bootstrap-slider-2.0.0"+i.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n=e.extend({},{},a.data.amsSliderOptions);n=i.executeFunctionByName(t.amsSliderInitCallback,a,n)||n;var s=a.slider(n);i.executeFunctionByName(t.amsSliderAfterInitCallback,a,s,n)})})},draggable:function(a){var t=e(".draggable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={containment:t.amsDraggableContainment,helper:i.getFunctionByName(t.amsDraggableHelper)||t.amsDraggableHelper,start:i.getFunctionByName(t.amsDraggableStart),stop:i.getFunctionByName(t.amsDraggableStop)},s=e.extend({},n,t.amsDraggableOptions);s=i.executeFunctionByName(t.amsDraggableInitCallback,a,s)||s;var r=a.draggable(s);a.disableSelection(),i.executeFunctionByName(t.amsDraggableAfterInitCallback,a,r,s)})},sortable:function(a){var t=e(".sortable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={items:t.amsSortableItems,handle:t.amsSortableHandle,helper:t.amsSortableHelper,connectWith:t.amsSortableConnectwith,start:i.getFunctionByName(t.amsSortableStart),over:i.getFunctionByName(t.amsSortableOver),containment:t.amsSortableContainment,placeholder:t.amsSortablePlaceholder,stop:i.getFunctionByName(t.amsSortableStop)},s=e.extend({},n,t.amsSortableOptions);s=i.executeFunctionByName(t.amsSortableInitCallback,a,s)||s;var r=a.sortable(s);a.disableSelection(),i.executeFunctionByName(t.amsSortableAfterInitCallback,a,r,s)})},resizable:function(a){var t=e(".resizable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={autoHide:!1===t.amsResizableAutohide||t.amsResizableAutohide,containment:t.amsResizableContainment,grid:t.amsResizableGrid,handles:t.amsResizableHandles,start:i.getFunctionByName(t.amsResizableStart),stop:i.getFunctionByName(t.amsResizableStop)},s=e.extend({},n,t.amsResizableOptions);s=i.executeFunctionByName(t.amsResizableInitCallback,a,s)||s;var r=a.resizable(s);a.disableSelection(),i.executeFunctionByName(t.amsResizableAfterInitCallback,a,r,s)})},typeahead:function(a){var t=e(".typeahead",a);t.length>0&&i.ajax.check(e.fn.typeahead,i.baseURL+"ext/jquery-typeahead"+i.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n=e.extend({},{},t.amsTypeaheadOptions);n=i.executeFunctionByName(t.amsTypeaheadInitCallback,a,n)||n;var s=a.typeahead(n);i.executeFunctionByName(t.amsTypeaheadAfterInitCallback,a,s,n)})})},select2:function(a){var t=e(".select2",a);t.length>0&&i.ajax.check(e.fn.select2,i.baseURL+"ext/jquery-select2-3.5.2"+i.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n={placeholder:t.amsSelect2Placeholder,multiple:t.amsSelect2Multiple,minimumInputLength:t.amsSelect2MinimumInputLength||0,maximumSelectionSize:t.amsSelect2MaximumSelectionSize,openOnEnter:void 0===t.amsSelect2EnterOpen||t.amsSelect2EnterOpen,allowClear:void 0===t.amsSelect2AllowClear||t.amsSelect2AllowClear,width:t.amsSelect2Width||"100%",initSelection:i.getFunctionByName(t.amsSelect2InitSelection),formatSelection:void 0===t.amsSelect2FormatSelection?i.helpers.select2FormatSelection:i.getFunctionByName(t.amsSelect2FormatSelection),formatResult:i.getFunctionByName(t.amsSelect2FormatResult),formatMatches:void 0===t.amsSelect2FormatMatches?function(e){return 1===e?i.i18n.SELECT2_MATCH:e+i.i18n.SELECT2_MATCHES}:i.getFunctionByName(t.amsSelect2FormatMatches),formatNoMatches:void 0===t.amsSelect2FormatResult?function(e){return i.i18n.SELECT2_NOMATCHES}:i.getFunctionByName(t.amsSelect2FormatResult),formatInputTooShort:void 0===t.amsSelect2FormatInputTooShort?function(e,a){var t=a-e.length;return i.i18n.SELECT2_INPUT_TOOSHORT.replace(/\{0\}/,t).replace(/\{1\}/,1===t?"":i.i18n.SELECT2_PLURAL)}:i.getFunctionByName(t.amsSelect2FormatInputTooShort),formatInputTooLong:void 0===t.amsSelect2FormatInputTooLong?function(e,a){var t=e.length-a;return i.i18n.SELECT2_INPUT_TOOLONG.replace(/\{0\}/,t).replace(/\{1\}/,1===t?"":i.i18n.SELECT2_PLURAL)}:i.getFunctionByName(t.amsSelect2FormatInputTooLong),formatSelectionTooBig:void 0===t.amsSelect2FormatSelectionTooBig?function(e){return i.i18n.SELECT2_SELECTION_TOOBIG.replace(/\{0\}/,e).replace(/\{1\}/,1===e?"":i.i18n.SELECT2_PLURAL)}:i.getFunctionByName(t.amsSelect2FormatSelectionTooBig),formatLoadMore:void 0===t.amsSelect2FormatLoadMore?function(e){return i.i18n.SELECT2_LOADMORE}:i.getFunctionByName(t.amsSelect2FormatLoadMore),formatSearching:void 0===t.amsSelect2FormatSearching?function(){return i.i18n.SELECT2_SEARCHING}:i.getFunctionByName(t.amsSelect2FormatSearching),separator:t.amsSelect2Separator||",",tokenSeparators:t.amsSelect2TokensSeparators||[","],tokenizer:i.getFunctionByName(t.amsSelect2Tokenizer)};switch(a.context.type){case"text":case"hidden":if(!n.initSelection){var s=a.data("ams-select2-values");s&&(n.initSelection=function(a,t){var i=[];e(a.val().split(n.separator)).each(function(){i.push({id:this,text:s[this]||this})}),t(i)})}}a.attr("readonly")?"hidden"===a.attr("type")&&(n.query=function(){return[]}):t.amsSelect2Query?(n.query=i.getFunctionByName(t.amsSelect2Query),n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2QueryUrl?(n.ajax={url:t.amsSelect2QueryUrl,quietMillis:t.amsSelect2QuietMillis||200,type:t.amsSelect2QueryType||"POST",dataType:t.amsSelect2QueryDatatype||"json",data:function(a,n,i){var s={};return s[t.amsSelect2QueryParamName||"query"]=a,s[t.amsSelect2PageParamName||"page"]=n,s[t.amsSelect2ContextParamName||"context"]=i,e.extend({},s,t.amsSelect2QueryOptions)},results:i.helpers.select2QueryUrlResultsCallback},n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2QueryMethod?(n.query=function(n){var s={url:t.amsSelect2MethodTarget||i.jsonrpc.getAddr(),type:t.amsSelect2MethodType||"POST",cache:!1,method:t.amsSelect2QueryMethod,params:t.amsSelect2QueryParams||{},success:function(e,t){return i.helpers.select2QueryMethodSuccessCallback.call(a,e,t,n)},error:i.error.show};s.params[t.amsSelect2QueryParamName||"query"]=n.term,s.params[t.amsSelect2PageParamName||"page"]=n.page,s.params[t.amsSelect2ContextParamName||"context"]=n.context,s=e.extend({},s,t.amsSelect2QueryOptions),s=i.executeFunctionByName(t.amsSelect2QueryInitCallback,a,s)||s,i.ajax.check(e.jsonRpc,i.baseURL+"ext/jquery-jsonrpc"+i.devext+".js",function(){e.jsonRpc(s)})},n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2Tags?n.tags=t.amsSelect2Tags:t.amsSelect2Data&&(n.data=t.amsSelect2Data),t.amsSelect2EnableFreeTags&&(n.createSearchChoice=function(e){return{id:e,text:(t.amsSelect2FreeTagsPrefix||i.i18n.SELECT2_FREETAG_PREFIX)+e}});var r=e.extend({},n,t.amsSelect2Options);r=i.executeFunctionByName(t.amsSelect2InitCallback,a,r)||r;var o=a.select2(r);i.executeFunctionByName(t.amsSelect2AfterInitCallback,a,o,r),a.hasClass("ordered")&&i.ajax.check(e.fn.select2Sortable,i.baseURL+"ext/jquery-select2-sortable"+i.devext+".js",function(){a.select2Sortable({bindOrder:"sortableStop"})}),a.on("change",function(){void 0!==e(a.get(0).form).data("validator")&&e(a).valid()})})})},maskedit:function(a){var t=e("[data-mask]",a);t.length>0&&i.ajax.check(e.fn.mask,i.baseURL+"ext/jquery-maskedinput-1.4.1"+i.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n={placeholder:void 0===t.amsMaskeditPlaceholder?"X":t.amsMaskeditPlaceholder,complete:i.getFunctionByName(t.amsMaskeditComplete)},s=e.extend({},n,t.amsMaskeditOptions);s=i.executeFunctionByName(t.amsMaskeditInitCallback,a,s)||s;var r=a.mask(a.attr("data-mask"),s);i.executeFunctionByName(t.amsMaskeditAfterInitCallback,a,r,s)})})},inputmask:function(a){var t=e("[data-input-mask]",a);t.length>0&&i.ajax.check(e.fn.inputmask,i.baseURL+"ext/jquery-inputmask-bundle-3.2.8"+i.devext+".js",function(){t.each(function(){var a,t=e(this),n=t.data();a="object"==typeof n.inputMask?n.inputMask:{mask:n.inputMask.toString()};var s=e.extend({},a,n.amsInputmaskOptions);s=i.executeFunctionByName(n.amsInputmaskInitCallback,t,s)||s;var r=t.inputmask(s);i.executeFunctionByName(n.amsInputmaskAfterInitCallback,t,r,s)})})},datepicker:function(a){var t=e(".datepicker",a);t.length>0&&i.ajax.check(e.fn.datetimepicker,i.baseURL+"ext/jquery-datetimepicker"+i.devext+".js",function(a){a&&(i.getCSS(i.baseURL+"../css/ext/jquery-datetimepicker"+i.devext+".css","jquery-datetimepicker"),i.dialog.registerHideCallback(i.helpers.datetimepickerDialogHiddenCallback)),t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||i.lang,format:t.amsDatetimepickerFormat||"d/m/y",datepicker:!0,dayOfWeekStart:1,timepicker:!1,closeOnDateSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,weeks:t.amsDatetimepickerWeeks},s=e.extend({},n,t.amsDatetimepickerOptions);s=i.executeFunctionByName(t.amsDatetimepickerInitCallback,a,s)||s;var r=a.datetimepicker(s);i.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,s)})})},datetimepicker:function(a){var t=e(".datetimepicker",a);t.length>0&&i.ajax.check(e.fn.datetimepicker,i.baseURL+"ext/jquery-datetimepicker"+i.devext+".js",function(a){a&&(i.getCSS(i.baseURL+"../css/ext/jquery-datetimepicker"+i.devext+".css","jquery-datetimepicker"),i.dialog.registerHideCallback(i.helpers.datetimepickerDialogHiddenCallback)),t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||i.lang,format:t.amsDatetimepickerFormat||"d/m/y H:i",datepicker:!0,dayOfWeekStart:1,timepicker:!0,closeOnDateSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,closeOnTimeSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,weeks:t.amsDatetimepickerWeeks},s=e.extend({},n,t.amsDatetimepickerOptions);s=i.executeFunctionByName(t.amsDatetimepickerInitCallback,a,s)||s;var r=a.datetimepicker(s);i.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,s)})})},timepicker:function(a){var t=e(".timepicker",a);t.length>0&&i.ajax.check(e.fn.datetimepicker,i.baseURL+"ext/jquery-datetimepicker"+i.devext+".js",function(a){a&&(i.getCSS(i.baseURL+"../css/ext/jquery-datetimepicker"+i.devext+".css","jquery-datetimepicker"),i.dialog.registerHideCallback(i.helpers.datetimepickerDialogHiddenCallback)),t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||i.lang,format:t.amsDatetimepickerFormat||"H:i",datepicker:!1,timepicker:!0,closeOnTimeSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect},s=e.extend({},n,t.amsDatetimepickerOptions);s=i.executeFunctionByName(t.amsDatetimepickerInitCallback,a,s)||s;var r=a.datetimepicker(s);i.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,s)})})},colorpicker:function(a){var t=e(".colorpicker",a);t.length>0&&i.ajax.check(e.fn.minicolors,i.baseURL+"ext/jquery-minicolors"+i.devext+".js",function(a){a&&i.getCSS(i.baseURL+"../css/ext/jquery-minicolors"+i.devext+".css","jquery-minicolors"),t.each(function(){var a=e(this),t=a.data(),n={position:t.amsColorpickerPosition||a.closest("label.input").data("ams-colorpicker-position")||"bottom left"},s=e.extend({},n,t.amsColorpickerOptions);s=i.executeFunctionByName(t.amsColorpickerInitCallback,a,s)||s;var r=a.minicolors(s);i.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,s)})})},validate:function(a){var t=e("FORM:not([novalidate])",a);t.length>0&&i.ajax.check(e.fn.validate,i.baseURL+"ext/jquery-validate-1.11.1"+i.devext+".js",function(a){if(a&&(e.validator.setDefaults({highlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").addClass("state-error")},unhighlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").removeClass("state-error")},errorElement:"span",errorClass:"state-error",errorPlacement:function(e,a){var t=a.parents("label:first");t.length?e.insertAfter(t):e.insertAfter(a)}}),i.plugins.i18n)){for(var n in i.plugins.i18n.validate)if(i.plugins.i18n.validate.hasOwnProperty(n)){var s=i.plugins.i18n.validate[n];"string"==typeof s&&s.indexOf("{0}")>-1&&(i.plugins.i18n.validate[n]=e.validator.format(s))}e.extend(e.validator.messages,i.plugins.i18n.validate)}t.each(function(){var a=e(this),t=a.data(),n={ignore:null,submitHandler:void 0!==a.attr("data-async")?void 0===t.amsFormSubmitHandler?function(){return e(".state-error",a).removeClass("state-error"),i.ajax.check(e.fn.ajaxSubmit,i.baseURL+"ext/jquery-form-3.49"+i.devext+".js"),i.form.submit(a)}:i.getFunctionByName(t.amsFormSubmitHandler):void 0,invalidHandler:void 0!==a.attr("data-async")?void 0===t.amsFormInvalidHandler?function(t,n){e(".state-error",a).removeClass("state-error");for(var i=0;i<n.errorList.length;i++){var s=n.errorList[i],r=e(s.element).parents(".tab-pane").index()+1;if(r>0){var o=e(".nav-tabs",e(s.element).parents(".tabforms"));e("li:nth-child("+r+")",o).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",o).click()}}}:i.getFunctionByName(t.amsFormInvalidHandler):void 0};e("[data-ams-validate-rules]",a).each(function(a){0===a&&(n.rules={}),n.rules[e(this).attr("name")]=e(this).data("ams-validate-rules")});var s=e.extend({},n,t.amsValidateOptions);s=i.executeFunctionByName(t.amsValidateInitCallback,a,s)||s;var r=a.validate(s);i.executeFunctionByName(t.amsValidateAfterInitCallback,a,r,s)})})},datatable:function(a){var t=e(".datatable",a);t.length>0&&i.ajax.check(e.fn.dataTable,i.baseURL+"ext/jquery-dataTables-1.9.4"+i.devext+".js",function(a){i.ajax.check(e.fn.dataTableExt.oPagination.bootstrap_full,i.baseURL+"myams-dataTables"+i.devext+".js",function(){e(t).each(function(){var a,t=e(this),n=t.data(),s=(n.amsDatatableExtensions||"").split(/\s+/),r=n.amsDatatableSdom||"W"+(s.indexOf("colreorder")>=0||s.indexOf("colreorderwithresize")>=0?"R":"")+"<'dt-top-row'"+(s.indexOf("colvis")>=0?"C":"")+(!1===n.amsDatatablePagination||!1===n.amsDatatablePaginationSize?"":"L")+(!1===n.amsDatatableGlobalFilter?"":"F")+">r<'dt-wrapper't"+(s.indexOf("scroller")>=0?"S":"")+"><'dt-row dt-bottom-row'<'row'<'col-sm-6'"+(!1===n.amsDatatableInformation?"":"i")+"><'col-sm-6 text-right'p>>",o=n.amsDatatableSorting;if("string"==typeof o){var c=o.split(";");for(o=[],a=0;a<c.length;a++){var l=c[a].split(",");l[0]=parseInt(l[0]),o.push(l)}}var d,m=[],u=e("th",t).listattr("data-ams-datatable-sortable");for(a=0;a<u.length;a++){var f=u[a];void 0!==f&&((d=m[a]||{}).bSortable=f,m[a]=d)}var h=e("th",t).listattr("data-ams-datatable-stype");for(a=0;a<h.length;a++){var p=h[a];p&&((d=m[a]||{}).sType=p,m[a]=d)}var g={bJQueryUI:!1,bFilter:!1!==n.amsDatatableGlobalFilter||s.indexOf("columnfilter")>=0,bPaginate:!1!==n.amsDatatablePagination,bInfo:!1!==n.amsDatatableInfo,bSort:!1!==n.amsDatatableSort,aaSorting:o,aoColumns:m.length>0?m:void 0,bDeferRender:!0,bAutoWidth:!1,iDisplayLength:n.amsDatatableDisplayLength||25,sPaginationType:n.amsDatatablePaginationType||"bootstrap_full",sDom:r,oLanguage:i.plugins.i18n.datatables,fnInitComplete:function(a,t){e(".ColVis_Button").addClass("btn btn-default btn-sm").html((i.plugins.i18n.datatables.sColumns||"Columns")+' <i class="fa fa-fw fa-caret-down"></i>')}},b=e.extend({},g,n.amsDatatableOptions),v=[],x=[],y=[];if(s.length>0)for(a=0;a<s.length;a++)switch(s[a]){case"autofill":v.push(e.fn.dataTable.AutoFill),x.push(i.baseURL+"ext/jquery-dataTables-autoFill"+i.devext+".js");break;case"columnfilter":v.push(e.fn.columnFilter),x.push(i.baseURL+"ext/jquery-dataTables-columnFilter"+i.devext+".js");break;case"colreorder":v.push(e.fn.dataTable.ColReorder),x.push(i.baseURL+"ext/jquery-dataTables-colReorder"+i.devext+".js");break;case"colreorderwithresize":v.push(window.ColReorder),x.push(i.baseURL+"ext/jquery-dataTables-colReorderWithResize"+i.devext+".js");break;case"colvis":v.push(e.fn.dataTable.ColVis),x.push(i.baseURL+"ext/jquery-dataTables-colVis"+i.devext+".js"),y.push(function(){b.oColVis=e.extend({},{activate:"click",sAlign:"right"},n.amsDatatableColvisOptions)});break;case"editable":v.push(e.fn.editable),x.push(i.baseURL+"ext/jquery-jeditable"+i.devext+".js"),v.push(e.fn.makeEditable),x.push(i.baseURL+"ext/jquery-dataTables-editable"+i.devext+".js");break;case"fixedcolumns":v.push(e.fn.dataTable.FixedColumns),x.push(i.baseURL+"ext/jquery-dataTables-fixedColumns"+i.devext+".js");break;case"fixedheader":v.push(e.fn.dataTable.Fixedheader),x.push(i.baseURL+"ext/jquery-dataTables-fixedHeader"+i.devext+".js");break;case"keytable":v.push(window.keyTable),x.push(i.baseURL+"ext/jquery-dataTables-keyTable"+i.devext+".js");break;case"rowgrouping":v.push(e.fn.rowGrouping()),x.push(i.baseURL+"ext/jquery-dataTables-rowGrouping"+i.devext+".js");break;case"rowreordering":v.push(e.fn.rowReordering),x.push(i.baseURL+"ext/jquery-dataTables-rowReordering"+i.devext+".js");break;case"scroller":v.push(e.fn.dataTable.Scroller),x.push(i.baseURL+"ext/jquery-dataTables-scroller"+i.devext+".js")}y.push(function(){b=i.executeFunctionByName(n.amsDatatableInitCallback,t,b)||b;try{var r=t.dataTable(b);if(i.executeFunctionByName(n.amsDatatableAfterInitCallback,t,r,b),s.length>0)for(a=0;a<s.length;a++)switch(s[a]){case"autofill":var o=e.extend({},n.amsDatatableAutofillOptions,b.autofill);o=i.executeFunctionByName(n.amsDatatableAutofillInitCallback,t,o)||o,t.data("ams-autofill",void 0===n.amsDatatableAutofillConstructor?new e.fn.dataTable.AutoFill(t,o):i.executeFunctionByName(n.amsDatatableAutofillConstructor,t,r,o));break;case"columnfilter":var c=e.extend({},{sPlaceHolder:"head:after"},n.amsDatatableColumnfilterOptions,b.columnfilter);c=i.executeFunctionByName(n.amsDatatableColumnfilterInitCallback,t,c)||c,t.data("ams-columnfilter",void 0===n.amsDatatableColumnfilterConstructor?r.columnFilter(c):i.executeFunctionByName(n.amsDatatableColumnfilterConstructor,t,r,c));break;case"editable":var l=e.extend({},n.amsDatatableEditableOptions,b.editable);l=i.executeFunctionByName(n.amsDatatableEditableInitCallback,t,l)||l,t.data("ams-editable",void 0===n.amsDatatableEditableConstructor?t.makeEditable(l):i.executeFunctionByName(n.amsDatatableEditableConstructor,t,r,l));break;case"fixedcolumns":var d=e.extend({},n.amsDatatableFixedcolumnsOptions,b.fixedcolumns);d=i.executeFunctionByName(n.amsDatatableFixedcolumnsInitCallback,t,d)||d,t.data("ams-fixedcolumns",void 0===n.amsDatatableFixedcolumnsConstructor?new e.fn.dataTable.FixedColumns(t,d):i.executeFunctionByName(n.amsDatatableFixedcolumnsConstructor,t,r,d));break;case"fixedheader":var m=e.extend({},n.amsDatatableFixedheaderOptions,b.fixedheader);m=i.executeFunctionByName(n.amsDatatableFixedheadeInitCallback,t,m)||m,t.data("ams-fixedheader",void 0===n.amsDatatableFixedheaderConstructor?new e.fn.dataTable.FixedHeader(t,m):i.executeFunctionByName(n.amsDatatableFixedheaderConstructor,t,r,m));break;case"keytable":var u={table:t.get(0),datatable:r},f=e.extend({},u,n.amsDatatableKeytableOptions,b.keytable);f=i.executeFunctionByName(n.amsDatatableKeytableInitCallback,t,f)||f,t.data("ams-keytable",void 0===n.amsDatatableKeytableConstructor?new KeyTable(f):i.executeFunctionByName(n.amsDatatableKeytableConstructor,t,r,f));break;case"rowgrouping":var h=e.extend({},n.amsDatatableRowgroupingOptions,b.rowgrouping);h=i.executeFunctionByName(n.amsDatatableRowgroupingInitCallback,t,h)||h,t.data("ams-rowgrouping",void 0===n.amsDatatableRowgroupingConstructor?t.rowGrouping(h):i.executeFunctionByName(n.amsDatatableRowgroupingConstructor,t,r,h));break;case"rowreordering":var p=e.extend({},n.amsDatatableRowreorderingOptions,b.rowreordering);p=i.executeFunctionByName(n.amsDatatableRowreorderingInitCallback,t,p)||p,t.data("ams-rowreordering",void 0===n.amsDatatableRowreorderingConstructor?t.rowReordering(p):i.executeFunctionByName(n.amsDatatableRowreorderingConstructor,t,r,p))}if(n.amsDatatableFinalizeCallback){var g=n.amsDatatableFinalizeCallback.split(/\s+/);if(g.length>0)for(a=0;a<g.length;a++)i.executeFunctionByName(g[a],t,r,b)}}catch(e){}}),i.ajax.check(v,x,y)})})})},tablednd:function(a){var t=e(".table-dnd",a);t.length>0&&i.ajax.check(e.fn.tableDnD,i.baseURL+"ext/jquery-tablednd"+i.devext+".js",function(a){t.each(function(){var a=e(this),t=a.data();t.amsTabledndDragHandle?e("tr",a).addClass("no-drag-handle"):e(a).on("mouseover","tr",function(){e(this.cells[0]).addClass("drag-handle")}).on("mouseout","tr",function(){e(this.cells[0]).removeClass("drag-handle")});var n={onDragClass:t.amsTabledndDragClass||"dragging-row",onDragStart:i.getFunctionByName(t.amsTabledndDragStart),dragHandle:t.amsTabledndDragHandle,scrollAmount:t.amsTabledndScrollAmount,onAllowDrop:t.amsTabledndAllowDrop,onDrop:i.getFunctionByName(t.amsTabledndDrop)||function(n,s){var r=t.amsTabledndDropTarget;if(r){e(s).data("ams-disabled-handlers","click");var o=[];e(n.rows).each(function(){var a=e(this).data("ams-element-name");a&&o.push(a)});var c=i.getFunctionByName(r);if("function"==typeof c)c.call(a,n,o);else{if(!r.startsWith(window.location.protocol)){var l=t.amsLocation;l&&(r=l+"/"+r)}i.ajax.post(r,{names:JSON.stringify(o)})}setTimeout(function(){e(s).removeData("ams-disabled-handlers")},50)}return!1}},s=e.extend({},n,t.amsTabledndOptions);s=i.executeFunctionByName(t.amsTabledndInitCallback,a,s)||s;var r=a.tableDnD(s);i.executeFunctionByName(t.amsTabledndAfterInitCallback,a,r,s)})})},wizard:function(a){var t=e(".wizard",a);t.length>0&&i.ajax.check(e.fn.bootstrapWizard,i.baseURL+"ext/bootstrap-wizard-1.4.2"+i.devext+".js",function(a){t.each(function(){var a=e(this),t=a.data(),n={withVisible:void 0===t.amsWizardWithVisible||t.amsWizardWithVisible,tabClass:t.amsWizardTabClass,firstSelector:t.amsWizardFirstSelector,previousSelector:t.amsWizardPreviousSelector,nextSelector:t.amsWizardNextSelector,lastSelector:t.amsWizardLastSelector,finishSelector:t.amsWizardFinishSelector,backSelector:t.amsWizardBackSelector,onInit:i.getFunctionByName(t.amsWizardInit),onShow:i.getFunctionByName(t.amsWizardShow),onNext:i.getFunctionByName(t.amsWizardNext),onPrevious:i.getFunctionByName(t.amsWizardPrevious),onFirst:i.getFunctionByName(t.amsWizardFirst),onLast:i.getFunctionByName(t.amsWizardLast),onBack:i.getFunctionByName(t.amsWizardBack),onFinish:i.getFunctionByName(t.amsWizardFinish),onTabChange:i.getFunctionByName(t.amsWizardTabChange),onTabClick:i.getFunctionByName(t.amsWizardTabClick),onTabShow:i.getFunctionByName(t.amsWizardTabShow)},s=e.extend({},n,t.amsWizardOptions);s=i.executeFunctionByName(t.amsWizardInitCallback,a,s)||s;var r=a.bootstrapWizard(s);i.executeFunctionByName(t.amsWizardAfterInitCallback,a,r,s)})})},tinymce:function(a){function t(){e(".tinymce",e(this)).each(function(){var a=tinymce.get(e(this).attr("id"));a&&a.remove()})}var n=e(".tinymce",a);if(n.length>0){var s=i.baseURL+"ext/tinymce"+(i.devmode?"/dev":"");i.ajax.check(window.tinymce,s+"/tinymce"+i.devext+".js",function(a){function r(){n.each(function(){var a=e(this),t=a.data(),n={theme:t.amsTinymceTheme||"modern",language:i.lang,plugins:["advlist autosave autolink lists link image charmap print preview hr anchor pagebreak","searchreplace wordcount visualblocks visualchars code fullscreen","insertdatetime media nonbreaking save table contextmenu directionality","emoticons paste textcolor colorpicker textpattern autoresize"],toolbar1:t.amsTinymceToolbar1||"undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",toolbar2:t.amsTinymceToolbar2||"forecolor backcolor emoticons | charmap link image media | fullscreen preview print | code",content_css:t.amsTinymceContentCss,formats:t.amsTinymceFormats,style_formats:t.amsTinymceStyleFormats,block_formats:t.amsTinymceBlockFormats,valid_classes:t.amsTinymceValidClasses,image_advtab:!0,image_list:i.getFunctionByName(t.amsTinymceImageList)||t.amsTinymceImageList,image_class_list:t.amsTinymceImageClassList,link_list:i.getFunctionByName(t.amsTinymceLinkList)||t.amsTinymceLinkList,link_class_list:t.amsTinymceLinkClassList,height:50,min_height:50,autoresize_min_height:50,autoresize_max_height:500,resize:!0};if(t.amsTinymceExternalPlugins){var s=t.amsTinymceExternalPlugins.split(/\s+/);for(var r in s){var o=a.data("ams-tinymce-plugin-"+s[r]);tinymce.PluginManager.load(s[r],i.getSource(o))}}var c=e.extend({},n,t.amsTinymceOptions);c=i.executeFunctionByName(t.amsTinymceInitCallback,a,c)||c;var l=a.tinymce(c);i.executeFunctionByName(t.amsTinymceAfterInitCallback,a,l,c)})}a?i.getScript(s+"/jquery.tinymce"+i.devext+".js",function(){tinymce.baseURL=s,tinymce.suffix=i.devext,i.skin.registerCleanCallback(t),r()}):r()})}},imgareaselect:function(a){var t=e(".imgareaselect",a);t.length>0&&i.ajax.check(e.fn.imgAreaSelect,i.baseURL+"ext/jquery-imgareaselect-0.9.11-rc1"+i.devext+".js",function(a){a&&i.getCSS(i.baseURL+"../css/ext/jquery-imgareaselect"+i.devext+".css"),t.each(function(){var a=e(this),t=a.data(),n=t.amsImgareaselectParent?a.parents(t.amsImgareaselectParent):"body",s={instance:!0,handles:!0,parent:n,x1:t.amsImgareaselectX1||0,y1:t.amsImgareaselectY1||0,x2:t.amsImgareaselectX2||t.amsImgareaselectImageWidth,y2:t.amsImgareaselectY2||t.amsImgareaselectImageHeight,imageWidth:t.amsImgareaselectImageWidth,imageHeight:t.amsImgareaselectImageHeight,minWidth:128,minHeight:128,aspectRatio:t.amsImgareaselectRatio,onSelectEnd:i.getFunctionByName(t.amsImgareaselectSelectEnd)||function(a,i){var s=t.amsImgareaselectTargetField||"image_";e('input[name="'+s+'x1"]',n).val(i.x1),e('input[name="'+s+'y1"]',n).val(i.y1),e('input[name="'+s+'x2"]',n).val(i.x2),e('input[name="'+s+'y2"]',n).val(i.y2)}},r=e.extend({},s,t.amsImgareaselectOptions);r=i.executeFunctionByName(t.amsImgareaselectInitCallback,a,r)||r;var o=a.imgAreaSelect(r);i.executeFunctionByName(t.amsImgareaselectAfterInitCallback,a,o,r),setTimeout(function(){o.update()},250)})})},fancybox:function(a){var t=e(".fancybox",a);t.length>0&&i.ajax.check(e.fn.fancybox,i.baseURL+"ext/jquery-fancybox-2.1.5"+i.devext+".js",function(a){a&&i.getCSS(i.baseURL+"../css/ext/jquery-fancybox-2.1.5"+i.devext+".css"),t.each(function(){var a=e(this),t=a.data(),n=a;t.amsFancyboxElements&&(n=e(t.amsFancyboxElements,a));var s=(t.amsFancyboxHelpers||"").split(/\s+/);if(s.length>0)for(var r=0;r<s.length;r++){var o=s[r];switch(o){case"buttons":i.ajax.check(e.fancybox.helpers.buttons,i.baseURL+"ext/fancybox-helpers/fancybox-buttons"+i.devext+".js");break;case"thumbs":i.ajax.check(e.fancybox.helpers.thumbs,i.baseURL+"ext/fancybox-helpers/fancybox-thumbs"+i.devext+".js");break;case"media":i.ajax.check(e.fancybox.helpers.media,i.baseURL+"ext/fancybox-helpers/fancybox-media"+i.devext+".js")}}var c={type:t.amsFancyboxType,padding:t.amsFancyboxPadding||10,margin:t.amsFancyboxMargin||10,loop:t.amsFancyboxLoop,beforeLoad:i.getFunctionByName(t.amsFancyboxBeforeLoad)||function(){var a;if(t.amsFancyboxTitleGetter&&(a=i.executeFunctionByName(t.amsFancyboxTitleGetter,this)),!a){var n=e("*:first",this.element);(a=n.attr("original-title")||n.attr("title"))||(a=e(this.element).attr("original-title")||e(this.element).attr("title"))}this.title=a},afterLoad:i.getFunctionByName(t.amsFancyboxAfterLoad),helpers:{title:{type:"inside"}}};if(s.length>0)for(r=0;r<s.length;r++)switch(o=s[r]){case"buttons":c.helpers.buttons={position:t.amsFancyboxButtonsPosition||"top"};break;case"thumbs":c.helpers.thumbs={width:t.amsFancyboxThumbsWidth||50,height:t.amsFancyboxThumbsHeight||50};break;case"media":c.helpers.media=!0}var l=e.extend({},c,t.amsFancyboxOptions);l=i.executeFunctionByName(t.amsFancyboxInitCallback,a,l)||l;var d=n.fancybox(l);i.executeFunctionByName(t.amsFancyboxAfterInitCallback,a,d,l)})})},graphs:function(a){var t=e(".sparkline",a);t.length>0&&i.ajax.check(i.graphs,i.baseURL+"myams-graphs"+i.devext+".js",function(){i.graphs.init(t)})},scrollbars:function(a){var t=e(".scrollbar",a);t.length>0&&i.ajax.check(e.event.special.mousewheel,i.baseURL+"ext/jquery-mousewheel.min.js",function(){i.ajax.check(e.fn.mCustomScrollbar,i.baseURL+"ext/jquery-mCustomScrollbar"+i.devext+".js",function(a){a&&i.getCSS(i.baseURL+"../css/ext/jquery-mCustomScrollbar.css","jquery-mCustomScrollbar"),t.each(function(){var a=e(this),t=a.data(),n={theme:t.amsScrollbarTheme||"light"},s=e.extend({},n,t.amsScrollbarOptions);s=i.executeFunctionByName(t.amsScrollbarInitCallback,a,s)||s;var r=a.mCustomScrollbar(s);i.executeFunctionByName(t.amsScrollbarAfterInitCallback,a,r,s)})})})}}},n.callbacks={init:function(a){e("[data-ams-callback]",a).each(function(){var a=this,n=e(a).data(),s=i.getFunctionByName(n.amsCallback);void 0===s?n.amsCallbackSource?i.getScript(n.amsCallbackSource,function(){i.executeFunctionByName(n.amsCallback,a,n.amsCallbackOptions)}):t&&t.warn&&t.warn("Undefined callback: "+n.amsCallback):s.call(a,n.amsCallbackOptions)})},alert:function(a){var t=e(this).data(),n=e.extend({},a,t.amsAlertOptions),s=e(t.amsAlertParent||n.parent||this),r=t.amsAlertStatus||n.status||"info",o=t.amsAlertHeader||n.header,c=t.amsAlertMessage||n.message,l=t.amsAlertSubtitle||n.subtitle,d=void 0===t.amsAlertMargin?void 0!==n.margin&&n.margin:t.amsAlertMargin;i.skin.alert(s,r,o,c,l,d)},messageBox:function(a){var t=e(this).data(),n=e.extend({},a,t.amsMessageboxOptions),s=e.extend({},n,{title:t.amsMessageboxTitle||n.title||"",content:t.amsMessageboxContent||n.content||"",icon:t.amsMessageboxIcon||n.icon,number:t.amsMessageboxNumber||n.number,timeout:t.amsMessageboxTimeout||n.timeout}),r=t.amsMessageboxStatus||n.status||"info",o=i.getFunctionByName(t.amsMessageboxCallback||n.callback);i.skin.messageBox(r,s,o)},smallBox:function(a){var t=e(this).data(),n=e.extend({},a,t.amsSmallboxOptions),s=e.extend({},n,{title:t.amsSmallboxTitle||n.title||"",content:t.amsSmallboxContent||n.content||"",icon:t.amsSmallboxIcon||n.icon,iconSmall:t.amsSmallboxIconSmall||n.iconSmall,timeout:t.amsSmallboxTimeout||n.timeout}),r=t.amsSmallboxStatus||n.status||"info",o=i.getFunctionByName(t.amsSmallboxCallback||n.callback);i.skin.smallBox(r,s,o)}},n.events={init:function(a){e("[data-ams-events-handlers]",a).each(function(){var a=e(this),t=a.data("ams-events-handlers");if(t)for(var n in t)t.hasOwnProperty(n)&&a.on(n,i.getFunctionByName(t[n]))})}},n.container={changeOrder:function(a,t){e('input[name="'+e(this).data("ams-input-name")+'"]',e(this)).val(t.join(";"))},deleteElement:function(a){return function(){var a=e(this);n.skin.bigBox({title:i.i18n.WARNING,content:'<i class="text-danger fa fa-fw fa-bell"></i>&nbsp; '+i.i18n.DELETE_WARNING,status:"info",buttons:i.i18n.BTN_OK_CANCEL},function(e){if(e===i.i18n.BTN_OK){var t=a.parents("table").first(),s=t.data("ams-location")||"",r=a.parents("tr").first(),o=r.data("ams-delete-target")||t.data("ams-delete-target")||"delete-element.json",c=r.data("ams-element-name");n.ajax.post(s+"/"+o,{object_name:c},function(e,a){"success"===e.status?(t.hasClass("datatable")?t.dataTable().fnDeleteRow(r[0]):r.remove(),e.handle_json&&n.ajax.handleJSON(e)):n.ajax.handleJSON(e)})}})}}},n.skin={_setPageHeight:function(){var a=e("#main").height(),t=(i.leftPanel.height(),e(window).height()-i.navbarHeight);a>t?i.root.css("min-height",a+i.navbarHeight):i.root.css("min-height",t),i.leftPanel.css("min-height",t),i.leftPanel.css("max-height",t)},_checkMobileWidth:function(){e(window).width()<979?i.root.addClass("mobile-view-activated"):i.root.hasClass("mobile-view-activated")&&i.root.removeClass("mobile-view-activated")},_showShortcutButtons:function(){i.shortcuts.animate({height:"show"},200,"easeOutCirc"),i.root.addClass("shortcut-on")},_hideShortcutButtons:function(){i.shortcuts.animate({height:"hide"},300,"easeOutCirc"),i.root.removeClass("shortcut-on")},checkNotification:function(){var a=e("#activity > .badge");parseInt(a.text())>0?a.removeClass("hidden").addClass("bg-color-red bounceIn animated"):a.addClass("hidden").removeClass("bg-color-red bounceIn animated")},refreshNotificationsPanel:function(a){var t=e(this);t.addClass("disabled"),e("i",t).addClass("fa-spin"),e('input[name="activity"]:checked',"#user-activity").change(),e("i",t).removeClass("fa-spin"),t.removeClass("disabled")},_initDesktopWidgets:function(t){if(i.enableWidgets){var n=e(".ams-widget",t);n.length>0&&i.ajax.check(e.fn.MyAMSWidget,i.baseURL+"myams-widgets"+i.devext+".js",function(){n.each(function(){var a=e(this),t=a.data(),n=e.extend({},{deleteSettingsKey:"#deletesettingskey-options",deletePositionKey:"#deletepositionkey-options"},t.amsWidgetOptions);n=i.executeFunctionByName(t.amsWidgetInitcallback,a,n)||n,a.MyAMSWidget(n)}),a.MyAMSWidget.initWidgetsGrid(e(".ams-widget-grid",t))})}},_initMobileWidgets:function(e){i.enableMobile&&i.enableWidgets&&i.skin._initDesktopWidgets(e)},alert:function(a,t,n,s,r,o){"error"===t&&(t="danger"),e(".alert-"+t,a).not(".persistent").remove();var c='<div class="'+(o?"margin-10":"")+" alert alert-block alert-"+t+' padding-5 fade in"><a class="close" data-dismiss="alert"><i class="fa fa-check"></i></a><h4 class="alert-heading"><i class="fa fa-fw fa-warning"></i> '+n+"</h4>"+(r?"<p>"+r+"</p>":"");if("string"==typeof s)c+="<ul><li>"+s+"</li></ul>";else if(s){c+="<ul>";for(var l in s)e.isNumeric(l)&&(c+="<li>"+s[l]+"</li>");c+="</ul>"}e(c+="</div>").prependTo(a);a.exists&&i.ajax.check(e.scrollTo,i.baseURL+"ext/jquery-scrollTo.min.js",function(){e.scrollTo(a,{offset:{top:-50}})})},bigBox:function(e,a){i.ajax.check(i.notify,i.baseURL+"myams-notify"+i.devext+".js",function(){i.notify.messageBox(e,a)})},messageBox:function(e,a,t){"object"==typeof e&&(t=a,a=e||{},e="info"),i.ajax.check(i.notify,i.baseURL+"myams-notify"+i.devext+".js",function(){switch(e){case"error":case"danger":a.color="#C46A69";break;case"warning":a.color="#C79121";break;case"success":a.color="#739E73";break;default:a.color=a.color||"#3276B1"}a.sound=!1,i.notify.bigBox(a,t)})},smallBox:function(e,a,t){"object"==typeof e&&(t=a,a=e||{},e="info"),i.ajax.check(i.notify,i.baseURL+"myams-notify"+i.devext+".js",function(){switch(e){case"error":case"danger":a.color="#C46A69";break;case"warning":a.color="#C79121";break;case"success":a.color="#739E73";break;default:a.color=a.color||"#3276B1"}a.sound=!1,i.notify.smallBox(a,t)})},_drawBreadCrumb:function(){var a=e("OL.breadcrumb","#ribbon");e("li",a).not(".parent").remove(),e("li",a).exists()||a.append(e("<li></li>").append(e("<a></a>").text(i.i18n.HOME).addClass("padding-right-5").attr("href",e('nav a[href!="#"]:first').attr("href")))),e("LI.active >A","nav").each(function(){var t=e(this),n=e.trim(t.clone().children(".badge").remove().end().text()),i=e("<li></li>").append(t.attr("href").replace(/^#/,"")?e("<a></a>").html(n).attr("href",t.attr("href")):n);a.append(i)})},checkURL:function(){function a(a){e(".active",n).removeClass("active"),a.addClass("open").addClass("active"),a.parents("li").addClass("open active").children("ul").addClass("active").show(),a.parents("li:first").removeClass("open"),a.parents("ul").addClass(a.attr("href").replace(/^#/,"")?"active":"").show()}var t,n=e("nav"),s=location.hash,r=s.replace(/^#/,"");if(r){var o=e("#content");o.exists()||(o=e("body")),(t=e('A[href="'+s+'"]',n)).exists()&&a(t),i.skin.loadURL(r,o,{afterLoadCallback:function(){var a=e("html head title").data("ams-title-prefix");document.title=(a?a+" > ":"")+(e("[data-ams-page-title]:first",o).data("ams-page-title")||t.attr("title")||document.title)}})}else{var c=e("[data-ams-active-menu]").data("ams-active-menu");(t=c?e('A[href="'+c+'"]',n):e('>UL >LI >A[href!="#"]',n).first()).exists()&&(a(t),c?i.skin._drawBreadCrumb():window.location.hash=t.attr("href"))}},_clean_callbacks:[],registerCleanCallback:function(e){var a=i.skin._clean_callbacks;a.indexOf(e)<0&&a.push(e)},unregisterCleanCallback:function(e){var a=i.skin._clean_callbacks,t=a.indexOf(e);t>=0&&a.splice(t,1)},cleanContainer:function(e){for(var a=i.skin._clean_callbacks,t=0;t<a.length;t++)a[t].call(e)},loadURL:function(a,t,n,s){a.startsWith("#")&&(a=a.substr(1)),"function"==typeof n?(s=n,n={}):void 0===n&&(n={}),t=e(t);var r={type:"GET",url:a,dataType:"html",cache:!1,beforeSend:function(){if(n&&n.preLoadCallback&&i.executeFunctionByName(n.preLoadCallback,this),i.skin.cleanContainer(t),t.html('<h1 class="loading"><i class="fa fa-cog fa-spin"></i> '+i.i18n.LOADING+" </h1>"),t[0]===e("#content")[0]){i.skin._drawBreadCrumb();var a=e("html head title").data("ams-title-prefix");document.title=(a?a+" > ":"")+e(".breadcrumb LI:last-child").text(),e("html, body").animate({scrollTop:0},"fast")}else t.animate({scrollTop:0},"fast")},success:function(a,r,o){if(s)i.executeFunctionByName(s,this,a,r,o,n);else{var c=i.ajax.getResponse(o),l=c.contentType,d=c.data;switch(e(".loading",t).remove(),l){case"json":i.ajax.handleJSON(d,t);break;case"script":case"xml":break;case"html":case"text":default:t.parents(".hidden").removeClass("hidden"),e(".alert",t.parents(".alerts-container")).remove(),t.css({opacity:"0.0"}).html(a).removeClass("hidden").delay(50).animate({opacity:"1.0"},300),i.initContent(t),i.form.setFocus(t)}n&&n.afterLoadCallback&&i.executeFunctionByName(n.afterLoadCallback,this),i.stats.logPageview()}},error:function(e,a,n){t.html('<h3 class="error"><i class="fa fa-warning txt-color-orangeDark"></i> '+i.i18n.ERROR+n+"</h3>"+e.responseText)},async:void 0===n.async||n.async},o=e.extend({},r,n);e.ajax(o)},setLanguage:function(e){var a=e.lang;switch(e.handler_type||"json"){case"json":var t=e.method||"setUserLanguage";i.jsonrpc.post(t,{lang:a},function(){window.location.reload(!0)});break;case"ajax":var n=e.href||"setUserLanguage";i.ajax.post(n,{lang:a},function(){window.location.reload(!0)})}},logout:function(){window.location=i.loginURL}},n.stats={logPageview:function(e){if(void 0!==a._gaq){var t=a.window.location;a._gaq.push(["_trackPageview",e||t.pathname+t.hash])}},logEvent:function(e,t,n){void 0!==a._gaq&&("object"==typeof e&&(t=e.action,n=e.label,e=e.category),a._gaq.push(["_trackEvent",e,t,n]))}},n.initPage=function(){var a=e("body");i.root=a,i.leftPanel=e("#left-panel"),i.shortcuts=e("#shortcut"),i.plugins.initData(a);var t=e.ajaxSettings.xhr;e.ajaxSetup({progress:i.ajax.progress,progressUpload:i.ajax.progress,xhr:function(){var e=t();if(e&&"function"==typeof e.addEventListener){var a=this;a&&a.progress&&e.addEventListener("progress",function(e){a.progress(e)},!1)}return e}}),e(document).ajaxStart(i.ajax.start),e(document).ajaxStop(i.ajax.stop),e(document).ajaxError(i.error.ajax),i.isMobile?(i.root.addClass("mobile-detected"),i.device="mobile",i.enableFastclick&&i.ajax.check(e.fn.noClickDelay,i.baseURL+"/ext/jquery-smartclick"+i.devext+".js",function(){e("NAV UL A").noClickDelay(),e("A","#hide-menu").noClickDelay()})):(i.root.addClass("desktop-detected"),i.device="desktop"),e("#hide-menu >:first-child > A").click(function(e){a.toggleClass("hidden-menu"),e.preventDefault()}),e("#show-shortcut").click(function(e){i.shortcuts.is(":visible")?i.skin._hideShortcutButtons():i.skin._showShortcutButtons(),e.preventDefault()}),i.shortcuts.click(function(e){i.skin._hideShortcutButtons()}),e(document).mouseup(function(e){i.shortcuts.is(e.target)||0!==i.shortcuts.has(e.target).length||i.skin._hideShortcutButtons()}),e("#search-mobile").click(function(){i.root.addClass("search-mobile")}),e("#cancel-search-js").click(function(){i.root.removeClass("search-mobile")}),e("#activity").click(function(a){var t=e(this),n=t.next(".ajax-dropdown");n.is(":visible")?(n.fadeOut(150),t.removeClass("active")):(n.css("left",t.position().left-n.innerWidth()/2+t.innerWidth()/2).fadeIn(150),t.addClass("active")),a.preventDefault()}),i.skin.checkNotification(),e(document).mouseup(function(a){var t=e(".ajax-dropdown");t.is(a.target)||0!==t.has(a.target).length||t.fadeOut(150).prev().removeClass("active")}),e('input[name="activity"]').change(function(a){var t=e(this).data("ams-url");if(t){a.preventDefault(),a.stopPropagation();var n=i.getFunctionByName(t);if("function"==typeof n&&(t=n.call(this)),"function"==typeof t)t.call(this);else{var s=e(".ajax-notifications");i.skin.loadURL(t,s)}}}),e("a","#logout").click(function(a){a.preventDefault(),a.stopPropagation(),i.loginURL=e(this).attr("href"),i.skin.bigBox({title:"<i class='fa fa-sign-out txt-color-orangeDark'></i> "+i.i18n.LOGOUT+" <span class='txt-color-orangeDark'><strong>"+e("#show-shortcut").text()+"</strong></span> ?",content:i.i18n.LOGOUT_COMMENT,buttons:i.i18n.BTN_YES_NO},function(e){e===i.i18n.BTN_YES&&(i.root.addClass("animated fadeOutUp"),setTimeout(i.skin.logout,1e3))})});var n=e("nav");e("UL",n).myams_menu({accordion:!1!==n.data("ams-menu-accordion"),speed:i.menuSpeed}),e(".minifyme").click(function(a){e("BODY").toggleClass("minified"),e(this).effect("highlight",{},500),a.preventDefault()}),e("#refresh").click(function(e){i.skin.bigBox({title:"<i class='fa fa-refresh' style='color: green'></i> "+i.i18n.CLEAR_STORAGE_TITLE,content:i.i18n.CLEAR_STORAGE_CONTENT,buttons:"["+i.i18n.BTN_CANCEL+"]["+i.i18n.BTN_OK+"]"},function(e){e===i.i18n.BTN_OK&&localStorage&&(localStorage.clear(),location.reload())}),e.preventDefault()}),a.on("click",function(a){var t=e(this);t.is(a.target)||0!==t.has(a.target).length||0!==e(".popover").has(a.target).length||t.popover("hide")}),i.ajax.check(e.resize,i.baseURL+"ext/jquery-resize"+i.devext+".js",function(){e("#main").resize(function(){i.skin._setPageHeight(),i.skin._checkMobileWidth()}),n.resize(function(){i.skin._setPageHeight()})}),i.ajaxNav&&(e(document).on("click",'a[href="#"]',function(e){e.preventDefault()}),e(document).on("click",'a[href!="#"]:not([data-toggle]), [data-ams-url]:not([data-toggle])',function(a){var t=e(a.currentTarget),n=t.data("ams-disabled-handlers");if(!0!==n&&"click"!==n&&"all"!==n){var s=t.attr("href")||t.data("ams-url");if(s&&!s.startsWith("javascript")&&!t.attr("target")&&!0!==t.data("ams-context-menu")){a.preventDefault(),a.stopPropagation();var r=i.getFunctionByName(s);if("function"==typeof r&&(s=r.call(t)),"function"==typeof s)s.call(t);else if(s=s.replace(/\%23/,"#"),a.ctrlKey)window.open(s);else{var o=t.data("ams-target");o?i.form.confirmChangedForm(o,function(){i.skin.loadURL(s,o,t.data("ams-link-options"),t.data("ams-link-callback"))}):i.form.confirmChangedForm(function(){s.startsWith("#")?s!==location.hash&&(i.root.hasClass("mobile-view-activated")?(i.root.removeClass("hidden-menu"),window.setTimeout(function(){window.location.hash=s},50)):window.location.hash=s):window.location=s})}}}}),e(document).on("click",'a[target="_blank"]',function(a){a.preventDefault();var t=e(a.currentTarget);window.open(t.attr("href")),i.stats.logEvent(t.data("ams-stats-category")||"Navigation",t.data("ams-stats-action")||"External",t.data("ams-stats-label")||t.attr("href"))}),e(document).on("click",'a[target="_top"]',function(a){a.preventDefault(),i.form.confirmChangedForm(function(){window.location=e(a.currentTarget).attr("href")})}),e(window).on("hashchange",i.skin.checkURL)),e(document).off("click.modal").on("click",'[data-toggle="modal"]',function(a){var t=e(this),n=t.data("ams-disabled-handlers");!0!==n&&"click"!==n&&"all"!==n&&!0!==t.data("ams-context-menu")&&(!0===t.data("ams-stop-propagation")&&a.stopPropagation(),a.preventDefault(),i.dialog.open(t),t.parents("#shortcut").exists()&&setTimeout(i.skin._hideShortcutButtons,300))}),e(document).on("click",'button[type="submit"], button.submit',function(){var a=e(this);e(a.get(0).form).data("ams-submit-button",a)}),e(document).on("click",'input[type="checkbox"][readonly]',function(){return!1}),e(document).on("click","[data-ams-click-handler]",function(a){var t=e(this),n=t.data("ams-disabled-handlers");if(!0!==n&&"click"!==n&&"all"!==n){var s=t.data();if(s.amsClickHandler){!0!==s.amsStopPropagation&&!0!==s.amsClickStopPropagation||a.stopPropagation(),!0!==s.amsClickKeepDefault&&a.preventDefault();var r=i.getFunctionByName(s.amsClickHandler);void 0!==r&&r.call(t,s.amsClickHandlerOptions)}}}),e(document).on("change","[data-ams-change-handler]",function(a){var t=e(this);if(!t.prop("readonly")){var n=t.data("ams-disabled-handlers");if(!0!==n&&"change"!==n&&"all"!==n){var s=t.data();if(s.amsChangeHandler){!0!==s.amsChangeKeepDefault&&a.preventDefault();var r=i.getFunctionByName(s.amsChangeHandler);void 0!==r&&r.call(t,s.amsChangeHandlerOptions)}}}}),e(document).on("reset","form",function(a){var t=e(this);setTimeout(function(){e(".alert-danger, SPAN.state-error",t).not(".persistent").remove(),e("LABEL.state-error",t).removeClass("state-error"),e('INPUT.select2[type="hidden"]',t).each(function(){var a=e(this),t=a.data("select2");a.select2("val",a.data("ams-select2-input-value").split(t.opts.separator))}),t.find(".select2").trigger("change"),e("[data-ams-reset-callback]",t).each(function(){var a=e(this),n=a.data(),s=i.getFunctionByName(n.amsResetCallback);void 0!==s&&s.call(t,a,n.amsResetCallbackOptions)})},10),i.form.setFocus(t)}),e(document).on("reset","[data-ams-reset-handler]",function(a){var t=e(this),n=t.data();if(n.amsResetHandler){!0!==n.amsResetKeepDefault&&a.preventDefault();var s=i.getFunctionByName(n.amsResetHandler);void 0!==s&&s.call(t,n.amsResetHandlerOptions)}}),e(document).on("change",'input[type="file"]',function(a){a.preventDefault();var t=e(this),n=t.parent(".button");n.exists()&&n.parent().hasClass("input-file")&&n.next('input[type="text"]').val(t.val())}),e(document).on("focusin",function(a){e(a.target).closest(".mce-window").length&&a.stopImmediatePropagation()}),e("a[data-toggle=tab]",".nav-tabs").on("click",function(a){if(e(this).parent("li").hasClass("disabled"))return a.preventDefault(),!1}),e(document).on("show.bs.tab",function(a){var t=e(a.target),n=t.data();if(n.amsUrl){if(n.amsTabLoaded)return;try{t.append('<i class="fa fa-spin fa-cog margin-left-5"></i>'),i.skin.loadURL(n.amsUrl,t.attr("href"),{afterLoadCallback:function(){n.amsTabLoadOnce&&t.data("ams-tab-loaded",!0)}})}finally{e("i",t).remove()}}}),e(document).on("hide.bs.modal",function(a){var t=e(a.target);i.form.confirmChangedForm(t,function(){return t.data("modal").isShown=!0,!0},function(){return a.preventDefault(),!1})}),i.initContent(document),i.ajaxNav&&n.exists()&&i.skin.checkURL(),i.form.setFocus(document),e(window).on("beforeunload",i.form.checkBeforeUnload)},n.initContent=function(a){e(".tipsy").remove(),e("[rel=tooltip]",a).tooltip(),e("[rel=popover]",a).popover(),e("[rel=popover-hover]",a).popover({trigger:"hover"}),i.plugins.init(a),i.callbacks.init(a),i.events.init(a),i.form.init(a),"desktop"===i.device?i.skin._initDesktopWidgets(a):i.skin._initMobileWidgets(a),i.skin._setPageHeight()},n.i18n={INFO:"Information",WARNING:"!! WARNING !!",ERROR:"ERROR: ",LOADING:"Loading...",PROGRESS:"Processing",WAIT:"Please wait!",FORM_SUBMITTED:"This form was already submitted...",NO_SERVER_RESPONSE:"No response from server!",ERROR_OCCURED:"An error occured!",ERRORS_OCCURED:"Some errors occured!",BAD_LOGIN_TITLE:"Bad login!",BAD_LOGIN_MESSAGE:"Your anthentication credentials didn't allow you to open a session; please check your credentials or contact administrator.",CONFIRM:"Confirm",CONFIRM_REMOVE:"Removing this content can't be undone. Do you confirm?",CLEAR_STORAGE_TITLE:"Clear Local Storage",CLEAR_STORAGE_CONTENT:"Would you like to RESET all your saved widgets and clear LocalStorage?",BTN_OK:"OK",BTN_CANCEL:"Cancel",BTN_OK_CANCEL:"[OK][Cancel]",BTN_YES:"Yes",BTN_NO:"No",BTN_YES_NO:"[Yes][No]",CLIPBOARD_COPY:"Copy to clipboard with Ctrl+C, and Enter",CLIPBOARD_CHARACTER_COPY_OK:"Character copied to clipboard",CLIPBOARD_TEXT_COPY_OK:"Text copied to clipboard",FORM_CHANGED_WARNING:"Some changes were not saved. These updates will be lost if you leave this page.",DELETE_WARNING:"This change can't be undone. Are you sure that you want to delete this element?",NO_UPDATE:"No changes were applied.",DATA_UPDATED:"Data successfully updated.",HOME:"Home",LOGOUT:"Logout?",LOGOUT_COMMENT:"You can improve your security further after logging out by closing this opened browser",SELECT2_PLURAL:"s",SELECT2_MATCH:"One result is available, press enter to select it.",SELECT2_MATCHES:" results are available, use up and down arrow keys to navigate.",SELECT2_NOMATCHES:"No matches found",SELECT2_SEARCHING:"Searching...",SELECT2_LOADMORE:"Loading more results...",SELECT2_INPUT_TOOSHORT:"Please enter {0} more character{1}",SELECT2_INPUT_TOOLONG:"Please delete {0} character{1}",SELECT2_SELECTION_TOOBIG:"You can only select {0} item{1}",SELECT2_FREETAG_PREFIX:"Free text: ",DT_COLUMNS:"Columns"},n.plugins.i18n={widgets:{},validate:{},datatables:{},fancybox:{ERROR:"Can't load requested content.",RETRY:"Please check URL or try again later.",CLOSE:"Close",NEXT:"Next",PREVIOUS:"Previous"}},e(document).ready(function(){var a=(e=jQuery.noConflict())("HTML"),t=a.attr("lang")||a.attr("xml:lang");t&&!t.startsWith("en")?(n.lang=t,n.getScript(n.baseURL+"i18n/myams_"+t.substr(0,2)+".js",function(){n.initPage()})):n.initPage()})}(jQuery,this);
+"use strict";!function(e,a){var t=a.console;String.prototype.startsWith=function(e){var a=this.length,t=e.length;return!(a<t)&&this.substr(0,t)===e},String.prototype.endsWith=function(e){var a=this.length,t=e.length;return!(a<t)&&this.substr(a-t)===e},Array.prototype.indexOf||(Array.prototype.indexOf=function(e,a){var t=this.length;for((a=(a=Number(a)||0)<0?Math.ceil(a):Math.floor(a))<0&&(a+=t);a<t;a++)if(a in this&&this[a]===e)return a;return-1}),e.expr[":"].hasvalue=function(a,t,n){return""!==e(a).val()},e.expr[":"].econtains=function(a,t,n){return(a.textContent||a.innerText||e(a).text()||"").toLowerCase()===n[3].toLowerCase()},e.expr[":"].withtext=function(a,t,n){return(a.textContent||a.innerText||e(a).text()||"")===n[3]},e.expr[":"].parents=function(a,t,n){return e(a).parents(n[3]).length>0},void 0===e.scrollbarWidth&&(e.scrollbarWidth=function(){var a=e('<div style="width: 50px; height: 50px; overflow: auto"><div/></div>').appendTo("body"),t=a.children(),n=t.innerWidth()-t.height(99).innerWidth();return a.remove(),n}),e.fn.extend({exists:function(){return e(this).length>0},objectOrParentWithClass:function(e){return this.hasClass(e)?this:this.parents("."+e)},listattr:function(a){var t=[];return this.each(function(){t.push(e(this).attr(a))}),t},style:function(e,a,t){if(void 0!==this.get(0)){var n=this.get(0).style;return void 0!==e?void 0!==a?(t=void 0!==t?t:"",n.setProperty(e,a,t),this):n.getPropertyValue(e):n}},removeClassPrefix:function(a){return this.each(function(t,n){var s=n.className.split(" ").map(function(e){return e.startsWith(a)?"":e});n.className=e.trim(s.join(" "))}),this},contextMenu:function(a){function t(t,n,s){var i=e(window)[n](),r=e(a.menuSelector)[n](),o=t;return t+r>i&&r<t&&(o-=r),o}return this.each(function(){e("a",e(a.menuSelector)).each(function(){e(this).data("ams-context-menu",!0)}),e(this).on("contextmenu",function(n){if(!n.ctrlKey)return e(a.menuSelector).data("invokedOn",e(n.target)).show().css({position:"fixed",left:t(n.clientX,"width")-10,top:t(n.clientY,"height")-10}).off("click").on("click",function(t){e(this).hide();var n=e(this).data("invokedOn"),i=e(t.target);a.menuSelected.call(this,n,i),s.event.stop(t)}),!1}),e(document).click(function(){e(a.menuSelector).hide()})})},myams_menu:function(a){var t=e.extend({},{accordion:!0,speed:200,closedSign:'<em class="fa fa-angle-down"></em>',openedSign:'<em class="fa fa-angle-up"></em>'},a),n=e(this);n.find("LI").each(function(){var a=e(this);if(a.find("UL").size()>0){a.find("A:first").append("<b class='collapse-sign'>"+t.closedSign+"</b>");var n=a.find("A:first");"#"===n.attr("href")&&n.click(function(){return!1})}}),n.find("LI.active").each(function(){var a=e(this).parents("UL"),n=a.parent("LI");a.slideDown(t.speed),n.find("b:first").html(t.openedSign),n.addClass("open")}),n.find("LI A").on("click",function(){var a=e(this);if(!a.hasClass("active")){var s=a.attr("href").replace(/^#/,""),i=a.parent().find("UL");if(t.accordion){var r=a.parent().parents("UL"),o=n.find("UL:visible");o.each(function(a){var n=!0;if(r.each(function(e){if(r[e]===o[a])return n=!1,!1}),n&&i!==o[a]){var l=e(o[a]);!s&&l.hasClass("active")||l.slideUp(t.speed,function(){e(this).parent("LI").removeClass("open").find("B:first").delay(t.speed).html(t.closedSign)})}})}var l=a.parent().find("UL:first");s||!l.is(":visible")||l.hasClass("active")?l.slideDown(t.speed,function(){a.parent("LI").addClass("open").find("B:first").delay(t.speed).html(t.openedSign)}):l.slideUp(t.speed,function(){a.parent("LI").removeClass("open").find("B:first").delay(t.speed).html(t.closedSign)})}})}}),e.UTF8={encode:function(e){e=e.replace(/\r\n/g,"\n");for(var a="",t=0;t<e.length;t++){var n=e.charCodeAt(t);n<128?a+=String.fromCharCode(n):n>127&&n<2048?(a+=String.fromCharCode(n>>6|192),a+=String.fromCharCode(63&n|128)):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128),a+=String.fromCharCode(63&n|128))}return a},decode:function(e){for(var a="",t=0,n=0,s=0,i=0;t<e.length;)(n=e.charCodeAt(t))<128?(a+=String.fromCharCode(n),t++):n>191&&n<224?(s=e.charCodeAt(t+1),a+=String.fromCharCode((31&n)<<6|63&s),t+=2):(s=e.charCodeAt(t+1),i=e.charCodeAt(t+2),a+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&i),t+=3);return a}},void 0===a.MyAMS&&(a.MyAMS={devmode:!0,devext:"",lang:"en",throttleDelay:350,menuSpeed:235,navbarHeight:49,ajaxNav:!0,enableWidgets:!0,enableMobile:!1,enableFastclick:!1,warnOnFormChange:!1,ismobile:/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())});var n=a.MyAMS,s=n;n.baseURL=function(){var a=e('script[src*="/myams.js"], script[src*="/myams.min.js"]').attr("src");return s.devmode=a.indexOf(".min.js")<0,s.devext=s.devmode?"":".min",a.substring(0,a.lastIndexOf("/")+1)}(),n.log=function(){t&&t.debug&&t.debug(this,arguments)},n.getQueryVar=function(e,a){if(e.indexOf("?")<0)return!1;e.endsWith("&")||(e+="&");var t=new RegExp(".*?[&\\?]"+a+"=(.*?)&.*"),n=e.replace(t,"$1");return n!==e&&n},n.rgb2hex=function(a){return"#"+e.map(a.match(/\b(\d+)\b/g),function(e){return("0"+parseInt(e).toString(16)).slice(-2)}).join("")},n.generateId=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+e()+e()},n.generateUUID=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var t=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===a?t:3&t|8).toString(16)})},n.getObject=function(e,a){if(e){if("string"!=typeof e)return e;var t=e.split(".");a=void 0===a||null===a?window:a;for(var n=0;n<t.length;n++)try{a=a[t[n]]}catch(e){return}return a}},n.getFunctionByName=function(e,a){if(void 0!==e){if("function"==typeof e)return e;var t=e.split("."),n=t.pop();a=void 0===a||null===a?window:a;for(var s=0;s<t.length;s++)try{a=a[t[s]]}catch(e){return}try{return a[n]}catch(e){return}}},n.executeFunctionByName=function(e,a){var t=s.getFunctionByName(e,window);if("function"==typeof t){var n=Array.prototype.slice.call(arguments,2);return t.apply(a,n)}},n.isInDOM=function(t){return!!(t=e(t)).exists()&&a.document.body.contains(t[0])},n.getSource=function(e){return e.replace(/{[^{}]*}/g,function(e){return s.getFunctionByName(e.substr(1,e.length-2))})},n.getScript=function(a,t,n){"object"==typeof t&&(n=t,t=null),void 0===n&&(n={});var i={dataType:"script",url:s.getSource(a),success:t,error:s.error.show,cache:!s.devmode,async:void 0===n.async?"function"==typeof t:n.async},r=e.extend({},i,n);return e.ajax(r)},n.getCSS=function(a,t,n,i){n&&(n=s.getFunctionByName(n));var r=e("HEAD"),o=e('style[data-ams-id="'+t+'"]',r);if(0===o.length){if(o=e("<style>").attr("data-ams-id",t).text('@import "'+s.getSource(a)+'";'),n)var l=setInterval(function(){try{o[0].sheet.cssRules;n.call(window,!0,i),clearInterval(l)}catch(e){}},10);o.appendTo(r)}else n&&n.call(window,!1,i)},n.event={stop:function(e){e||(e=window.event),e&&"string"!=typeof e&&(e.stopPropagation?(e.stopPropagation(),e.preventDefault()):(e.cancelBubble=!0,e.returnValue=!1))}},n.browser={getInternetExplorerVersion:function(){var e=-1;if("Microsoft Internet Explorer"===navigator.appName){var a=navigator.userAgent;null!==new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(a)&&(e=parseFloat(RegExp.$1))}return e},checkVersion:function(){var e="You're not using Windows Internet Explorer.",t=this.getInternetExplorerVersion();t>-1&&(e=t>=8?"You're using a recent copy of Windows Internet Explorer.":"You should upgrade your copy of Windows Internet Explorer."),a.alert&&a.alert(e)},isIE8orlower:function(){var e="0",a=this.getInternetExplorerVersion();return a>-1&&(e=a>=9?0:1),e},copyToClipboard:function(i){function r(i){var r=!1;if(window.clipboardData&&window.clipboardData.setData)r=clipboardData.setData("Text",i);else if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var o=e("<textarea>");o.val(i),o.css("position","fixed"),o.appendTo(e("body")),o.get(0).select();try{document.execCommand("copy"),r=!0}catch(e){t&&t.warn&&t.warn("Copy to clipboard failed.",e)}finally{o.remove()}}r?s.skin.smallBox("success",{title:i.length>1?s.i18n.CLIPBOARD_TEXT_COPY_OK:s.i18n.CLIPBOARD_CHARACTER_COPY_OK,icon:"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:3e3}):a.prompt&&a.prompt(n.i18n.CLIPBOARD_COPY,i)}if(void 0===i)return function(){var a=e(this),t=a.text();a.parents(".btn-group").removeClass("open"),r(t)};r(i)}},n.error={ajax:function(e,a,n,i){if(!("abort"===i||a&&a.statusText&&"OK"===a.statusText.toUpperCase())){if("json"===(a=s.ajax.getResponse(a)).contentType)s.ajax.handleJSON(a.data);else{var r=e.statusText||e.type,o=a.responseText;s.skin.messageBox("error",{title:s.i18n.ERROR_OCCURED,content:"<h4>"+r+"</h4><p>"+(o||"")+"</p>",icon:"fa fa-warning animated shake",timeout:1e4})}t&&(t.error&&t.error(e),t.debug&&t.debug(a))}},show:function(e,a,n){if(n){var i=s.ajax.getResponse(e);"json"===i.contentType?s.ajax.handleJSON(i.data):s.skin.messageBox("error",{title:s.i18n.ERRORS_OCCURED,content:"<h4>"+a+"</h4><p>"+n+"</p>",icon:"fa fa-warning animated shake",timeout:1e4}),t&&(t.error&&t.error(n),t.debug&&t.debug(e))}}},n.ajax={check:function(a,t,n,i){function r(e,a){if(void 0!==n){n instanceof Array||(n=[n]);for(var t=0;t<n.length;t++){var i=s.getFunctionByName(n[t]);"function"==typeof i&&i(e,a)}}}n instanceof Array||"object"==typeof n&&(i=n,n=void 0);var o={async:"function"==typeof n},l=e.extend({},o,i);if(a instanceof Array){for(var c=[],d=0;d<a.length;d++)void 0===a[d]&&c.push(s.getScript(t[d],{async:!0}));c.length>0?e.when.apply(e,c).then(function(){r(!0,i)}):r(!1,i)}else void 0===a?"string"==typeof t&&s.getScript(t,function(){r(!0,i)},l):r(!1,i)},getAddr:function(a){var t=a||e("HTML HEAD BASE").attr("href")||window.location.href;return t.substr(0,t.lastIndexOf("/")+1)},start:function(){e("#ajax-gear").show()},stop:function(){e("#ajax-gear").hide()},progress:function(e){e.lengthComputable&&(e.loaded>=e.total||t&&t.log&&t.log(parseInt(e.loaded/e.total*100,10)+"%"))},post:function(a,t,n,i){var r;r=a.startsWith(window.location.protocol)?a:this.getAddr()+a,"function"==typeof n?(i=n,n={}):n||(n={}),void 0===i&&(i=n.callback),"string"==typeof i&&(i=s.getFunctionByName(i)),delete n.callback;var o,l={url:r,type:"post",cache:!1,async:"function"==typeof i,data:e.param(t),dataType:"json",success:i||function(e){o=e.result}},c=e.extend({},l,n);return e.ajax(c),o},getResponse:function(e){var a,t,n=e.getResponseHeader("content-type");if(n)if(n.startsWith("application/javascript"))a="script",t=e.responseText;else if(n.startsWith("text/html"))a="html",t=e.responseText;else if(n.startsWith("text/xml"))a="xml",t=e.responseText;else if(t=e.responseJSON)a="json";else try{t=JSON.parse(e.responseText),a="json"}catch(n){t=e.responseText,a="text"}else a="json",t={status:"alert",alert:{title:s.i18n.ERROR_OCCURED,content:s.i18n.NO_SERVER_RESPONSE}};return{contentType:a,data:t}},handleJSON:function(n,i,r){var o,l=n.status;switch(l){case"alert":a.alert&&a.alert(n.alert.title+"\n\n"+n.alert.content);break;case"error":s.form.showErrors(i,n);break;case"info":case"success":void 0!==i&&(s.form.resetChanged(i),!1!==n.close_form&&s.dialog.close(i));break;case"message":case"messagebox":break;case"notify":case"callback":case"callbacks":void 0!==i&&(s.form.resetChanged(i),!1!==n.close_form&&s.dialog.close(i));break;case"modal":s.dialog.open(n.location);break;case"reload":void 0!==i&&(s.form.resetChanged(i),!1!==n.close_form&&s.dialog.close(i)),(o=n.location||window.location.hash).startsWith("#")&&(o=o.substr(1));var c=e(n.target||r||"#content");s.skin.loadURL(o,c,{preLoadCallback:s.getFunctionByName(n.pre_reload)||function(){e("[data-ams-pre-reload]",c).each(function(){s.executeFunctionByName(e(this).data("ams-pre-reload"))})},afterLoadCallback:s.getFunctionByName(n.post_reload)||function(){e("[data-ams-post-reload]",c).each(function(){s.executeFunctionByName(e(this).data("ams-post-reload"))})}});break;case"redirect":void 0!==i&&(s.form.resetChanged(i),!0===n.close_form&&s.dialog.close(i)),o=n.location||window.location.href,n.window?window.open(o,n.window,n.options):window.location.href===o?window.location.reload(!0):window.location.href=o;break;default:t&&t.log&&t.log("Unhandled status: "+l)}var d,m,u;if(n.content&&(m=n.content,u=e(m.target||r||i||"#content"),!0===m.raw?u.text(m.text):(u.html(m.html),s.initContent(u)),m.keep_hidden||u.removeClass("hidden")),n.contents){var f=n.contents;for(d=0;d<f.length;d++)m=f[d],u=e(m.target),!0===m.raw?u.text(m.text):(u.html(m.html),s.initContent(u)),m.keep_hidden||u.removeClass("hidden")}var h;if(n.message&&("string"==typeof(h=n.message)?"info"===l||"success"===l?s.skin.smallBox(l,{title:h,icon:"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:3e3}):s.skin.alert(e(i||"#content"),l,h):s.skin.alert(e(h.target||r||i||"#content"),h.status||"success",h.header,h.body,h.subtitle)),n.smallbox&&("string"==typeof(h=n.smallbox)?s.skin.smallBox(n.smallbox_status||l,{title:n.smallbox,icon:n.smallbox_icon||"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:n.smallbox_timeout||3e3}):s.skin.smallBox(h.status||l,{title:h.message,icon:h.icon||"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:h.timeout||3e3})),n.messagebox)if("string"==typeof(h=n.messagebox))s.skin.messageBox("info",{title:s.i18n.ERROR_OCCURED,content:h,timeout:1e4});else{var p=h.status||"info";"error"===p&&i&&r&&s.executeFunctionByName(i.data("ams-form-submit-error")||"MyAMS.form.finalizeSubmitOnError",i,r),s.skin.messageBox(p,{title:h.title||s.i18n.ERROR_OCCURED,content:h.content,icon:h.icon,number:h.number,timeout:null===h.timeout?void 0:h.timeout||1e4})}if(n.event&&i.trigger(n.event,n.event_options),n.events){var g;for(void 0===i&&(i=e(document)),d=0;d<n.events.length;d++)null!==(g=n.events[d])&&("string"==typeof g?i.trigger(g,n.events_options):i.trigger(g.event,g.options))}if(n.callback&&s.executeFunctionByName(n.callback,i,n.options),n.callbacks){var b;for(d=0;d<n.callbacks.length;d++)"function"==typeof(b=n.callbacks[d])?s.executeFunctionByName(b,i,b.options):s.executeFunctionByName(b.callback,i,b.options)}}},n.jsonrpc={getAddr:function(a){var t=(a||e("HTML HEAD BASE").attr("href")||window.location.href).replace(/\+\+skin\+\+\w+\//,"");return t.substr(0,t.lastIndexOf("/")+1)},query:function(a,t,n,i){s.ajax.check(e.jsonRpc,s.baseURL+"ext/jquery-jsonrpc"+s.devext+".js",function(){"function"==typeof n?(i=n,n={}):n||(n={}),"undefined"===i&&(i=n.callback),"string"==typeof i&&(i=s.getFunctionByName(i)),delete n.callback;var r={};"string"==typeof a?r.query=a:"object"==typeof a&&e.extend(r,a),e.extend(r,n);var o,l={url:s.jsonrpc.getAddr(n.url),type:"post",cache:!1,method:t,params:r,async:"function"==typeof i,success:i||function(e){o=e.result},error:s.error.show};return e.jsonRpc(l),o})},post:function(a,t,n,i){s.ajax.check(e.jsonRpc,s.baseURL+"ext/jquery-jsonrpc"+s.devext+".js",function(){"function"==typeof n?(i=n,n={}):n||(n={}),void 0===i&&(i=n.callback),"string"==typeof i&&(i=s.getFunctionByName(i)),delete n.callback;var r,o={url:s.jsonrpc.getAddr(n.url),type:"post",cache:!1,method:a,params:t,async:"function"==typeof i,success:i||function(e){r=e.result},error:s.error.show},l=e.extend({},o,n);return e.jsonRpc(l),r})}},n.xmlrpc={getAddr:function(a){var t=(a||e("HTML HEAD BASE").attr("href")||window.location.href).replace(/\+\+skin\+\+\w+\//,"");return t.substr(0,t.lastIndexOf("/")+1)},post:function(a,t,n,i,r){s.ajax.check(e.xmlrpc,s.baseURL+"ext/jquery-xmlrpc"+s.devext+".js",function(){"function"==typeof i?(r=i,i={}):i||(i={}),void 0===r&&(r=i.callback),"string"==typeof r&&(r=s.getFunctionByName(r)),delete i.callback;var o,l={url:s.xmlrpc.getAddr(a),methodName:t,params:n,success:r||function(e){o=e},error:s.error.show},c=e.extend({},l,i);return e.xmlrpc(c),o})}},n.form={init:function(a){e("FORM",a).each(function(){var a=e(this);e('INPUT.select2[type="hidden"]',a).each(function(){var a=e(this);a.data("ams-select2-input-value",a.val())})});(s.warnOnFormChange?e('FORM[data-ams-warn-on-change!="false"]',a):e('FORM[data-ams-warn-on-change="true"]',a)).each(function(){var a=e(this);e('INPUT[type="text"], INPUT[type="checkbox"], INPUT[type="radio"], SELECT, TEXTAREA, [data-ams-changed-event]',a).each(function(){var a=e(this);if(!0!==a.data("ams-ignore-change")){var t=a.data("ams-changed-event")||"change";a.on(t,function(){s.form.setChanged(e(this).parents("FORM"))})}}),a.on("reset",function(){s.form.resetChanged(e(this))})})},setFocus:function(a){var t=e("[data-ams-focus-target]",a).first();t.exists()||(t=e("input, select",a).first()),t.exists()&&(t.hasClass("select2-input")&&(t=t.parents(".select2")),t.hasClass("select2")?setTimeout(function(){t.select2("focus"),!0===t.data("ams-focus-open")&&t.select2("open")},100):t.focus())},checkBeforeUnload:function(){if(e('FORM[data-ams-form-changed="true"]').exists())return s.i18n.FORM_CHANGED_WARNING},confirmChangedForm:function(t,n,i){"function"==typeof t&&(n=t,t=void 0),e('FORM[data-ams-form-changed="true"]',t).exists()?i?a.confirm(s.i18n.FORM_CHANGED_WARNING,s.i18n.WARNING)?n.call(t):i.call(t):s.skin.bigBox({title:s.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+s.i18n.FORM_CHANGED_WARNING,buttons:s.i18n.BTN_OK_CANCEL},function(e){e===s.i18n.BTN_OK&&n.call(t)}):n.call(t)},setChanged:function(e){e.attr("data-ams-form-changed",!0)},resetChanged:function(a){void 0!==a&&e(a).removeAttr("data-ams-form-changed")},submit:function(t,n,i){if(!(t=e(t)).exists())return!1;if("object"==typeof n&&(i=n,n=void 0),t.data("submitted"))return t.data("ams-form-hide-submitted")||s.skin.messageBox("warning",{title:s.i18n.WAIT,content:s.i18n.FORM_SUBMITTED,icon:"fa fa-save shake animated",timeout:t.data("ams-form-alert-timeout")||5e3}),!1;if(!s.form._checkSubmitValidators(t))return!1;e(".alert-danger, SPAN.state-error",t).not(".persistent").remove(),e(".state-error",t).removeClassPrefix("state-");var r=e(t.data("ams-submit-button"));return r&&!r.data("ams-form-hide-loading")&&(r.data("ams-progress-content",r.html()),r.button("loading")),s.ajax.check(e.fn.ajaxSubmit,s.baseURL+"ext/jquery-form-3.49"+s.devext+".js",function(){function r(t,r){var o,l,c,d,m,u,f,h,p,g=t.data(),b=g.amsFormOptions;if(i&&(m=i.formDataInitCallback),m?delete i.formDataInitCallback:m=g.amsFormDataInitCallback,m){var v={};if(d="function"==typeof m?m.call(t,v):s.executeFunctionByName(m,t,v),v.veto)return(o=t.data("ams-submit-button"))&&o.button("reset"),s.form.finalizeSubmitFooter.call(t),!1}else d=g.amsFormData||{};(o=e(t.data("ams-submit-button")))&&o.exists()?c=(l=o.data()).amsFormSubmitTarget:l={};var x,y=n||l.amsFormHandler||g.amsFormHandler||"";if(y.startsWith(window.location.protocol))x=y;else{var k=l.amsFormAction||t.attr("action").replace(/#/,"");x=k.startsWith(window.location.protocol)?k:s.ajax.getAddr()+k,x+=y}u=l.amsProgressHandler||g.amsProgressHandler||"",f=l.amsProgressInterval||g.amsProgressInterval||1e3,h=l.amsProgressCallback||g.amsProgressCallback,p=l.amsProgressEndCallback||g.amsProgressEndCallback;var C=null;i&&i.initSubmitTarget?s.executeFunctionByName(i.initSubmitTarget,t):g.amsFormInitSubmitTarget?(C=e(c||g.amsFormSubmitTarget||"#content"),s.executeFunctionByName(g.amsFormInitSubmit||"MyAMS.form.initSubmit",t,C)):g.amsFormHideSubmitFooter||s.executeFunctionByName(g.amsFormInitSubmit||"MyAMS.form.initSubmitFooter",t),i&&(d=e.extend({},d,i.form_data));var S;u?d.progress_id=s.generateUUID():(S=void 0!==r.uuid)&&(x.indexOf("X-Progress-ID")<0&&(x+="?X-Progress-ID="+r.uuid),delete r.uuid);var w={url:x,type:"post",cache:!1,data:d,dataType:g.amsFormDatatype,beforeSerialize:function(){void 0!==a.tinyMCE&&a.tinyMCE.triggerSave()},beforeSubmit:function(e,a){a.data("submitted",!0)},error:function(e,a,t,n){C&&s.executeFunctionByName(g.amsFormSubmitError||"MyAMS.form.finalizeSubmitOnError",n,C),s.form.resetAfterSubmit(n)},iframe:S},T=i&&i.downloadTarget||g.amsFormDownloadTarget;if(T){var N=e('iframe[name="'+T+'"]');N.exists()||(N=e("<iframe></iframe>").hide().attr("name",T).appendTo(e("body"))),w=e.extend({},w,{iframe:!0,iframeTarget:N,success:function(a,t,n,i){if(e(i).parents(".modal-dialog").exists())s.dialog.close(i);else{var r,o=i.data("ams-submit-button");o&&(r=o.data("ams-form-submit-callback")),r||(r=s.getFunctionByName(g.amsFormSubmitCallback)||s.form._submitCallback);try{r.call(i,a,t,n,i)}finally{s.form.resetAfterSubmit(i),s.form.resetChanged(i)}}}})}else w=e.extend({},w,{error:function(e,a,t,n){C&&s.executeFunctionByName(g.amsFormSubmitError||"MyAMS.form.finalizeSubmitOnError",n,C),s.form.resetAfterSubmit(n)},success:function(e,a,t,n){var i,r=n.data("ams-submit-button");r&&(i=r.data("ams-form-submit-callback")),i||(i=s.getFunctionByName(g.amsFormSubmitCallback)||s.form._submitCallback);try{i.call(n,e,a,t,n)}finally{s.form.resetAfterSubmit(n),s.form.resetChanged(n)}},iframe:S});var F=e.extend({},w,r,b,i);if(u&&function(e,a){function n(){clearInterval(i),s.form.resetAfterSubmit(t,o),o.html(o.data("ams-progress-content")),s.executeFunctionByName(p,t,o),s.form.resetChanged(t)}var i;o.button("loading"),i=setInterval(function(){s.ajax.post(e,{progress_id:a},{error:n},s.getFunctionByName(h)||function(e,a){if("success"===a)if("running"===e.status)if(e.message)o.text(e.message);else{var t=o.data("ams-progress-text")||s.i18n.PROGRESS;e.current?t+=": "+e.current+"/ "+(e.length||100):t+="...",o.text(t)}else"finished"===e.status&&n();else n()})},f)}(u,d.progress_id),e(t).ajaxSubmit(F),T){var R=e(t).parents(".modal-dialog"),O=R.exists()&&o.exists()&&o.data("ams-keep-modal");R.exists()&&!0!==O?s.dialog.close(t):u||setTimeout(function(){s.form.resetAfterSubmit(t,o),s.form.resetChanged(t)},o.data("ams-form-reset-timeout")||2e3)}}if(!0!==t.data("ams-form-ignore-uploads")&&e('INPUT[type="file"]',t).length>0){s.ajax.check(e.progressBar,s.baseURL+"ext/jquery-progressbar"+s.devext+".js");var o=e.extend({},{uuid:e.progressBar.submit(t)});r(t,o)}else r(t,{})}),!1},initSubmit:function(a,t){var n=e(this),s='<i class="fa fa-3x fa-gear fa-spin"></i>';t||(t=n.data("ams-form-submit-message")),t&&(s+="<strong>"+t+"</strong>"),e(a).html('<div class="row margin-20"><div class="text-center">'+s+"</div></div>"),e(a).parents(".hidden").removeClass("hidden")},resetAfterSubmit:function(e){if(e.is(":visible")){var a=e.data("ams-submit-button");a&&a.button("reset"),s.form.finalizeSubmitFooter.call(e)}e.data("submitted",!1),e.removeData("ams-submit-button")},finalizeSubmitOnError:function(a){e("i",a).removeClass("fa-spin").removeClass("fa-gear").addClass("fa-ambulance")},initSubmitFooter:function(a){var t=e(this),n='<i class="fa fa-3x fa-gear fa-spin"></i>';a||(a=e(this).data("ams-form-submit-message")),a&&(n+='<strong class="submit-message align-top padding-left-10 margin-top-10">'+a+"</strong>");var s=e("footer",t);e("button",s).hide(),s.append('<div class="row"><div class="text-center">'+n+"</div></div>")},finalizeSubmitFooter:function(){var a=e(this),t=e("footer",a);t&&(e(".row",t).remove(),e("button",t).show())},_submitCallback:function(a,t,n,i){var r;i.is(":visible")&&(s.form.finalizeSubmitFooter.call(i),(r=i.data("ams-submit-button"))&&r.button("reset"));var o,l=i.data();if(l.amsFormDatatype)o=l.amsFormDatatype;else{var c=s.ajax.getResponse(n);o=c.contentType,a=c.data}var d;switch(d=e(r?r.data("ams-form-submit-target")||l.amsFormSubmitTarget||"#content":l.amsFormSubmitTarget||"#content"),o){case"json":s.ajax.handleJSON(a,i,d);break;case"script":case"xml":break;case"html":case"text":default:s.form.resetChanged(i),r&&!0!==r.data("ams-keep-modal")&&s.dialog.close(i),d.exists()||(d=e("body")),d.parents(".hidden").removeClass("hidden"),e(".alert",d.parents(".alerts-container")).remove(),d.css({opacity:"0.0"}).html(a).delay(50).animate({opacity:"1.0"},300),s.initContent(d),s.form.setFocus(d)}var m=n.getResponseHeader("X-AMS-Callback");if(m){var u=n.getResponseHeader("X-AMS-Callback-Options");s.executeFunctionByName(m,i,void 0===u?{}:JSON.parse(u),n)}},_getSubmitValidators:function(a){var t=[],n=a.data("ams-form-validator");return n&&t.push([a,n]),e("[data-ams-form-validator]",a).each(function(){var a=e(this);t.push([a,a.data("ams-form-validator")])}),t},_checkSubmitValidators:function(e){var a=s.form._getSubmitValidators(e);if(!a.length)return!0;for(var t=[],n=!0,i=0;i<a.length;i++){var r=a[i],o=r[0],l=r[1],c=s.executeFunctionByName(l,e,o);!1===c?n=!1:"string"==typeof c?t.push(c):n.length&&n.length>0&&(t=t.concat(n))}if(t.length>0){var d=1===t.length?s.i18n.ERROR_OCCURED:s.i18n.ERRORS_OCCURED;return s.skin.alert(e,"danger",d,t),!1}return n},showErrors:function(a,t){var n;if("string"==typeof t)s.skin.alert(a,"error",s.i18n.ERROR_OCCURED,t);else if(t instanceof Array)n=1===t.length?s.i18n.ERROR_OCCURED:s.i18n.ERRORS_OCCURED,s.skin.alert(a,"error",n,t);else{e(".state-error",a).removeClass("state-error"),n=t.error_header||(t.widgets&&t.widgets.length>1?s.i18n.ERRORS_OCCURED:s.i18n.ERROR_OCCURED);var i,r=[];if(t.messages)for(i=0;i<t.messages.length;i++){var o=t.messages[i];o.header?r.push("<strong>"+o.header+"</strong><br />"+o.message):r.push(o.message||o)}if(t.widgets)for(i=0;i<t.widgets.length;i++){var l=t.widgets[i],c=e('[name="'+l.name+'"]',a);c.exists()||(c=e('[name="'+l.name+':list"]',a)),c.exists()?c.parents("label:first").removeClassPrefix("state-").addClass("state-error").after('<span for="name" class="state-error">'+l.message+"</span>"):l.label&&r.push(l.label+" : "+l.message);var d=c.parents(".tab-pane").index()+1;if(d>0){var m=e(".nav-tabs",e(c).parents(".tabforms"));e("li:nth-child("+d+")",m).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",a).click()}}s.skin.alert(e(".form-group:first",a),t.error_level||"error",n,r,t.error_message)}}},n.dialog={_shown_callbacks:[],registerShownCallback:function(e,a){var t;a&&(t=a.objectOrParentWithClass("modal-dialog"));var n;t&&t.exists()?void 0===(n=t.data("shown-callbacks"))&&(n=[],t.data("shown-callbacks",n)):n=s.dialog._shown_callbacks,n.indexOf(e)<0&&n.push(e)},_hide_callbacks:[],registerHideCallback:function(e,a){var t;a&&(t=a.objectOrParentWithClass("modal-dialog"));var n;t&&t.exists()?void 0===(n=t.data("hide-callbacks"))&&(n=[],t.data("hide-callbacks",n)):n=s.dialog._hide_callbacks,n.indexOf(e)<0&&n.push(e)},open:function(a,t){s.ajax.check(e.fn.modalmanager,s.baseURL+"ext/bootstrap-modalmanager"+s.devext+".js",function(){s.ajax.check(e.fn.modal.defaults,s.baseURL+"ext/bootstrap-modal"+s.devext+".js",function(n){n&&(e(document).off("click.modal"),e.fn.modal.defaults.spinner=e.fn.modalmanager.defaults.spinner='<div class="loading-spinner" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="progress-bar" style="width: 100%;"></div></div></div>');var i,r;if("string"==typeof a)i={},r=a;else{i=a.data(),r=a.attr("href")||i.amsUrl;var o=s.getFunctionByName(r);"function"==typeof o&&(r=o.call(a))}r&&(e("body").modalmanager("loading"),0===r.indexOf("#")?e(r).modal("show"):e.ajax({url:r,type:"get",cache:void 0!==i.amsAllowCache&&i.amsAllowCache,data:t,success:function(t,n,o){e("body").modalmanager("removeLoading");var l=s.ajax.getResponse(o),c=l.contentType,d=l.data;switch(c){case"json":s.ajax.handleJSON(d,e(e(a).data("ams-json-target")||"#content"));break;case"script":case"xml":break;case"html":case"text":default:var m=e(d),u=e(".modal-dialog",m.wrap("<div></div>").parent()),f=u.data(),h={backdrop:"static",overflow:f.amsModalOverflow||".modal-viewport",maxHeight:void 0===f.amsModalMaxHeight?function(){return e(window).height()-e(".modal-header",m).outerHeight(!0)-e("footer",m).outerHeight(!0)-85}:s.getFunctionByName(f.amsModalMaxHeight)},p=e.extend({},h,f.amsModalOptions);p=s.executeFunctionByName(f.amsModalInitCallback,u,p)||p,e("<div>").addClass("modal fade").append(m).modal(p).on("shown",s.dialog.shown).on("hidden",s.dialog.hidden),s.initContent(m),!1!==i.amsLogEvent&&s.stats.logPageview(r)}}}))})})},shown:function(a){function t(a){var t=e(".scrollmarker.top",i),n=i.scrollTop();n>0?t.show():t.hide();var s=e(".scrollmarker.bottom",i);r+n>=i.get(0).scrollHeight?s.hide():s.show()}var n=a.target,i=e(".modal-viewport",n);if(i.exists()){var r=parseInt(i.css("max-height")),o=e.scrollbarWidth();"hidden"!==i.css("overflow")&&i.height()===r?(e("<div></div>").addClass("scrollmarker").addClass("top").css("top",0).css("width",i.width()-o).hide().appendTo(i),e("<div></div>").addClass("scrollmarker").addClass("bottom").css("top",r-20).css("width",i.width()-o).appendTo(i),i.scroll(t),i.off("resize").on("resize",t)):e(".scrollmarker",i).remove()}e("[data-ams-shown-callback]",n).each(function(){var a=s.getFunctionByName(e(this).data("ams-shown-callback"));a&&a.call(n,this)});var l,c=e(".modal-dialog",n).data("shown-callbacks");if(c)for(l=0;l<c.length;l++)c[l].call(n);if(c=s.dialog._shown_callbacks)for(l=0;l<c.length;l++)c[l].call(n);s.form.setFocus(n)},close:function(a){"string"==typeof a&&(a=e(a));var t=a.parents(".modal").data("modal");if(t){var n=e("body").data("modalmanager");n&&n.getOpenModals().indexOf(t)>=0&&t.hide()}},hidden:function(a){var t=a.target;s.skin.cleanContainer(t),e("[data-ams-hidden-callback]",t).each(function(){var a=s.getFunctionByName(e(this).data("ams-hidden-callback"));a&&a.call(t,this)});var n,i=e(".modal-dialog",t).data("hide-callbacks");if(i)for(n=0;n<i.length;n++)i[n].call(t);if(i=s.dialog._hide_callbacks)for(n=0;n<i.length;n++)i[n].call(t)}},n.helpers={sort:function(a,t){t||(t="weight"),a.children().sort(function(a,n){return+e(a).data(t)-+e(n).data(t)}).each(function(){a.append(this)})},select2ClearSelection:function(){var a=e(this),t=a.parents("label"),n=a.data("ams-select2-target");e('[name="'+n+'"]',t).data("select2").val("")},select2FormatSelection:function(a,t){a instanceof Array||(a=[a]),e(a).each(function(){"object"==typeof this?t.append(this.text):t.append(this)})},select2SelectAllHelper:function(){var a=e(this).parents("label:first"),t=e(".select2",a);t.select2("data",t.data("ams-select2-data"))},select2QueryUrlResultsCallback:function(a,t,n){switch(a.status){case"error":s.skin.messageBox("error",{title:s.i18n.ERROR_OCCURED,content:"<h4>"+a.error_message+"</h4>",icon:"fa fa-warning animated shake",timeout:1e4});break;case"modal":e(this).data("select2").dropdown.hide(),s.dialog.open(a.location);break;default:return{results:a.results||a,more:a.has_more||!1,context:a.context}}},select2QueryMethodSuccessCallback:function(a,t,n){var i=a.result;if("string"==typeof i)try{i=JSON.parse(i)}catch(e){}switch(i.status){case"error":s.skin.messageBox("error",{title:s.i18n.ERROR_OCCURED,content:"<h4>"+i.error_message+"</h4>",icon:"fa fa-warning animated shake",timeout:1e4});break;case"modal":e(this).data("select2").dropdown.hide(),s.dialog.open(i.location);break;default:n.callback({results:i.results||i,more:i.has_more||!1,context:i.context})}},select2ChangeHelper:function(){var a=e(this),t=a.data(),n=e(t.amsSelect2HelperTarget);switch(t.amsSelect2HelperType){case"html":n.html('<div class="text-center"><i class="fa fa-2x fa-gear fa-spin"></i></div>');var i={};i[t.amsSelect2HelperArgument||"value"]=a.val(),e.get(t.amsSelect2HelperUrl,i,s.getFunctionByName(t.amsSelect2HelperCallback)||function(e){e?(n.html(e),s.initContent(n)):n.empty()});break;case"json-rpc":n.html('<div class="text-center"><i class="fa fa-2x fa-gear fa-spin"></i></div>'),s.jsonrpc.post(t.amsSelect2HelperMethod,{value:a.val()},{url:t.amsSelect2HelperUrl},s.getFunctionByName(t.amsSelect2HelperCallback)||function(e){e.result?(n.html(e.result),s.initContent(n)):n.empty()});break;default:var r=t.amsSelect2HelperCallback;r&&s.executeFunctionByName(r,a,t)}},contextMenuHandler:function(e,a){var t=a.data();if("modal"===t.toggle)s.dialog.open(a);else{var n=a.attr("href")||t.amsUrl;if(!n||n.startsWith("javascript")||a.attr("target"))return;s.event.stop();var i=s.getFunctionByName(n);"function"==typeof i&&(n=i.call(a,e)),"function"==typeof n?n.call(a,e):(n=n.replace(/\%23/,"#"),(e=a.data("ams-target"))?s.form.confirmChangedForm(e,function(){s.skin.loadURL(n,e,a.data("ams-link-options"),a.data("ams-link-callback"))}):s.form.confirmChangedForm(function(){n.startsWith("#")?n!==location.hash&&(s.root.hasClass("mobile-view-activated")?(s.root.removeClass("hidden-menu"),window.setTimeout(function(){window.location.hash=n},150)):window.location.hash=n):window.location=n}))}},datetimepickerDialogHiddenCallback:function(){e(".datepicker, .timepicker, .datetimepicker",this).datetimepicker("destroy")},setSEOStatus:function(){var a=e(this),t=a.siblings(".progress").children(".progress-bar"),n=Math.min(a.val().length,100),s="success";n<20||n>80?s="danger":(n<40||n>66)&&(s="warning"),t.removeClassPrefix("progress-bar").addClass("progress-bar").addClass("progress-bar-"+s).css("width",n+"%")}},n.plugins={init:function(a){function t(e,a){if(o.hasOwnProperty(e)){var t=o[e];t.css=t.css||a.css,t.callbacks.push({callback:a.callback,context:a.context}),a.register&&(t.register=!0),!1===a.async&&(t.async=!1)}else o[e]={src:a.src,css:a.css,callbacks:[{callback:a.callback,context:a.context}],register:a.register,async:a.async};a.css&&s.getCSS(a.css,e+"_css")}function n(e){var t,n,i=l.callbacks;if(i&&i.length){for(t=0;t<i.length;t++)if(n=i[t],n.callback=s.getFunctionByName(n.callback),!1!==l.register){var o=s.plugins.enabled;o.hasOwnProperty(r)?o[r].push(n):o[r]=[n]}}else!1!==l.register&&(s.plugins.enabled[r]=null);if(!0!==e&&i&&i.length&&!1!==l.async)for(t=0;t<i.length;t++)n=i[t],s.executeFunctionByName(n.callback,a,n.context)}s.plugins.initData(a);var i=[];e("[data-ams-plugins-disabled]",a).each(function(){for(var a=e(this).data("ams-plugins-disabled").split(/\s+/),t=0;t<a.length;t++)i.push(a[t])});var r,o={};e("[data-ams-plugins]",a).each(function(){var a=e(this),n=a.data("ams-plugins");if("string"==typeof n)for(var s=a.data("ams-plugins").split(/\s+/),i=0;i<s.length;i++){r=s[i];var o={src:a.data("ams-plugin-"+r+"-src"),css:a.data("ams-plugin-"+r+"-css"),callback:a.data("ams-plugin-"+r+"-callback"),context:a,register:a.data("ams-plugin-"+r+"-register"),async:a.data("ams-plugin-"+r+"-async")};t(r,o)}else for(r in n)n.hasOwnProperty(r)&&t(r,n[r])});var l;for(r in o)o.hasOwnProperty(r)&&(l=o[r],void 0===s.plugins.enabled[r]?s.getScript(l.src,n,{async:void 0===l.async||l.async}):(!function(){var e=s.plugins.enabled[r];for(c=0;c<e.length;c++){var a=e[c];a&&a.context&&!s.isInDOM(a.context)&&(e[c]=null)}}(),n(!0)));for(var c in s.plugins.enabled)if(s.plugins.enabled.hasOwnProperty(c)&&!(i.indexOf(c)>=0)){var d=s.plugins.enabled[c];if(d)switch(typeof d){case"function":d(a);break;default:for(var m=0;m<d.length;m++){var u=d[m];switch(typeof u){case"function":u(a);break;default:u&&u.callback&&u.callback(u.context)}}}}},initData:function(a){e("[data-ams-data]",a).each(function(){var a=e(this),t=a.data("ams-data");if(t)for(var n in t)if(t.hasOwnProperty(n)){var s=t[n];"string"!=typeof s&&(s=JSON.stringify(s)),a.attr("data-"+n,s)}})},register:function(e,a,n){if("function"==typeof a&&(n=a,a=null),a=a||e.name,s.plugins.enabled.indexOf(a)>=0)t&&t.warn&&t.warn("Plugin "+a+" is already registered!");else if("object"==typeof e){var i=e.src;i?s.ajax.check(e.callback,i,function(t){t&&(s.plugins.enabled[a]=s.getFunctionByName(e.callback),e.css&&s.getCSS(e.css,a+"_css"),n&&s.executeFunctionByName(n))}):(s.plugins.enabled[a]=s.getFunctionByName(e.callback),e.css&&s.getCSS(e.css,a+"_css"),n&&s.executeFunctionByName(n))}else"function"==typeof e&&(s.plugins.enabled[a]=e,n&&s.executeFunctionByName(n))},enabled:{hint:function(a){var t=e(".hint:not(:parents(.nohints))",a);t.length>0&&s.ajax.check(e.fn.tipsy,s.baseURL+"ext/jquery-tipsy"+s.devext+".js",function(){s.getCSS(s.baseURL+"../css/ext/jquery-tipsy"+s.devext+".css","jquery-tipsy",function(){t.each(function(){var a=e(this),t=a.data(),n={html:void 0===t.amsHintHtml?(a.attr("title")||"").startsWith("<"):t.amsHintHtml,title:s.getFunctionByName(t.amsHintTitleGetter)||function(){var a=e(this),n=a.attr("original-title")||a.attr(t.amsHintTitleAttr||"title")||(t.amsHintHtml?a.html():a.text());return n=n.replace(/\?_="/,"?_="+(new Date).getTime()+'"')},opacity:t.amsHintOpacity||.95,gravity:t.amsHintGravity||"sw",offset:t.amsHintOffset||0},i=e.extend({},n,t.amsHintOptions);i=s.executeFunctionByName(t.amsHintInitCallback,a,i)||i;var r=a.tipsy(i);s.executeFunctionByName(t.amsHintAfterInitCallback,a,r,i)})})})},contextMenu:function(a){var t=e(".context-menu",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={menuSelector:t.amsContextmenuSelector,menuSelected:s.helpers.contextMenuHandler},i=e.extend({},n,t.amsContextmenuOptions);i=s.executeFunctionByName(t.amsContextmenuInitCallback,a,i)||i;var r=a.contextMenu(i);s.executeFunctionByName(t.amsContextmenuAfterInitCallback,a,r,i)})},switcher:function(a){e("LEGEND.switcher",a).each(function(){var a=e(this),t=a.parent("fieldset"),n=a.data();n.amsSwitcher||(e('<i class="fa fa-fw"></i>').prependTo(e(this)).addClass("open"===n.amsSwitcherState?n.amsSwitcherMinusClass||"fa-minus":n.amsSwitcherPlusClass||"fa-plus"),a.on("click",function(s){s.preventDefault();var i={};if(a.trigger("ams.switcher.before-switch",[a,i]),!i.veto)if(t.hasClass("switched")){t.removeClass("switched"),e(".fa",a).removeClass(n.amsSwitcherPlusClass||"fa-plus").addClass(n.amsSwitcherMinusClass||"fa-minus"),a.trigger("ams.switcher.opened",[a]);var r=a.attr("id");r&&e('legend.switcher[data-ams-switcher-sync="'+r+'"]',t).each(function(){var a=e(this);a.parents("fieldset").hasClass("switched")&&a.click()})}else t.addClass("switched"),e(".fa",a).removeClass(n.amsSwitcherMinusClass||"fa-minus").addClass(n.amsSwitcherPlusClass||"fa-plus"),a.trigger("ams.switcher.closed",[a])}),"open"!==n.amsSwitcherState&&t.addClass("switched"),a.data("ams-switcher","on"))})},checker:function(a){e("LEGEND.checker",a).each(function(){var a=e(this),t=a.parent("fieldset"),n=a.data();if(!n.amsChecker){var i=e('<label class="checkbox"></label>'),r=n.amsCheckerFieldname||"checker_"+s.generateId(),o=r.replace(/\./,"_"),l=n.amsCheckerHiddenPrefix,c=null,d=n.amsCheckerHiddenValueOn||"true",m=n.amsCheckerHiddenValueOff||"false",u=n.amsCheckerMarker||!1;l?c=e('<input type="hidden">').attr("name",l+r).val("on"===n.amsCheckerState?d:m).prependTo(a):u&&e('<input type="hidden">').attr("name",u).attr("value",1).prependTo(a);var f=e('<input type="checkbox">').attr("name",r).attr("id",o).data("ams-checker-hidden-input",c).data("ams-checker-init",!0).val(n.amsCheckerValue||!0).attr("checked","on"===n.amsCheckerState?"checked":null);n.amsCheckerReadonly?f.attr("disabled","disabled"):f.on("change",function(i){i.preventDefault();var r={},o=e(this).is(":checked");if(a.trigger("ams.checker.before-switch",[a,r]),r.veto)e(this).prop("checked",!o);else if(s.executeFunctionByName(n.amsCheckerChangeHandler,a,o),!n.amsCheckerCancelDefault){var l=f.data("ams-checker-hidden-input");o?("disable"===n.amsCheckerMode?(t.removeAttr("disabled"),e(".select2",t).removeAttr("disabled")):t.removeClass("switched"),l&&l.val(d),e("[data-required]",t).attr("required","required"),a.trigger("ams.checker.opened",[a])):("disable"===n.amsCheckerMode?(t.prop("disabled","disabled"),e(".select2",t).attr("disabled","disabled")):t.addClass("switched"),l&&l.val(m),e("[data-required]",t).removeAttr("required"),a.trigger("ams.checker.closed",[a]))}}),f.appendTo(i),e(">label",a).attr("for",f.attr("id")),i.append("<i></i>").prependTo(a);var h=e("[required]",t);h.attr("data-required",!0),"on"===n.amsCheckerState?f.attr("checked",!0):("disable"===n.amsCheckerMode?(t.attr("disabled","disabled"),e(".select2",t).attr("disabled","disabled")):t.addClass("switched"),h.removeAttr("required")),a.data("ams-checker","on")}})},slider:function(a){var t=e(".slider",a);t.length>0&&s.ajax.check(e.fn.slider,s.baseURL+"ext/bootstrap-slider-2.0.0"+s.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n=e.extend({},{},a.data.amsSliderOptions);n=s.executeFunctionByName(t.amsSliderInitCallback,a,n)||n;var i=a.slider(n);s.executeFunctionByName(t.amsSliderAfterInitCallback,a,i,n)})})},draggable:function(a){var t=e(".draggable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={cursor:t.amsDraggableCursor||"move",containment:t.amsDraggableContainment,connectToSortable:t.amsDraggableConnectSortable,helper:s.getFunctionByName(t.amsDraggableHelper)||t.amsDraggableHelper,start:s.getFunctionByName(t.amsDraggableStart),stop:s.getFunctionByName(t.amsDraggableStop)},i=e.extend({},n,t.amsDraggableOptions);i=s.executeFunctionByName(t.amsDraggableInitCallback,a,i)||i;var r=a.draggable(i);a.disableSelection(),s.executeFunctionByName(t.amsDraggableAfterInitCallback,a,r,i)})},droppable:function(a){var t=e(".droppable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={accept:t.amsdroppableAccept,drop:s.getFunctionByName(t.amsDroppableDrop)},i=e.extend({},n,t.amsDroppableOptions);i=s.executeFunctionByName(t.amsDroppableInitCallback,a,i)||i;var r=a.droppable(i);s.executeFunctionByName(t.amsDroppableAfterInitCallback,a,r,i)})},sortable:function(a){var t=e(".sortable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={items:t.amsSortableItems,handle:t.amsSortableHandle,helper:t.amsSortableHelper,connectWith:t.amsSortableConnectwith,start:s.getFunctionByName(t.amsSortableStart),over:s.getFunctionByName(t.amsSortableOver),containment:t.amsSortableContainment,placeholder:t.amsSortablePlaceholder,stop:s.getFunctionByName(t.amsSortableStop)},i=e.extend({},n,t.amsSortableOptions);i=s.executeFunctionByName(t.amsSortableInitCallback,a,i)||i;var r=a.sortable(i);a.disableSelection(),s.executeFunctionByName(t.amsSortableAfterInitCallback,a,r,i)})},resizable:function(a){var t=e(".resizable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={autoHide:!1===t.amsResizableAutohide||t.amsResizableAutohide,containment:t.amsResizableContainment,grid:t.amsResizableGrid,handles:t.amsResizableHandles,start:s.getFunctionByName(t.amsResizableStart),stop:s.getFunctionByName(t.amsResizableStop)},i=e.extend({},n,t.amsResizableOptions);i=s.executeFunctionByName(t.amsResizableInitCallback,a,i)||i;var r=a.resizable(i);a.disableSelection(),s.executeFunctionByName(t.amsResizableAfterInitCallback,a,r,i)})},typeahead:function(a){var t=e(".typeahead",a);t.length>0&&s.ajax.check(e.fn.typeahead,s.baseURL+"ext/jquery-typeahead"+s.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n=e.extend({},{},t.amsTypeaheadOptions);n=s.executeFunctionByName(t.amsTypeaheadInitCallback,a,n)||n;var i=a.typeahead(n);s.executeFunctionByName(t.amsTypeaheadAfterInitCallback,a,i,n)})})},treeview:function(a){var t=e(".treeview",a);t.length>0&&s.ajax.check(e.fn.treview,s.baseURL+"ext/bootstrap-treeview"+s.devext+".js",function(){s.getCSS(s.baseURL+"../css/ext/bootstrap-treeview"+s.devext+".css","bootstrap-treeview",function(){t.each(function(){var a=e(this),t=a.data(),n={data:t.amsTreeviewData,levels:t.amsTreeviewLevels,injectStyle:t.amsTreeviewInjectStyle,expandIcon:t.amsTreeviewExpandIcon||"fa fa-fw fa-plus-square-o",collapseIcon:t.amsTreeviewCollaspeIcon||"fa fa-fw fa-minus-square-o",emptyIcon:t.amsTreeviewEmptyIcon||"fa fa-fw",nodeIcon:t.amsTreeviewNodeIcon,selectedIcon:t.amsTreeviewSelectedIcon,checkedIcon:t.amsTreeviewCheckedIcon||"fa fa-fw fa-check-square-o",uncheckedIcon:t.amsTreeviewUncheckedIcon||"fa fa-fw fa-square-o",color:t.amsTreeviewColor,backColor:t.amsTreeviewBackColor,borderColor:t.amsTreeviewBorderColor,onHoverColor:t.amsTreeviewHoverColor,selectedColor:t.amsTreeviewSelectedColor,selectedBackColor:t.amsTreeviewSelectedBackColor,unselectableColor:t.amsTreeviewUnselectableColor||"rgba(1,1,1,0.25)",unselectableBackColor:t.amsTreeviewUnselectableBackColor||"rgba(1,1,1,0.25)",enableLinks:t.amsTreeviewEnableLinks,highlightSelected:t.amsTreeviewHighlightSelected,highlightSearchResults:t.amsTreeviewhighlightSearchResults,showBorder:t.amsTreeviewShowBorder,showIcon:t.amsTreeviewShowIcon,showCheckbox:t.amsTreeviewShowCheckbox,showTags:t.amsTreeviewShowTags,toggleUnselectable:t.amsTreeviewToggleUnselectable,multiSelect:t.amsTreeviewMultiSelect,onNodeChecked:s.getFunctionByName(t.amsTreeviewNodeChecked),onNodeCollapsed:s.getFunctionByName(t.amsTreeviewNodeCollapsed),onNodeDisabled:s.getFunctionByName(t.amsTreeviewNodeDisabled),onNodeEnabled:s.getFunctionByName(t.amsTreeviewNodeEnabled),onNodeExpanded:s.getFunctionByName(t.amsTreeviewNodeExpanded),onNodeSelected:s.getFunctionByName(t.amsTreeviewNodeSelected),onNodeUnchecked:s.getFunctionByName(t.amsTreeviewNodeUnchecked),onNodeUnselected:s.getFunctionByName(t.amsTreeviewNodeUnselected),onSearchComplete:s.getFunctionByName(t.amsTreeviewSearchComplete),onSearchCleared:s.getFunctionByName(t.amsTreeviewSearchCleared)},i=e.extend({},n,t.amsTreeviewOptions);i=s.executeFunctionByName(t.amsTreeviewInitcallback,a,i)||i;var r=a.treeview(i);s.executeFunctionByName(t.amsTreeviewAfterInitCallback,a,r,i)})})})},select2:function(a){var t=e(".select2",a);t.length>0&&s.ajax.check(e.fn.select2,s.baseURL+"ext/jquery-select2-3.5.4"+s.devext+".js",function(){t.each(function(){var a=e(this),t=a.data();if(!t.select2){var n={placeholder:t.amsSelect2Placeholder,multiple:t.amsSelect2Multiple,minimumInputLength:t.amsSelect2MinimumInputLength||0,maximumSelectionSize:t.amsSelect2MaximumSelectionSize,openOnEnter:void 0===t.amsSelect2EnterOpen||t.amsSelect2EnterOpen,allowClear:void 0===t.amsSelect2AllowClear||t.amsSelect2AllowClear,width:t.amsSelect2Width||"100%",initSelection:s.getFunctionByName(t.amsSelect2InitSelection),formatSelection:void 0===t.amsSelect2FormatSelection?s.helpers.select2FormatSelection:s.getFunctionByName(t.amsSelect2FormatSelection),formatResult:s.getFunctionByName(t.amsSelect2FormatResult),formatMatches:void 0===t.amsSelect2FormatMatches?function(e){return 1===e?s.i18n.SELECT2_MATCH:e+s.i18n.SELECT2_MATCHES}:s.getFunctionByName(t.amsSelect2FormatMatches),formatNoMatches:void 0===t.amsSelect2FormatResult?function(e){return s.i18n.SELECT2_NOMATCHES}:s.getFunctionByName(t.amsSelect2FormatResult),formatInputTooShort:void 0===t.amsSelect2FormatInputTooShort?function(e,a){var t=a-e.length;return s.i18n.SELECT2_INPUT_TOOSHORT.replace(/\{0\}/,t).replace(/\{1\}/,1===t?"":s.i18n.SELECT2_PLURAL)}:s.getFunctionByName(t.amsSelect2FormatInputTooShort),formatInputTooLong:void 0===t.amsSelect2FormatInputTooLong?function(e,a){var t=e.length-a;return s.i18n.SELECT2_INPUT_TOOLONG.replace(/\{0\}/,t).replace(/\{1\}/,1===t?"":s.i18n.SELECT2_PLURAL)}:s.getFunctionByName(t.amsSelect2FormatInputTooLong),formatSelectionTooBig:void 0===t.amsSelect2FormatSelectionTooBig?function(e){return s.i18n.SELECT2_SELECTION_TOOBIG.replace(/\{0\}/,e).replace(/\{1\}/,1===e?"":s.i18n.SELECT2_PLURAL)}:s.getFunctionByName(t.amsSelect2FormatSelectionTooBig),formatLoadMore:void 0===t.amsSelect2FormatLoadMore?function(e){return s.i18n.SELECT2_LOADMORE}:s.getFunctionByName(t.amsSelect2FormatLoadMore),formatSearching:void 0===t.amsSelect2FormatSearching?function(){return s.i18n.SELECT2_SEARCHING}:s.getFunctionByName(t.amsSelect2FormatSearching),separator:t.amsSelect2Separator||",",tokenSeparators:t.amsSelect2TokensSeparators||[","],tokenizer:s.getFunctionByName(t.amsSelect2Tokenizer)};switch(a.context.type){case"text":case"hidden":if(!n.initSelection){var i=a.data("ams-select2-values");i&&(n.initSelection=function(a,t){var s=[];e(a.val().split(n.separator)).each(function(){s.push({id:this,text:i[this]||this})}),t(s)})}}a.attr("readonly")?"hidden"===a.attr("type")&&(n.query=function(){return[]}):t.amsSelect2Query?(n.query=s.getFunctionByName(t.amsSelect2Query),n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2QueryUrl?(n.ajax={url:t.amsSelect2QueryUrl,quietMillis:t.amsSelect2QuietMillis||200,type:t.amsSelect2QueryType||"POST",dataType:t.amsSelect2QueryDatatype||"json",data:function(a,n,s){var i={};return i[t.amsSelect2QueryParamName||"query"]=a,i[t.amsSelect2PageParamName||"page"]=n,i[t.amsSelect2ContextParamName||"context"]=s,e.extend({},i,t.amsSelect2QueryOptions)},results:s.helpers.select2QueryUrlResultsCallback},n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2QueryMethod?(n.query=function(n){var i={url:t.amsSelect2MethodTarget||s.jsonrpc.getAddr(),type:t.amsSelect2MethodType||"POST",cache:!1,method:t.amsSelect2QueryMethod,params:t.amsSelect2QueryParams||{},success:function(e,t){return s.helpers.select2QueryMethodSuccessCallback.call(a,e,t,n)},error:s.error.show};i.params[t.amsSelect2QueryParamName||"query"]=n.term,i.params[t.amsSelect2PageParamName||"page"]=n.page,i.params[t.amsSelect2ContextParamName||"context"]=n.context,i=e.extend({},i,t.amsSelect2QueryOptions),i=s.executeFunctionByName(t.amsSelect2QueryInitCallback,a,i)||i,s.ajax.check(e.jsonRpc,s.baseURL+"ext/jquery-jsonrpc"+s.devext+".js",function(){e.jsonRpc(i)})},n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2Tags?n.tags=t.amsSelect2Tags:t.amsSelect2Data&&(n.data=t.amsSelect2Data),t.amsSelect2EnableFreeTags&&(n.createSearchChoice=function(e){return{id:e,text:(t.amsSelect2FreeTagsPrefix||s.i18n.SELECT2_FREETAG_PREFIX)+e}});var r=e.extend({},n,t.amsSelect2Options);r=s.executeFunctionByName(t.amsSelect2InitCallback,a,r)||r;var o=a.select2(r);s.executeFunctionByName(t.amsSelect2AfterInitCallback,a,o,r),a.hasClass("ordered")&&s.ajax.check(e.fn.select2Sortable,s.baseURL+"ext/jquery-select2-sortable"+s.devext+".js",function(){a.select2Sortable({bindOrder:"sortableStop"})}),a.on("change",function(){void 0!==e(a.get(0).form).data("validator")&&e(a).valid()})}})})},maskedit:function(a){var t=e("[data-mask]",a);t.length>0&&s.ajax.check(e.fn.mask,s.baseURL+"ext/jquery-maskedinput-1.4.1"+s.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n={placeholder:void 0===t.amsMaskeditPlaceholder?"X":t.amsMaskeditPlaceholder,complete:s.getFunctionByName(t.amsMaskeditComplete)},i=e.extend({},n,t.amsMaskeditOptions);i=s.executeFunctionByName(t.amsMaskeditInitCallback,a,i)||i;var r=a.mask(a.attr("data-mask"),i);s.executeFunctionByName(t.amsMaskeditAfterInitCallback,a,r,i)})})},inputmask:function(a){var t=e("[data-input-mask]",a);t.length>0&&s.ajax.check(e.fn.inputmask,s.baseURL+"ext/jquery-inputmask-bundle-3.2.8"+s.devext+".js",function(){t.each(function(){var a,t=e(this),n=t.data();a="object"==typeof n.inputMask?n.inputMask:{mask:n.inputMask.toString()};var i=e.extend({},a,n.amsInputmaskOptions);i=s.executeFunctionByName(n.amsInputmaskInitCallback,t,i)||i;var r=t.inputmask(i);s.executeFunctionByName(n.amsInputmaskAfterInitCallback,t,r,i)})})},datepicker:function(a){var t=e(".datepicker",a);t.length>0&&s.ajax.check(e.fn.datetimepicker,s.baseURL+"ext/jquery-datetimepicker"+s.devext+".js",function(a){a&&s.dialog.registerHideCallback(s.helpers.datetimepickerDialogHiddenCallback),s.getCSS(s.baseURL+"../css/ext/jquery-datetimepicker"+s.devext+".css","jquery-datetimepicker",function(){t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||s.lang,format:t.amsDatetimepickerFormat||"d/m/y",datepicker:!0,dayOfWeekStart:1,timepicker:!1,closeOnDateSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,weeks:t.amsDatetimepickerWeeks},i=e.extend({},n,t.amsDatetimepickerOptions);i=s.executeFunctionByName(t.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);s.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,i)})})})},datetimepicker:function(a){var t=e(".datetimepicker",a);t.length>0&&s.ajax.check(e.fn.datetimepicker,s.baseURL+"ext/jquery-datetimepicker"+s.devext+".js",function(a){a&&s.dialog.registerHideCallback(s.helpers.datetimepickerDialogHiddenCallback),s.getCSS(s.baseURL+"../css/ext/jquery-datetimepicker"+s.devext+".css","jquery-datetimepicker",function(){t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||s.lang,format:t.amsDatetimepickerFormat||"d/m/y H:i",datepicker:!0,dayOfWeekStart:1,timepicker:!0,closeOnDateSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,closeOnTimeSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,weeks:t.amsDatetimepickerWeeks},i=e.extend({},n,t.amsDatetimepickerOptions);i=s.executeFunctionByName(t.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);s.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,i)})})})},timepicker:function(a){var t=e(".timepicker",a);t.length>0&&s.ajax.check(e.fn.datetimepicker,s.baseURL+"ext/jquery-datetimepicker"+s.devext+".js",function(a){a&&s.dialog.registerHideCallback(s.helpers.datetimepickerDialogHiddenCallback),s.getCSS(s.baseURL+"../css/ext/jquery-datetimepicker"+s.devext+".css","jquery-datetimepicker",function(){t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||s.lang,format:t.amsDatetimepickerFormat||"H:i",datepicker:!1,timepicker:!0,closeOnTimeSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect},i=e.extend({},n,t.amsDatetimepickerOptions);i=s.executeFunctionByName(t.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);s.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,i)})})})},colorpicker:function(a){var t=e(".colorpicker",a);t.length>0&&s.ajax.check(e.fn.minicolors,s.baseURL+"ext/jquery-minicolors"+s.devext+".js",function(){s.getCSS(s.baseURL+"../css/ext/jquery-minicolors"+s.devext+".css","jquery-minicolors",function(){t.each(function(){var a=e(this),t=a.data(),n={position:t.amsColorpickerPosition||a.closest("label.input").data("ams-colorpicker-position")||"bottom left"},i=e.extend({},n,t.amsColorpickerOptions);i=s.executeFunctionByName(t.amsColorpickerInitCallback,a,i)||i;var r=a.minicolors(i);s.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,i)})})})},dndupload:function(a){var t=e(".dndupload",a);t.length>0&&s.ajax.check(e.fn.dndupload,s.baseURL+"ext/jquery-dndupload"+s.devext+".js",function(){s.getCSS(s.baseURL+"../css/ext/jquery-dndupload"+s.devext+".css","jquery-dndupload",function(){t.each(function(){var a=e(this),t=a.data(),n={action:t.amsDnduploadAction||a.attr("action")||"upload-files",fieldname:t.amsDnduploadFieldname||"files",autosubmit:t.amsDnduploadAutosubmit},i=e.extend({},n,t.amsDnduploadOptions);i=s.executeFunctionByName(t.amsDnduploadInitCallback,a,i)||i;var r=a.dndupload(i);s.executeFunctionByName(t.amsDnduploadAfterInitcallback,a,r,i)})})})},validate:function(a){var t=e("FORM:not([novalidate])",a);t.length>0&&s.ajax.check(e.fn.validate,s.baseURL+"ext/jquery-validate-1.11.1"+s.devext+".js",function(a){if(a&&(e.validator.setDefaults({highlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").addClass("state-error")},unhighlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").removeClass("state-error")},errorElement:"span",errorClass:"state-error",errorPlacement:function(e,a){var t=a.parents("label:first");t.length?e.insertAfter(t):e.insertAfter(a)}}),s.plugins.i18n)){for(var n in s.plugins.i18n.validate)if(s.plugins.i18n.validate.hasOwnProperty(n)){var i=s.plugins.i18n.validate[n];"string"==typeof i&&i.indexOf("{0}")>-1&&(s.plugins.i18n.validate[n]=e.validator.format(i))}e.extend(e.validator.messages,s.plugins.i18n.validate)}t.each(function(){var a=e(this),t=a.data(),n={ignore:null,submitHandler:void 0!==a.attr("data-async")?void 0===t.amsFormSubmitHandler?function(){return e(".state-error",a).removeClass("state-error"),s.ajax.check(e.fn.ajaxSubmit,s.baseURL+"ext/jquery-form-3.49"+s.devext+".js"),s.form.submit(a)}:s.getFunctionByName(t.amsFormSubmitHandler):void 0,invalidHandler:void 0!==a.attr("data-async")?void 0===t.amsFormInvalidHandler?function(t,n){e(".state-error",a).removeClass("state-error");for(var s=0;s<n.errorList.length;s++){var i=n.errorList[s],r=e(i.element).parents(".tab-pane").index()+1;if(r>0){var o=e(".nav-tabs",e(i.element).parents(".tabforms"));e("li:nth-child("+r+")",o).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",o).click()}}}:s.getFunctionByName(t.amsFormInvalidHandler):void 0};e("[data-ams-validate-rules]",a).each(function(a){0===a&&(n.rules={}),n.rules[e(this).attr("name")]=e(this).data("ams-validate-rules")});var i=e.extend({},n,t.amsValidateOptions);i=s.executeFunctionByName(t.amsValidateInitCallback,a,i)||i;var r=a.validate(i);s.executeFunctionByName(t.amsValidateAfterInitCallback,a,r,i)})})},datatable:function(a){var t=e(".datatable",a);t.length>0&&s.ajax.check(e.fn.dataTable,s.baseURL+"ext/jquery-dataTables-1.9.4"+s.devext+".js",function(){s.ajax.check(e.fn.dataTableExt.oPagination.bootstrap_full,s.baseURL+"myams-dataTables"+s.devext+".js",function(){e(t).each(function(){var a,t=e(this),n=t.data(),i=(n.amsDatatableExtensions||"").split(/\s+/),r=n.amsDatatableSdom||"W"+(i.indexOf("colreorder")>=0||i.indexOf("colreorderwithresize")>=0?"R":"")+"<'dt-top-row'"+(i.indexOf("colvis")>=0?"C":"")+(!1===n.amsDatatablePagination||!1===n.amsDatatablePaginationSize?"":"L")+(!1===n.amsDatatableGlobalFilter?"":"F")+">r<'dt-wrapper't"+(i.indexOf("scroller")>=0?"S":"")+"><'dt-row dt-bottom-row'<'row'<'col-sm-6'"+(!1===n.amsDatatableInformation?"":"i")+"><'col-sm-6 text-right'p>>",o=n.amsDatatableSorting;if("string"==typeof o){var l=o.split(";");for(o=[],a=0;a<l.length;a++){var c=l[a].split(",");c[0]=parseInt(c[0]),o.push(c)}}var d,m=[],u=e("th",t).listattr("data-ams-datatable-sortable");for(a=0;a<u.length;a++){var f=u[a];void 0!==f?((d=m[a]||{}).bSortable="string"==typeof f?JSON.parse(f):f,m[a]=d):m[a]=m[a]||{}}var h=e("th",t).listattr("data-ams-datatable-stype");for(a=0;a<h.length;a++){var p=h[a];p?((d=m[a]||{}).sType=p,m[a]=d):m[a]=m[a]||{}}var g={bJQueryUI:!1,bServerSide:n.amsDatatableServerSide||!1,sAjaxSource:!0===n.amsDatatableServerSide?n.amsDatatableAjaxSource:void 0,sServerMethod:!0===n.amsDatatableServerSide?"POST":void 0,bFilter:!1!==n.amsDatatableGlobalFilter||i.indexOf("columnfilter")>=0,bPaginate:!1!==n.amsDatatablePagination,bInfo:!1!==n.amsDatatableInfo,bSort:!1!==n.amsDatatableSort,aaSorting:o,aoColumns:m.length>0?m:void 0,bDeferRender:!0,bAutoWidth:!1,iDisplayLength:n.amsDatatableDisplayLength||25,sPaginationType:n.amsDatatablePaginationType||"bootstrap_full",sDom:r,oLanguage:s.plugins.i18n.datatables,fnInitComplete:function(a,t){e(".ColVis_Button").addClass("btn btn-default btn-sm").html((s.plugins.i18n.datatables.sColumns||"Columns")+' <i class="fa fa-fw fa-caret-down"></i>')}},b=e.extend({},g,n.amsDatatableOptions),v=[],x=[],y=[];if(i.length>0)for(a=0;a<i.length;a++)switch(i[a]){case"autofill":v.push(e.fn.dataTable.AutoFill),x.push(s.baseURL+"ext/jquery-dataTables-autoFill"+s.devext+".js");break;case"columnfilter":v.push(e.fn.columnFilter),x.push(s.baseURL+"ext/jquery-dataTables-columnFilter"+s.devext+".js");break;case"colreorder":v.push(e.fn.dataTable.ColReorder),x.push(s.baseURL+"ext/jquery-dataTables-colReorder"+s.devext+".js");break;case"colreorderwithresize":v.push(window.ColReorder),x.push(s.baseURL+"ext/jquery-dataTables-colReorderWithResize"+s.devext+".js");break;case"colvis":v.push(e.fn.dataTable.ColVis),x.push(s.baseURL+"ext/jquery-dataTables-colVis"+s.devext+".js"),y.push(function(){b.oColVis=e.extend({},{activate:"click",sAlign:"right"},n.amsDatatableColvisOptions)});break;case"editable":v.push(e.fn.editable),x.push(s.baseURL+"ext/jquery-jeditable"+s.devext+".js"),v.push(e.fn.makeEditable),x.push(s.baseURL+"ext/jquery-dataTables-editable"+s.devext+".js");break;case"fixedcolumns":v.push(e.fn.dataTable.FixedColumns),x.push(s.baseURL+"ext/jquery-dataTables-fixedColumns"+s.devext+".js");break;case"fixedheader":v.push(e.fn.dataTable.Fixedheader),x.push(s.baseURL+"ext/jquery-dataTables-fixedHeader"+s.devext+".js");break;case"keytable":v.push(window.keyTable),x.push(s.baseURL+"ext/jquery-dataTables-keyTable"+s.devext+".js");break;case"rowgrouping":v.push(e.fn.rowGrouping),x.push(s.baseURL+"ext/jquery-dataTables-rowGrouping"+s.devext+".js");break;case"rowreordering":v.push(e.fn.rowReordering),x.push(s.baseURL+"ext/jquery-dataTables-rowReordering"+s.devext+".js");break;case"scroller":v.push(e.fn.dataTable.Scroller),x.push(s.baseURL+"ext/jquery-dataTables-scroller"+s.devext+".js")}y.push(function(){b=s.executeFunctionByName(n.amsDatatableInitCallback,t,b)||b;try{var r=t.dataTable(b);if(s.executeFunctionByName(n.amsDatatableAfterInitCallback,t,r,b),i.length>0)for(a=0;a<i.length;a++)switch(i[a]){case"autofill":var o=e.extend({},n.amsDatatableAutofillOptions,b.autofill);o=s.executeFunctionByName(n.amsDatatableAutofillInitCallback,t,o)||o,t.data("ams-autofill",void 0===n.amsDatatableAutofillConstructor?new e.fn.dataTable.AutoFill(t,o):s.executeFunctionByName(n.amsDatatableAutofillConstructor,t,r,o));break;case"columnfilter":var l=e.extend({},{sPlaceHolder:"head:after"},n.amsDatatableColumnfilterOptions,b.columnfilter);l=s.executeFunctionByName(n.amsDatatableColumnfilterInitCallback,t,l)||l,t.data("ams-columnfilter",void 0===n.amsDatatableColumnfilterConstructor?r.columnFilter(l):s.executeFunctionByName(n.amsDatatableColumnfilterConstructor,t,r,l));break;case"editable":var c=e.extend({},n.amsDatatableEditableOptions,b.editable);c=s.executeFunctionByName(n.amsDatatableEditableInitCallback,t,c)||c,t.data("ams-editable",void 0===n.amsDatatableEditableConstructor?t.makeEditable(c):s.executeFunctionByName(n.amsDatatableEditableConstructor,t,r,c));break;case"fixedcolumns":var d=e.extend({},n.amsDatatableFixedcolumnsOptions,b.fixedcolumns);d=s.executeFunctionByName(n.amsDatatableFixedcolumnsInitCallback,t,d)||d,t.data("ams-fixedcolumns",void 0===n.amsDatatableFixedcolumnsConstructor?new e.fn.dataTable.FixedColumns(t,d):s.executeFunctionByName(n.amsDatatableFixedcolumnsConstructor,t,r,d));break;case"fixedheader":var m=e.extend({},n.amsDatatableFixedheaderOptions,b.fixedheader);m=s.executeFunctionByName(n.amsDatatableFixedheadeInitCallback,t,m)||m,t.data("ams-fixedheader",void 0===n.amsDatatableFixedheaderConstructor?new e.fn.dataTable.FixedHeader(t,m):s.executeFunctionByName(n.amsDatatableFixedheaderConstructor,t,r,m));break;case"keytable":var u={table:t.get(0),datatable:r},f=e.extend({},u,n.amsDatatableKeytableOptions,b.keytable);f=s.executeFunctionByName(n.amsDatatableKeytableInitCallback,t,f)||f,t.data("ams-keytable",void 0===n.amsDatatableKeytableConstructor?new KeyTable(f):s.executeFunctionByName(n.amsDatatableKeytableConstructor,t,r,f));break;case"rowgrouping":var h=e.extend({},n.amsDatatableRowgroupingOptions,b.rowgrouping);h=s.executeFunctionByName(n.amsDatatableRowgroupingInitCallback,t,h)||h,t.data("ams-rowgrouping",void 0===n.amsDatatableRowgroupingConstructor?t.rowGrouping(h):s.executeFunctionByName(n.amsDatatableRowgroupingConstructor,t,r,h));break;case"rowreordering":var p=e.extend({},n.amsDatatableRowreorderingOptions,b.rowreordering);p=s.executeFunctionByName(n.amsDatatableRowreorderingInitCallback,t,p)||p,t.data("ams-rowreordering",void 0===n.amsDatatableRowreorderingConstructor?t.rowReordering(p):s.executeFunctionByName(n.amsDatatableRowreorderingConstructor,t,r,p))}if(n.amsDatatableFinalizeCallback){var g=n.amsDatatableFinalizeCallback.split(/\s+/);if(g.length>0)for(a=0;a<g.length;a++)s.executeFunctionByName(g[a],t,r,b)}}catch(e){}}),s.ajax.check(v,x,y)})})})},tablednd:function(a){var t=e(".table-dnd",a);t.length>0&&s.ajax.check(e.fn.tableDnD,s.baseURL+"ext/jquery-tablednd"+s.devext+".js",function(){t.each(function(){var a=e(this),t=a.data();t.amsTabledndDragHandle?e("tr",a).addClass("no-drag-handle"):e(a).on("mouseover","tr",function(){e(this.cells[0]).addClass("drag-handle")}).on("mouseout","tr",function(){e(this.cells[0]).removeClass("drag-handle")});var n={onDragClass:t.amsTabledndDragClass||"dragging-row",onDragStart:s.getFunctionByName(t.amsTabledndDragStart),dragHandle:t.amsTabledndDragHandle,scrollAmount:t.amsTabledndScrollAmount,onAllowDrop:t.amsTabledndAllowDrop,onDrop:s.getFunctionByName(t.amsTabledndDrop)||function(n,i){var r=t.amsTabledndDropTarget;if(r){e(i).data("ams-disabled-handlers","click");try{var o=[];e(n.rows).each(function(){var a=e(this).data("ams-element-name");a&&o.push(a)});var l=s.getFunctionByName(r);if("function"==typeof l)l.call(a,n,o);else{if(!r.startsWith(window.location.protocol)){var c=t.amsLocation;c&&(r=c+"/"+r)}s.ajax.post(r,{names:JSON.stringify(o)})}}finally{setTimeout(function(){e(i).removeData("ams-disabled-handlers")},50)}}return!1}},i=e.extend({},n,t.amsTabledndOptions);i=s.executeFunctionByName(t.amsTabledndInitCallback,a,i)||i;var r=a.tableDnD(i);s.executeFunctionByName(t.amsTabledndAfterInitCallback,a,r,i)})})},wizard:function(a){var t=e(".wizard",a);t.length>0&&s.ajax.check(e.fn.bootstrapWizard,s.baseURL+"ext/bootstrap-wizard-1.4.2"+s.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n={withVisible:void 0===t.amsWizardWithVisible||t.amsWizardWithVisible,tabClass:t.amsWizardTabClass,firstSelector:t.amsWizardFirstSelector,previousSelector:t.amsWizardPreviousSelector,nextSelector:t.amsWizardNextSelector,lastSelector:t.amsWizardLastSelector,finishSelector:t.amsWizardFinishSelector,backSelector:t.amsWizardBackSelector,onInit:s.getFunctionByName(t.amsWizardInit),onShow:s.getFunctionByName(t.amsWizardShow),onNext:s.getFunctionByName(t.amsWizardNext),onPrevious:s.getFunctionByName(t.amsWizardPrevious),onFirst:s.getFunctionByName(t.amsWizardFirst),onLast:s.getFunctionByName(t.amsWizardLast),onBack:s.getFunctionByName(t.amsWizardBack),onFinish:s.getFunctionByName(t.amsWizardFinish),onTabChange:s.getFunctionByName(t.amsWizardTabChange),onTabClick:s.getFunctionByName(t.amsWizardTabClick),onTabShow:s.getFunctionByName(t.amsWizardTabShow)},i=e.extend({},n,t.amsWizardOptions);i=s.executeFunctionByName(t.amsWizardInitCallback,a,i)||i;var r=a.bootstrapWizard(i);s.executeFunctionByName(t.amsWizardAfterInitCallback,a,r,i)})})},tinymce:function(a){function t(){e(".tinymce",e(this)).each(function(){var a=tinymce.get(e(this).attr("id"));a&&a.remove()})}var n=e(".tinymce",a);if(n.length>0){var i=s.baseURL+"ext/tinymce"+(s.devmode?"/dev":"");s.ajax.check(window.tinymce,i+"/tinymce"+s.devext+".js",function(a){function r(){n.each(function(){var a=e(this),t=a.data(),n={theme:t.amsTinymceTheme||"modern",language:s.lang,menubar:!1!==t.amsTinymceMenubar,statusbar:!1!==t.amsTinymceStatusbar,plugins:t.amsTinymcePlugins||["advlist autosave autolink lists link charmap print preview hr anchor pagebreak","searchreplace wordcount visualblocks visualchars code fullscreen","insertdatetime nonbreaking save table contextmenu directionality","emoticons paste textcolor colorpicker textpattern autoresize"],toolbar:t.amsTinymceToolbar,toolbar1:!1!==t.amsTinymceToolbar1&&(t.amsTinymceToolbar1||"undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"),toolbar2:!1!==t.amsTinymceToolbar2&&(t.amsTinymceToolbar2||"forecolor backcolor emoticons | charmap link image media | fullscreen preview print | code"),content_css:t.amsTinymceContentCss,formats:t.amsTinymceFormats,style_formats:t.amsTinymceStyleFormats,block_formats:t.amsTinymceBlockFormats,valid_classes:t.amsTinymceValidClasses,image_advtab:!0,image_list:s.getFunctionByName(t.amsTinymceImageList)||t.amsTinymceImageList,image_class_list:t.amsTinymceImageClassList,link_list:s.getFunctionByName(t.amsTinymceLinkList)||t.amsTinymceLinkList,link_class_list:t.amsTinymceLinkClassList,height:50,min_height:50,autoresize_min_height:50,autoresize_max_height:500,resize:!0};if(t.amsTinymceExternalPlugins){var i=t.amsTinymceExternalPlugins.split(/\s+/);for(var r in i)if(i.hasOwnProperty(r)){var o=a.data("ams-tinymce-plugin-"+i[r]);tinymce.PluginManager.load(i[r],s.getSource(o))}}var l=e.extend({},n,t.amsTinymceOptions);l=s.executeFunctionByName(t.amsTinymceInitCallback,a,l)||l;var c=a.tinymce(l);s.executeFunctionByName(t.amsTinymceAfterInitCallback,a,c,l)})}a?s.getScript(i+"/jquery.tinymce"+s.devext+".js",function(){tinymce.baseURL=i,tinymce.suffix=s.devext,s.skin.registerCleanCallback(t),r()}):r()})}},imgareaselect:function(a){var t=e(".imgareaselect",a);t.length>0&&s.ajax.check(e.fn.imgAreaSelect,s.baseURL+"ext/jquery-imgareaselect-0.9.11-rc1"+s.devext+".js",function(){s.getCSS(s.baseURL+"../css/ext/jquery-imgareaselect"+s.devext+".css","jquery-imgareaselect",function(){t.each(function(){var a=e(this),t=a.data(),n=t.amsImgareaselectParent?a.parents(t.amsImgareaselectParent):"body",i={instance:!0,handles:!0,parent:n,x1:t.amsImgareaselectX1||0,y1:t.amsImgareaselectY1||0,x2:t.amsImgareaselectX2||t.amsImgareaselectImageWidth,y2:t.amsImgareaselectY2||t.amsImgareaselectImageHeight,imageWidth:t.amsImgareaselectImageWidth,imageHeight:t.amsImgareaselectImageHeight,minWidth:128,minHeight:128,aspectRatio:t.amsImgareaselectRatio,onSelectEnd:s.getFunctionByName(t.amsImgareaselectSelectEnd)||function(a,s){var i=t.amsImgareaselectTargetField||"image_";e('input[name="'+i+'x1"]',n).val(s.x1),e('input[name="'+i+'y1"]',n).val(s.y1),e('input[name="'+i+'x2"]',n).val(s.x2),e('input[name="'+i+'y2"]',n).val(s.y2)}},r=e.extend({},i,t.amsImgareaselectOptions);r=s.executeFunctionByName(t.amsImgareaselectInitCallback,a,r)||r;var o=a.imgAreaSelect(r);s.executeFunctionByName(t.amsImgareaselectAfterInitCallback,a,o,r),setTimeout(function(){o.update()},250)})})})},fancybox:function(a){var t=e(".fancybox",a);t.length>0&&s.ajax.check(e.fn.fancybox,s.baseURL+"ext/jquery-fancybox-2.1.5"+s.devext+".js",function(){s.getCSS(s.baseURL+"../css/ext/jquery-fancybox-2.1.5"+s.devext+".css","jquery-fancybox",function(){t.each(function(){var a,t=e(this),n=t.data(),i=t;n.amsFancyboxElements&&(i=e(n.amsFancyboxElements,t));var r=(n.amsFancyboxHelpers||"").split(/\s+/);if(r.length>0)for(a=0;a<r.length;a++)switch(r[a]){case"buttons":s.ajax.check(e.fancybox.helpers.buttons,s.baseURL+"ext/fancybox-helpers/fancybox-buttons"+s.devext+".js");break;case"thumbs":s.ajax.check(e.fancybox.helpers.thumbs,s.baseURL+"ext/fancybox-helpers/fancybox-thumbs"+s.devext+".js");break;case"media":s.ajax.check(e.fancybox.helpers.media,s.baseURL+"ext/fancybox-helpers/fancybox-media"+s.devext+".js")}var o={type:n.amsFancyboxType,padding:n.amsFancyboxPadding||10,margin:n.amsFancyboxMargin||10,loop:n.amsFancyboxLoop,beforeLoad:s.getFunctionByName(n.amsFancyboxBeforeLoad)||function(){var a;if(n.amsFancyboxTitleGetter&&(a=s.executeFunctionByName(n.amsFancyboxTitleGetter,this)),!a){var t=e("*:first",this.element);(a=t.attr("original-title")||t.attr("title"))||(a=e(this.element).attr("original-title")||e(this.element).attr("title"))}this.title=a},afterLoad:s.getFunctionByName(n.amsFancyboxAfterLoad),helpers:{title:{type:"inside"}}};if(r.length>0)for(a=0;a<r.length;a++)switch(r[a]){case"buttons":o.helpers.buttons={position:n.amsFancyboxButtonsPosition||"top"};break;case"thumbs":o.helpers.thumbs={width:n.amsFancyboxThumbsWidth||50,height:n.amsFancyboxThumbsHeight||50};break;case"media":o.helpers.media=!0}var l=e.extend({},o,n.amsFancyboxOptions);l=s.executeFunctionByName(n.amsFancyboxInitCallback,t,l)||l;var c=i.fancybox(l);s.executeFunctionByName(n.amsFancyboxAfterInitCallback,t,c,l)})})})},chart:function(a){var t=e(".chart",a);t.length>0&&s.ajax.check(e.fn.plot,s.baseURL+"flot/jquery.flot"+s.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n=(t.amsChartPlugins||"").split(/\s+/);if(n.length>0)for(var i in n)if(n.hasOwnProperty(i)){var r=n[i];(function(a){for(var t in e.plot.plugins)if(e.plot.plugins.hasOwnProperty(t)){var n=e.plot.plugins[t];if(n.name===a)return n}return null})(r)||s.getScript(s.baseURL+"flot/jquery.flot."+r+s.devext+".js")}var o=e.extend({},{},t.amsChartOptions);o=s.executeFunctionByName(t.amsChartInitCallback,a,o)||o;var l=t.amsChartData;l=s.executeFunctionByName(t.amsChartInitData,a,l)||l;var c=a.plot(l,o);s.executeFunctionByName(t.amsChartAfterInitCallback,a,c,o)})})},graphs:function(a){var t=e(".sparkline",a);t.length>0&&s.ajax.check(s.graphs,s.baseURL+"myams-graphs"+s.devext+".js",function(){s.graphs.init(t)})},scrollbars:function(a){var t=e(".scrollbar",a);t.length>0&&s.ajax.check(e.event.special.mousewheel,s.baseURL+"ext/jquery-mousewheel.min.js",function(){s.ajax.check(e.fn.mCustomScrollbar,s.baseURL+"ext/jquery-mCustomScrollbar"+s.devext+".js",function(){s.getCSS(s.baseURL+"../css/ext/jquery-mCustomScrollbar.css","jquery-mCustomScrollbar",function(){t.each(function(){var a=e(this),t=a.data(),n={theme:t.amsScrollbarTheme||"light"},i=e.extend({},n,t.amsScrollbarOptions);i=s.executeFunctionByName(t.amsScrollbarInitCallback,a,i)||i;var r=a.mCustomScrollbar(i);s.executeFunctionByName(t.amsScrollbarAfterInitCallback,a,r,i)})})})})}}},n.callbacks={init:function(a){e("[data-ams-callback]",a).each(function(){var a=this,n=e(a).data(),i=s.getFunctionByName(n.amsCallback);void 0===i?n.amsCallbackSource?s.getScript(n.amsCallbackSource,function(){s.executeFunctionByName(n.amsCallback,a,n.amsCallbackOptions)}):t&&t.warn&&t.warn("Undefined callback: "+n.amsCallback):i.call(a,n.amsCallbackOptions)})},alert:function(a){var t=e(this).data(),n=e.extend({},a,t.amsAlertOptions),i=e(t.amsAlertParent||n.parent||this),r=t.amsAlertStatus||n.status||"info",o=t.amsAlertHeader||n.header,l=t.amsAlertMessage||n.message,c=t.amsAlertSubtitle||n.subtitle,d=void 0===t.amsAlertMargin?void 0!==n.margin&&n.margin:t.amsAlertMargin;s.skin.alert(i,r,o,l,c,d)},messageBox:function(a){var t=e(this).data(),n=e.extend({},a,t.amsMessageboxOptions),i=e.extend({},n,{title:t.amsMessageboxTitle||n.title||"",content:t.amsMessageboxContent||n.content||"",icon:t.amsMessageboxIcon||n.icon,number:t.amsMessageboxNumber||n.number,timeout:t.amsMessageboxTimeout||n.timeout}),r=t.amsMessageboxStatus||n.status||"info",o=s.getFunctionByName(t.amsMessageboxCallback||n.callback);s.skin.messageBox(r,i,o)},smallBox:function(a){var t=e(this).data(),n=e.extend({},a,t.amsSmallboxOptions),i=e.extend({},n,{title:t.amsSmallboxTitle||n.title||"",content:t.amsSmallboxContent||n.content||"",icon:t.amsSmallboxIcon||n.icon,iconSmall:t.amsSmallboxIconSmall||n.iconSmall,timeout:t.amsSmallboxTimeout||n.timeout}),r=t.amsSmallboxStatus||n.status||"info",o=s.getFunctionByName(t.amsSmallboxCallback||n.callback);s.skin.smallBox(r,i,o)}},n.events={init:function(a){e("[data-ams-events-handlers]",a).each(function(){var a=e(this),t=a.data("ams-events-handlers");if(t)for(var n in t)t.hasOwnProperty(n)&&a.on(n,s.getFunctionByName(t[n]))})}},n.container={changeOrder:function(a,t){e('input[name="'+e(this).data("ams-input-name")+'"]',e(this)).val(t.join(";"))},deleteElement:function(){return function(){var a=e(this);n.skin.bigBox({title:s.i18n.WARNING,content:'<i class="text-danger fa fa-fw fa-bell"></i>&nbsp; '+s.i18n.DELETE_WARNING,status:"info",buttons:s.i18n.BTN_OK_CANCEL},function(e){if(e===s.i18n.BTN_OK){var t=a.parents("tr").first(),i=t.parents("table").first(),r=t.data("ams-location")||i.data("ams-location")||"";r&&(r+="/");var o=t.data("ams-delete-target")||i.data("ams-delete-target")||"delete-element.json",l=t.data("ams-element-name");n.ajax.post(r+o,{object_name:l},function(e,a){"success"===e.status?(i.hasClass("datatable")?i.dataTable().fnDeleteRow(t[0]):t.remove(),e.handle_json&&n.ajax.handleJSON(e)):n.ajax.handleJSON(e)})}})}},switchElementVisibility:function(){return function(){var a=e(this),t=a.parents("tr").first(),n=t.parents("table");s.ajax.post(n.data("ams-location")+"/"+n.data("ams-visibility-switcher"),{object_name:t.data("ams-element-name")},function(t,n){t.visible?e("i",a).attr("class","fa fa-fw fa-eye"):e("i",a).attr("class","fa fa-fw fa-eye-slash text-danger")})}}},n.tree={switchTableNode:function(){function a(t){e('tr[data-ams-tree-node-parent-id="'+t+'"]').each(function(){var t=e(this);a(t.data("ams-tree-node-id")),t.remove()})}var t=e(this),i=e("i.switch",t),r=t.parents("tr").first(),o=r.parents("table").first();if(i.hasClass("fa-minus-square-o"))a(r.data("ams-tree-node-id")),i.removeClass("fa-minus-square-o").addClass("fa-plus-square-o");else{var l=r.data("ams-location")||o.data("ams-location")||"",c=r.data("ams-tree-nodes-target")||o.data("ams-tree-nodes-target")||"get-tree-nodes.json",d=r.data("ams-element-name");i.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin"),n.ajax.post(l+"/"+d+"/"+c,{can_sort:!e("td.sorter",r).is(":empty")},function(a,t){if(a.length>0){for(var n=r,l=0;l<a.length;l++){var c=e(a[l]);c.insertAfter(n).addClass("no-drag-handle"),s.initContent(c),n=c}o.hasClass("table-dnd")&&o.tableDnDUpdate()}i.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o")})}},switchTree:function(){var a=e(this),t=e("i.switch",a),i=e(this).parents("table").first(),r=i.data("ams-tree-node-id");if(t.hasClass("fa-minus-square-o"))e("tr[data-ams-tree-node-parent-id]").filter('tr[data-ams-tree-node-parent-id!="'+r+'"]').remove(),e("i.switch",i).removeClass("fa-minus-square-o").addClass("fa-plus-square-o");else{var o=e("tbody tr",i).first(),l=i.data("ams-location")||"",c=i.data("ams-tree-nodes-target")||"get-tree.json";t.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin"),n.ajax.post(l+"/"+c,{can_sort:!e("td.sorter",o).is(":empty")},function(a,n){e("tr[data-ams-tree-node-id]",i).remove();for(var r=null,o=0;o<a.length;o++){var l=e(a[o]);null===r?l.appendTo(e("tbody",i)):l.insertAfter(r),l.addClass("no-drag-handle"),s.initContent(l),r=l}i.hasClass("table-dnd")&&i.tableDnDUpdate(),e("i.switch",i).removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),t.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o")})}},sortTree:function(a,t){var n=e(a).data(),i=n.amsTabledndDropTarget;if(i){(t=e(t)).data("ams-disabled-handlers","click");try{var r=t.parents("table").first().data("ams-tree-node-id"),o=t.data("ams-tree-node-id"),l=t.data("ams-tree-node-parent-id"),c=t.prev("tr");if(c.exists()){var d=c.data("ams-tree-node-id"),m=e(".switch",c);if(m.hasClass("fa-minus-square-o"))if(l===d)var u="reorder";else u="reparent";else u=l===(d=c.data("ams-tree-node-parent-id"))?"reorder":"reparent"}else m=null,u=l===(d=r)?"reorder":"reparent";var f=s.getFunctionByName(i);if("function"==typeof f)f.call(table,a,p);else{if(!i.startsWith(window.location.protocol)){var h=n.amsLocation;h&&(i=h+"/"+i)}var p={action:u,child:o,parent:d,order:JSON.stringify(e("tr[data-ams-tree-node-id]").listattr("data-ams-tree-node-id")),can_sort:!e("td.sorter",t).is(":empty")};s.ajax.post(i,p,function(a){function n(a){e('tr[data-ams-tree-node-parent-id="'+a+'"]').each(function(){var a=e(this);n(a.attr("data-ams-tree-node-id")),a.remove()})}if(a.status)s.ajax.handleJSON(a);else{var i=e(t).parents("tbody").first();if(n(o),"reparent"===p.action){n(d),t.remove();for(var r=e('tr[data-ams-tree-node-id="'+d+'"]'),l=0;l<a.length;l++){var c=e(a[l]);r.exists()?c.insertAfter(r).addClass("no-drag-handle"):c.prependTo(i).addClass("no-drag-handle"),s.initContent(c),r=c}}e("tr").parents("table").tableDnDUpdate()}})}}finally{setTimeout(function(){e(t).removeData("ams-disabled-handlers")},50)}}return!1}},n.skin={_setPageHeight:function(){var a=e("#main").height(),t=(s.leftPanel.height(),e(window).height()-s.navbarHeight);a>t?s.root.css("min-height",a+s.navbarHeight):s.root.css("min-height",t),s.leftPanel.css("min-height",t),s.leftPanel.css("max-height",t)},_checkMobileWidth:function(){e(window).width()<979?s.root.addClass("mobile-view-activated"):s.root.hasClass("mobile-view-activated")&&s.root.removeClass("mobile-view-activated")},_showShortcutButtons:function(){s.shortcuts.animate({height:"show"},200,"easeOutCirc"),s.root.addClass("shortcut-on")},_hideShortcutButtons:function(){s.shortcuts.animate({height:"hide"},300,"easeOutCirc"),s.root.removeClass("shortcut-on")},checkNotification:function(){var a=e("#activity > .badge");parseInt(a.text())>0?a.removeClass("hidden").addClass("bg-color-red bounceIn animated"):a.addClass("hidden").removeClass("bg-color-red bounceIn animated")},refreshNotificationsPanel:function(a){var t=e(this);t.addClass("disabled"),e("i",t).addClass("fa-spin"),e('input[name="activity"]:checked',"#user-activity").change(),e("i",t).removeClass("fa-spin"),t.removeClass("disabled")},refreshContent:function(a){var t=e('[id="'+a.object_id+'"]');return t.replaceWith(e(a.content)),t=e('[id="'+a.object_id+'"]'),n.initContent(t),t},refreshWidget:function(a){var t=e('[id="'+a.parent_id+'"]'),s=e('[name="'+a.widget_name+'"]',t);s.exists()||(s=e('[name="'+a.widget_name+':list"]',t));var i=s.parents("label.input").last();return i.html(a.content),n.initContent(i),i},refreshTable:function(a){var t=e('[id="'+a.object_id+'"]').parents(".ams-widget:first");return t.replaceWith(e(a.table)),t=e('[id="'+a.object_id+'"]').parents(".ams-widget:first"),n.initContent(t),t},refreshSwitchedTable:function(e){var a=s.skin.refreshTable(e).siblings("legend");a.parents("fieldset:first").hasClass("switched")&&a.click()},refreshRow:function(a){var t=e('tr[id="'+a.object_id+'"]'),s=t.parents("table").first(),i=e(a.row);return t.replaceWith(i),n.initContent(i),s.hasClass("table-dnd")&&(i.addClass("no-drag-handle"),s.tableDnDUpdate()),i},refreshRowCell:function(a){var t=e('tr[id="'+a.object_id+'"]'),s=t.parents("table").first(),i=e("tr",e("thead",s)),r=e('th[data-ams-column-name="'+a.col_name+'"]',i),o=e("th",i).index(r);if(o>-1){var l=e(e("td",t).get(o));l.html(a.cell),n.initContent(l)}},_initDesktopWidgets:function(t){if(s.enableWidgets){var n=e(".ams-widget",t);n.length>0&&s.ajax.check(e.fn.MyAMSWidget,s.baseURL+"myams-widgets"+s.devext+".js",function(){n.each(function(){var a=e(this),t=a.data(),n=e.extend({},{deleteSettingsKey:"#deletesettingskey-options",deletePositionKey:"#deletepositionkey-options"},t.amsWidgetOptions);n=s.executeFunctionByName(t.amsWidgetInitcallback,a,n)||n,a.MyAMSWidget(n)}),a.MyAMSWidget.initWidgetsGrid(e(".ams-widget-grid",t))})}},_initMobileWidgets:function(e){s.enableMobile&&s.enableWidgets&&s.skin._initDesktopWidgets(e)},alert:function(a,t,n,i,r,o){"error"===t&&(t="danger"),e(".alert-"+t,a).not(".persistent").remove();var l='<div class="'+(o?"margin-10":"")+" alert alert-block alert-"+t+' padding-5 fade in"><a class="close" data-dismiss="alert"><i class="fa fa-check"></i></a><h4 class="alert-heading"><i class="fa fa-fw fa-warning"></i> '+n+"</h4>"+(r?"<p>"+r+"</p>":"");if("string"==typeof i)l+="<ul><li>"+i+"</li></ul>";else if(i){l+="<ul>";for(var c in i)e.isNumeric(c)&&(l+="<li>"+i[c]+"</li>");l+="</ul>"}e(l+="</div>").insertBefore(a),a.exists&&s.skin.scrollTo(a,{offset:{top:-50}})},bigBox:function(e,a){s.ajax.check(s.notify,s.baseURL+"myams-notify"+s.devext+".js",function(){s.notify.messageBox(e,a)})},messageBox:function(e,a,t){"object"==typeof e&&(t=a,a=e||{},e="info"),s.ajax.check(s.notify,s.baseURL+"myams-notify"+s.devext+".js",function(){switch(e){case"error":case"danger":a.color="#C46A69";break;case"warning":a.color="#C79121";break;case"success":a.color="#739E73";break;default:a.color=a.color||"#3276B1"}a.sound=!1,s.notify.bigBox(a,t)})},smallBox:function(e,a,t){"object"==typeof e&&(t=a,a=e||{},e="info"),s.ajax.check(s.notify,s.baseURL+"myams-notify"+s.devext+".js",function(){switch(e){case"error":case"danger":a.color="#C46A69";break;case"warning":a.color="#C79121";break;case"success":a.color="#739E73";break;default:a.color=a.color||"#3276B1"}a.sound=!1,s.notify.smallBox(a,t)})},scrollTo:function(a,t){s.ajax.check(e.scrollTo,s.baseURL+"ext/jquery-scrollto-2.1.2"+s.devext+".js",function(){var n=e("body"),s=t.offset||0;n.hasClass("fixed-header")&&(s-=e("#header").height()),n.hasClass("fixed-ribbon")&&(s-=e("#ribbon").height()),t=e.extend({},t,{offset:s}),e.scrollTo(a,t)})},_drawBreadCrumb:function(){var a=e("OL.breadcrumb","#ribbon");e("li",a).not(".parent").remove(),e("li",a).exists()||a.append(e("<li></li>").append(e("<a></a>").text(s.i18n.HOME).addClass("padding-right-5").attr("href",e('nav a[href!="#"]:first').attr("href")))),e("LI.active >A","nav").each(function(){var t=e(this),n=e.trim(t.clone().children(".badge").remove().end().text()),s=e("<li></li>").append(t.attr("href").replace(/^#/,"")?e("<a></a>").html(n).attr("href",t.attr("href")):n);a.append(s)})},checkURL:function(){function a(a){e(".active",n).removeClass("active"),a.addClass("open").addClass("active"),a.parents("li").addClass("open active").children("ul").addClass("active").show(),a.parents("li:first").removeClass("open"),a.parents("ul").addClass(a.attr("href").replace(/^#/,"")?"active":"").show()}var t,n=e("nav"),i=location.hash,r=i.replace(/^#/,"");if(r){var o=e("#content");o.exists()||(o=e("body")),(t=e('A[href="'+i+'"]',n)).exists()&&a(t),s.skin.loadURL(r,o,{afterLoadCallback:function(){var a=e("html head title").data("ams-title-prefix");document.title=(a?a+" > ":"")+(e("[data-ams-page-title]:first",o).data("ams-page-title")||t.attr("title")||document.title)}})}else{var l=e("[data-ams-active-menu]").data("ams-active-menu");(t=l?e('A[href="'+l+'"]',n):e('>UL >LI >A[href!="#"]',n).first()).exists()&&(a(t),l?s.skin._drawBreadCrumb():window.location.hash=t.attr("href"))}},_clean_callbacks:[],registerCleanCallback:function(e){var a=s.skin._clean_callbacks;a.indexOf(e)<0&&a.push(e)},unregisterCleanCallback:function(e){var a=s.skin._clean_callbacks,t=a.indexOf(e);t>=0&&a.splice(t,1)},cleanContainer:function(e){for(var a=s.skin._clean_callbacks,t=0;t<a.length;t++)a[t].call(e)},loadURL:function(a,t,n,i){a.startsWith("#")&&(a=a.substr(1)),"function"==typeof n?(i=n,n={}):void 0===n&&(n={}),t=e(t);var r={type:"GET",url:a,dataType:"html",cache:!1,beforeSend:function(){if(n&&n.preLoadCallback&&s.executeFunctionByName(n.preLoadCallback,this),s.skin.cleanContainer(t),t.html('<h1 class="loading"><i class="fa fa-cog fa-spin"></i> '+s.i18n.LOADING+" </h1>"),t[0]===e("#content")[0]){s.skin._drawBreadCrumb();var a=e("html head title").data("ams-title-prefix");document.title=(a?a+" > ":"")+e(".breadcrumb LI:last-child").text(),e("html, body").animate({scrollTop:0},"fast")}else t.animate({scrollTop:0},"fast")},success:function(a,r,o){if(i)s.executeFunctionByName(i,this,a,r,o,n);else{var l=s.ajax.getResponse(o),c=l.contentType,d=l.data;switch(e(".loading",t).remove(),c){case"json":s.ajax.handleJSON(d,t);break;case"script":case"xml":break;case"html":case"text":default:t.parents(".hidden").removeClass("hidden"),e(".alert",t.parents(".alerts-container")).remove(),t.css({opacity:"0.0"}).html(a).removeClass("hidden").delay(50).animate({opacity:"1.0"},300),s.initContent(t),s.form.setFocus(t)}n&&n.afterLoadCallback&&s.executeFunctionByName(n.afterLoadCallback,this),s.stats.logPageview()}},error:function(e,a,i){t.html('<h3 class="error"><i class="fa fa-warning txt-color-orangeDark"></i> '+s.i18n.ERROR+i+"</h3>"+e.responseText),n&&n.afterErrorCallback&&s.executeFunctionByName(n.afterErrorCallback,this)},async:void 0===n.async||n.async},o=e.extend({},r,n);e.ajax(o)},setLanguage:function(e,a){var t=a.lang;switch(a.handler_type||"json"){case"json":var n=a.method||"setUserLanguage";s.jsonrpc.post(n,{lang:t},function(){window.location.reload(!0)});break;case"ajax":var i=a.href||"setUserLanguage";s.ajax.post(i,{lang:t},function(){window.location.reload(!0)})}},logout:function(){window.location=s.loginURL}},n.stats={logPageview:function(e){if(void 0!==a._gaq){var t=a.window.location;a._gaq.push(["_trackPageview",e||t.pathname+t.hash])}},logEvent:function(e,t,n){void 0!==a._gaq&&("object"==typeof e&&(t=e.action,n=e.label,e=e.category),a._gaq.push(["_trackEvent",e,t,n]))}},n.initPage=function(){var a=e("body");s.root=a,s.leftPanel=e("#left-panel"),s.shortcuts=e("#shortcut"),s.plugins.initData(a);var t=e.ajaxSettings.xhr;e.ajaxSetup({progress:s.ajax.progress,progressUpload:s.ajax.progress,xhr:function(){var e=t();if(e&&"function"==typeof e.addEventListener){var a=this;a&&a.progress&&e.addEventListener("progress",function(e){a.progress(e)},!1)}return e}}),e(document).ajaxStart(s.ajax.start),e(document).ajaxStop(s.ajax.stop),e(document).ajaxError(s.error.ajax),s.isMobile?(s.root.addClass("mobile-detected"),s.device="mobile",s.enableFastclick&&s.ajax.check(e.fn.noClickDelay,s.baseURL+"/ext/jquery-smartclick"+s.devext+".js",function(){e("NAV UL A").noClickDelay(),e("A","#hide-menu").noClickDelay()})):(s.root.addClass("desktop-detected"),s.device="desktop"),e("#hide-menu").find(">:first-child >A").click(function(e){a.toggleClass("hidden-menu"),e.preventDefault()}),e("#show-shortcut").click(function(e){s.shortcuts.is(":visible")?s.skin._hideShortcutButtons():s.skin._showShortcutButtons(),e.preventDefault()}),s.shortcuts.click(function(e){s.skin._hideShortcutButtons()}),e(document).mouseup(function(e){s.shortcuts.is(e.target)||0!==s.shortcuts.has(e.target).length||s.skin._hideShortcutButtons()}),e("#search-mobile").click(function(){s.root.addClass("search-mobile")}),e("#cancel-search-js").click(function(){s.root.removeClass("search-mobile")}),e("#activity").click(function(a){var t=e(this),n=t.next(".ajax-dropdown");n.is(":visible")?(n.fadeOut(150),t.removeClass("active")):(n.css("left",t.position().left-n.innerWidth()/2+t.innerWidth()/2).fadeIn(150),t.addClass("active")),a.preventDefault()}),s.skin.checkNotification(),e(document).mouseup(function(a){var t=e(".ajax-dropdown");t.is(a.target)||0!==t.has(a.target).length||t.fadeOut(150).prev().removeClass("active")}),e('input[name="activity"]').change(function(a){var t=e(this).data("ams-url");if(t){a.preventDefault(),a.stopPropagation();var n=s.getFunctionByName(t);if("function"==typeof n&&(t=n.call(this)),"function"==typeof t)t.call(this);else{var i=e(".ajax-notifications");s.skin.loadURL(t,i)}}}),e("a","#logout").click(function(a){a.preventDefault(),a.stopPropagation(),s.loginURL=e(this).attr("href"),s.skin.bigBox({title:"<i class='fa fa-sign-out txt-color-orangeDark'></i> "+s.i18n.LOGOUT+" <span class='txt-color-orangeDark'><strong>"+e("#show-shortcut").text()+"</strong></span> ?",content:s.i18n.LOGOUT_COMMENT,buttons:s.i18n.BTN_YES_NO},function(e){e===s.i18n.BTN_YES&&(s.root.addClass("animated fadeOutUp"),setTimeout(s.skin.logout,1e3))})});var i=e("nav");e("UL",i).myams_menu({accordion:!1!==i.data("ams-menu-accordion"),speed:s.menuSpeed}),e(".minifyme").click(function(a){e("BODY").toggleClass("minified"),e(this).effect("highlight",{},500),a.preventDefault()}),e("#refresh").click(function(e){s.skin.bigBox({title:"<i class='fa fa-refresh' style='color: green'></i> "+s.i18n.CLEAR_STORAGE_TITLE,content:s.i18n.CLEAR_STORAGE_CONTENT,buttons:"["+s.i18n.BTN_CANCEL+"]["+s.i18n.BTN_OK+"]"},function(e){e===s.i18n.BTN_OK&&localStorage&&(localStorage.clear(),location.reload())}),e.preventDefault()}),a.on("click",function(a){var t=e(this);t.is(a.target)||0!==t.has(a.target).length||0!==e(".popover").has(a.target).length||t.popover("hide")}),s.ajax.check(e.resize,s.baseURL+"ext/jquery-resize"+s.devext+".js",function(){e("#main").resize(function(){s.skin._setPageHeight(),s.skin._checkMobileWidth()}),i.resize(function(){s.skin._setPageHeight()})}),s.ajaxNav&&(e(document).on("click",'a[href="#"]',function(e){e.preventDefault()}),e(document).on("click",'a[href!="#"]:not([data-toggle]), [data-ams-url]:not([data-toggle])',function(a){var t=e(a.currentTarget),n=t.data("ams-disabled-handlers");if(!0!==n&&"click"!==n&&"all"!==n){var i=t.attr("href")||t.data("ams-url");if(i&&!i.startsWith("javascript")&&!t.attr("target")&&!0!==t.data("ams-context-menu")){a.preventDefault(),a.stopPropagation();var r=s.getFunctionByName(i);if("function"==typeof r&&(i=r.call(t)),"function"==typeof i)i.call(t);else if(i=i.replace(/\%23/,"#"),a.ctrlKey)window.open(i);else{var o=t.data("ams-target");o?s.form.confirmChangedForm(o,function(){s.skin.loadURL(i,o,t.data("ams-link-options"),t.data("ams-link-callback"))}):s.form.confirmChangedForm(function(){i.startsWith("#")?i!==location.hash&&(s.root.hasClass("mobile-view-activated")?(s.root.removeClass("hidden-menu"),window.setTimeout(function(){window.location.hash=i},50)):window.location.hash=i):window.location=i})}}}}),e(document).on("click",'a[target="_blank"]',function(a){a.preventDefault();var t=e(a.currentTarget);window.open(t.attr("href")),s.stats.logEvent(t.data("ams-stats-category")||"Navigation",t.data("ams-stats-action")||"External",t.data("ams-stats-label")||t.attr("href"))}),e(document).on("click",'a[target="_top"]',function(a){a.preventDefault(),s.form.confirmChangedForm(function(){window.location=e(a.currentTarget).attr("href")})}),e(window).on("hashchange",s.skin.checkURL)),e(document).off("click.modal").on("click",'[data-toggle="modal"]',function(a){var t=e(this),n=t.data("ams-disabled-handlers");!0!==n&&"click"!==n&&"all"!==n&&!0!==t.data("ams-context-menu")&&(!0===t.data("ams-stop-propagation")&&a.stopPropagation(),a.preventDefault(),s.dialog.open(t),t.parents("#shortcut").exists()&&setTimeout(s.skin._hideShortcutButtons,300))}),e(document).on("click",'button[type="submit"], button.submit',function(){var a=e(this);e(a.get(0).form).data("ams-submit-button",a)}),e(document).on("click",'input[type="checkbox"][readonly]',function(){return!1}),e(document).on("click","[data-ams-click-handler]",function(a){var t=e(this),n=t.data("ams-disabled-handlers");if(!0!==n&&"click"!==n&&"all"!==n){var i=t.data();if(i.amsClickHandler){!0!==i.amsStopPropagation&&!0!==i.amsClickStopPropagation||a.stopPropagation(),!0!==i.amsClickKeepDefault&&a.preventDefault();var r=s.getFunctionByName(i.amsClickHandler);void 0!==r&&r.call(t,a,i.amsClickHandlerOptions)}}}),e(document).on("change","[data-ams-change-handler]",function(a){var t=e(this);if(!t.prop("readonly")){var n=t.data("ams-disabled-handlers");if(!0!==n&&"change"!==n&&"all"!==n){var i=t.data();if(i.amsChangeHandler){!0!==i.amsStopPropagation&&!0!==i.amsChangeStopPropagation||a.stopPropagation(),!0!==i.amsChangeKeepDefault&&a.preventDefault();var r=s.getFunctionByName(i.amsChangeHandler);void 0!==r&&r.call(t,a,i.amsChangeHandlerOptions)}}}}),e(document).on("keydown","textarea",function(a){10!==a.keyCode&&13!==a.keyCode||!a.ctrlKey&&!a.metaKey||e(this).closest("form").submit()}),e(document).on("reset","form",function(a){var t=e(this);setTimeout(function(){e(".alert-danger, SPAN.state-error",t).not(".persistent").remove(),e("LABEL.state-error",t).removeClass("state-error"),e('INPUT.select2[type="hidden"]',t).each(function(){var a=e(this),t=a.data("select2"),n=a.data("ams-select2-input-value");n&&a.select2("val",n.split(t.opts.separator))}),t.find(".select2").trigger("change"),e("[data-ams-reset-callback]",t).each(function(){var a=e(this),n=a.data(),i=s.getFunctionByName(n.amsResetCallback);void 0!==i&&i.call(t,a,n.amsResetCallbackOptions)})},10),s.form.setFocus(t)}),e(document).on("reset","[data-ams-reset-handler]",function(a){var t=e(this),n=t.data();if(n.amsResetHandler){!0!==n.amsResetKeepDefault&&a.preventDefault();var i=s.getFunctionByName(n.amsResetHandler);void 0!==i&&i.call(t,n.amsResetHandlerOptions)}}),e(document).on("click","[data-ams-click-event]",function(a){var t=e(this);e(a.target).trigger(t.data("ams-click-event"),t.data("ams-click-event-options"))}),e(document).on("change",'input[type="file"]',function(a){a.preventDefault();var t=e(this),n=t.parent(".button");n.exists()&&n.parent().hasClass("input-file")&&n.next('input[type="text"]').val(t.val())}),e(document).on("focus",'input[readonly="readonly"]',function(){e(this).blur()}),e(document).on("focusin",function(a){e(a.target).closest(".mce-window").length&&a.stopImmediatePropagation()}),e(document).on("click",".nav-tabs a[data-toggle=tab]",function(a){if(e(this).parent("li").hasClass("disabled"))return a.preventDefault(),!1}),e(document).on("show.bs.dropdown",".btn-group",function(){var a=e(this),t=a.children(".dropdown-menu"),n=a.get(0).getBoundingClientRect(),s=n.top,i=n.height,r=t.outerHeight();s>r&&e(window).height()-s<i+r&&a.addClass("dropup")}).on("hidden.bs.dropdown",".btn-group",function(){e(this).removeClass("dropup")}),e(document).on("show.bs.tab",function(a){var t=e(a.target);t.exists()&&"A"!==t.get(0).tagName&&(t=e("a[href]",t));var n=t.data();if(n.amsUrl){if(n.amsTabLoaded)return;t.append('<i class="fa fa-spin fa-cog margin-left-5"></i>'),s.skin.loadURL(n.amsUrl,t.attr("href"),{afterLoadCallback:function(){n.amsTabLoadOnce&&t.data("ams-tab-loaded",!0),e("i",t).remove()},afterErrorCallback:function(){e("i",t).remove()}})}}),e(document).on("hide.bs.modal",function(a){var t=e(a.target);s.form.confirmChangedForm(t,function(){return t.data("modal").isShown=!0,!0},function(){return a.preventDefault(),!1})}),e(document).on("myams.refresh",function(e,a){n.executeFunctionByName(a.handler||n.skin.refreshContent,e.target,a)}),s.initContent(document),s.ajaxNav&&i.exists()&&s.skin.checkURL(),s.form.setFocus(document),e(window).on("beforeunload",s.form.checkBeforeUnload)},n.initContent=function(a){e(".tipsy").remove(),e("[rel=tooltip]",a).tooltip(),e("[rel=popover]",a).popover(),e("[rel=popover-hover]",a).popover({trigger:"hover"}),s.plugins.init(a),s.callbacks.init(a),s.events.init(a),s.form.init(a),"desktop"===s.device?s.skin._initDesktopWidgets(a):s.skin._initMobileWidgets(a),s.skin._setPageHeight()},n.i18n={INFO:"Information",WARNING:"!! WARNING !!",ERROR:"ERROR: ",LOADING:"Loading...",PROGRESS:"Processing",WAIT:"Please wait!",FORM_SUBMITTED:"This form was already submitted...",NO_SERVER_RESPONSE:"No response from server!",ERROR_OCCURED:"An error occured!",ERRORS_OCCURED:"Some errors occured!",BAD_LOGIN_TITLE:"Bad login!",BAD_LOGIN_MESSAGE:"Your anthentication credentials didn't allow you to open a session; please check your credentials or contact administrator.",CONFIRM:"Confirm",CONFIRM_REMOVE:"Removing this content can't be undone. Do you confirm?",CLEAR_STORAGE_TITLE:"Clear Local Storage",CLEAR_STORAGE_CONTENT:"Would you like to RESET all your saved widgets and clear LocalStorage?",BTN_OK:"OK",BTN_CANCEL:"Cancel",BTN_OK_CANCEL:"[OK][Cancel]",BTN_YES:"Yes",BTN_NO:"No",BTN_YES_NO:"[Yes][No]",CLIPBOARD_COPY:"Copy to clipboard with Ctrl+C, and Enter",CLIPBOARD_CHARACTER_COPY_OK:"Character copied to clipboard",CLIPBOARD_TEXT_COPY_OK:"Text copied to clipboard",FORM_CHANGED_WARNING:"Some changes were not saved. These updates will be lost if you leave this page.",DELETE_WARNING:"This change can't be undone. Are you sure that you want to delete this element?",NO_UPDATE:"No changes were applied.",DATA_UPDATED:"Data successfully updated.",HOME:"Home",LOGOUT:"Logout?",LOGOUT_COMMENT:"You can improve your security further after logging out by closing this opened browser",SELECT2_PLURAL:"s",SELECT2_MATCH:"One result is available, press enter to select it.",SELECT2_MATCHES:" results are available, use up and down arrow keys to navigate.",SELECT2_NOMATCHES:"No matches found",SELECT2_SEARCHING:"Searching...",SELECT2_LOADMORE:"Loading more results...",SELECT2_INPUT_TOOSHORT:"Please enter {0} more character{1}",SELECT2_INPUT_TOOLONG:"Please delete {0} character{1}",SELECT2_SELECTION_TOOBIG:"You can only select {0} item{1}",SELECT2_FREETAG_PREFIX:"Free text: ",DT_COLUMNS:"Columns"},n.plugins.i18n={widgets:{},validate:{},datatables:{},fancybox:{ERROR:"Can't load requested content.",RETRY:"Please check URL or try again later.",CLOSE:"Close",NEXT:"Next",PREVIOUS:"Previous"},dndupload:{FILES_SELECTED:"{count} files selected",CHOOSE_FILE:"Select file(s)",ADD_INFO:"to add them to current folder,",DRAG_FILE:"or drag and drop them here!",UPLOAD:"Upload",UPLOADING:"Uploading&hellip;",DONE:"Done!",UPLOAD_MORE:"Upload more?",ERROR:"Error!",TRY_AGAIN:"Try again?"}},e(document).ready(function(){var a=(e=jQuery.noConflict())("HTML");a.removeClass("no-js").addClass("js");var t=a.attr("lang")||a.attr("xml:lang");t&&!t.startsWith("en")?(n.lang=t,n.getScript(n.baseURL+"i18n/myams_"+t.substr(0,2)+".js",function(){n.initPage()})):n.initPage()})}(jQuery,this);