1 /**
    2  * Top-level namespace of these objects.
    3  * @namespace
    4  */
    5 var ort;
    6 (function(ort) {
    7 	'use strict';
    8 
    9 	/**
   10 	 * Convenience function to resolve a set of translated strings into a 
   11 	 * single one depending upon the current language.
   12 	 * @param {langmap} vals - All translations of a given word.
   13 	 * @private
   14 	 * @function _strlang
   15 	 * @memberof ort
   16 	 */
   17 	function _strlang(vals)
   18 	{
   19 		var lang;
   20 		lang = document.documentElement.lang;
   21 		if (null !== lang && lang in vals)
   22 			return vals[lang];
   23 		else if ('_default' in vals)
   24 			return vals['_default'];
   25 		else
   26 			return '';
   27 	}
   28 
   29 	/**
   30 	 * Used exclusively by enumerations and bitfields to do language 
   31 	 * replacement conditional upon the label (<i>jslabel</i> in the 
   32 	 * configuration).
   33 	 * Like {@link ort._replcl} with inclusion set to false.
   34 	 * @param {HTMLElement} e - The root of the DOM tree in which we 
   35 	 * query for elements to fill into.
   36 	 * @param {String} name - The class name we search for within the 
   37 	 * root (not inclusive).
   38 	 * @param {langmap} vals - All possible translations.
   39 	 * @private
   40 	 * @function _replcllang
   41 	 * @memberof ort
   42 	 */
   43 	function _replcllang(e, name, vals)
   44 	{
   45 		_replcl(e, name, _strlang(vals), false);
   46 	}
   47 
   48 	/**
   49 	 * Used exclusively by enumerations and bitfields to do language 
   50 	 * replacement conditional upon the label (<i>jslabel</i> in the 
   51 	 * configuration).
   52 	 * Like {@link ort._repl}.
   53 	 * @param {HTMLElement} e - The root of the DOM tree in which we 
   54 	 * query for elements to fill into.
   55 	 * @param {langmap} vals - All possible translations.
   56 	 * @private
   57 	 * @function _repllang
   58 	 * @memberof ort
   59 	 */
   60 	function _repllang(e, vals)
   61 	{
   62 		_repl(e, _strlang(vals));
   63 	}
   64 
   65 	function _attr(e, attr, text)
   66 	{
   67 		if (null !== e)
   68 			e.setAttribute(attr, text);
   69 	}
   70 
   71 	function _rattr(e, attr)
   72 	{
   73 		if (null !== e)
   74 			e.removeAttribute(attr);
   75 	}
   76 
   77 	/**
   78 	 * Internal function for checking inputs for all elements of class 
   79 	 * strct-name-value-checked whose value matches the object's value. 
   80 	 * If the object is null, all elements are unchecked.
   81 	 * @param {HTMLElement} e - The root of the DOM tree in which we 
   82 	 * query for elements to fill into.
   83 	 * @param {String} strct - The name of the structure that we're 
   84 	 * filling in.
   85 	 * @param {String} name - The name of the field.
   86 	 * @param {Number|String|null} obj - The data itself.
   87 	 * @param {Boolean} inc - Whether to include the root element in 
   88 	 * looking for elements to fill.
   89 	 * @private
   90 	 * @function _fillValueChecked
   91 	 * @memberof ort
   92 	 */
   93 	function _fillValueChecked(e, fname, val, inc)
   94 	{
   95 		var list;
   96 		var i;
   97 		var valstr;
   98 		fname += '-value-checked';
   99 		valstr = null === val ? null : 
  100 			("number" === typeof val ? val.toString() : val);
  101 		list = _elemList(e, fname, inc);
  102 		for (i = 0; i < list.length; i++)
  103 			if (valstr === null)
  104 				_rattr(list[i], 'checked');
  105 			else if (valstr === (list[i]).value)
  106 				_attr(list[i], 'checked', 'true');
  107 			else
  108 				_rattr(list[i], 'checked');
  109 	}
  110 
  111 	/**
  112 	 * Internal function that takes all <code>&lt;option&gt;</code> 
  113 	 * elements in the root and sets or unsets their 
  114 	 * <code>selected</code> status depending upon whether it matches the 
  115 	 * object's value.
  116 	 * @param {HTMLElement} e - The root of the DOM tree in which we 
  117 	 * query for elements to fill into.
  118 	 * @param {Number|String} val - The object's value.
  119 	 * @private
  120 	 * @function _fillValueSelect
  121 	 * @memberof ort
  122 	 */
  123 	function _fillValueSelect(e, val)
  124 	{
  125 		var list;
  126 		var i;
  127 		var v;
  128 		if (null === e)
  129 			return;
  130 		list = e.getElementsByTagName('option');
  131 		for (i = 0; i < list.length; i++) {
  132 			v = 'number' === typeof val ? 
  133 			     parseInt((list[i]).value) :
  134 			     (list[i]).value;
  135 			if (val === v)
  136 				_attr(list[i], 'selected', 'true');
  137 			else
  138 				_rattr(list[i], 'selected');
  139 		}
  140 	}
  141 
  142 	function _attrcl(e, attr, name, text, inc)
  143 	{
  144 		var list;
  145 		var i;
  146 		if (null === e)
  147 			return;
  148 		list = _elemList(e, name, inc);
  149 		for (i = 0; i < list.length; i++)
  150 			_attr(list[i], attr, text);
  151 	}
  152 
  153 	function _elemList(e, cls, inc)
  154 	{
  155 		var a;
  156 		var list;
  157 		var i;
  158 		a = [];
  159 		if (null === e)
  160 			return a;
  161 		list = e.getElementsByClassName(cls);
  162 		for (i = 0; i < list.length; i++)
  163 			a.push(list[i]);
  164 		if (inc && e.classList.contains(cls))
  165 			a.push(e);
  166 		return a;
  167 	}
  168 
  169 	function _repl(e, text)
  170 	{
  171 		if (null === e)
  172 			return;
  173 		while (e.firstChild)
  174 			e.removeChild(e.firstChild);
  175 		e.appendChild(document.createTextNode(text));
  176 	}
  177 
  178 	/**
  179 	 * Internal function for filling in ISO-8601 dates.
  180 	 * @param {HTMLElement} e - The root of the DOM tree in which we 
  181 	 * query for elements to fill into.
  182 	 * @param {String} strct - The name of the structure that we're 
  183 	 * filling in.
  184 	 * @param {String} name - The name of the field.
  185 	 * @param {Number|null} obj - The data itself.
  186 	 * @param {Boolean} inc - Whether to include the root element in 
  187 	 * looking for elements to fill.
  188 	 * @private
  189 	 * @function _fillDateValue
  190 	 * @memberof ort
  191 	 */
  192 	function _fillDateValue(e, strct, name, val, inc)
  193 	{
  194 		var fname;
  195 		var year;
  196 		var mo;
  197 		var day;
  198 		var full;
  199 		var d;
  200 		if (null === val)
  201 			return;
  202 		d = new Date();
  203 		d.setTime(val * 1000);
  204 		year = d.getFullYear();
  205 		mo = d.getMonth() + 1;
  206 		day = d.getDate();
  207 		full = year + '-' +
  208 			(mo < 10 ? '0' : '') + mo + '-' +
  209 			(day < 10 ? '0' : '') + day;
  210 		fname = strct + '-' + name + '-date-value';
  211 		_attrcl(e, 'value', fname, full, inc);
  212 		fname = strct + '-' + name + '-date-text';
  213 		_replcl(e, fname, full, inc);
  214 	}
  215 
  216 	/**
  217 	 * Internal function for checking inputs for all elements of class 
  218 	 * strct-name-bits-checked whose value is the bit-wise AND of the 
  219 	 * object's value. If the object is null, all elements are unchecked.
  220 	 * @param {HTMLElement} e - The root of the DOM tree in which we 
  221 	 * query for elements to fill into.
  222 	 * @param {String} strct - The name of the structure that we're 
  223 	 * filling in.
  224 	 * @param {String} name - The name of the field.
  225 	 * @param {Number|null} obj - The data itself.
  226 	 * @param {Boolean} inc - Whether to include the root element in 
  227 	 * looking for elements to fill.
  228 	 * @private
  229 	 * @function _fillBitsChecked
  230 	 * @memberof ort
  231 	 */
  232 	function _fillBitsChecked(e, strct, name, val, inc)
  233 	{
  234 		var list;
  235 		var fname;
  236 		var i;
  237 		var v;
  238 		fname = strct + '-' + name + '-bits-checked';
  239 		list = _elemList(e, fname, inc);
  240 		for (i = 0; i < list.length; i++) {
  241 			if (val === null) {
  242 				_rattr(list[i], 'checked');
  243 				continue;
  244 			}
  245 			v = parseInt((list[i]).value);
  246 			if (isNaN(v))
  247 				_rattr(list[i], 'checked');
  248 			else if (0 === v && 0 === val)
  249 				_attr(list[i], 'checked', 'true');
  250 			else if ((1 << (v - 1)) & val)
  251 				_attr(list[i], 'checked', 'true');
  252 			else
  253 				_rattr(list[i], 'checked');
  254 		}
  255 	}
  256 
  257 	/**
  258 	 * Internal function for filling a structure field.
  259 	 * This first does the has/no class setting for null values, then 
  260 	 * optionally returns if null (running the custom fields first), 
  261 	 * otherwise the generic text/value/etc fields, then finally the 
  262 	 * custom fields.
  263 	 * @param {HTMLElement} e - The root of the DOM tree in which we 
  264 	 * query for elements to fill into.
  265 	 * @param {String} strct - The name of the structure that we're 
  266 	 * filling in.
  267 	 * @param {String} name - The name of the field.
  268 	 * @param {ort.DataCallbacks|null} custom - Custom callback functions 
  269 	 * to invoke on the field.
  270 	 * @param obj - The data itself, which is either a native type or one 
  271 	 * of the data interfaces for an application-specific type.
  272 	 * @param {Boolean} inc - Whether to include the root element in 
  273 	 * looking for elements to fill. Note that nested structures are 
  274 	 * alwyas filled non-inclusively.
  275 	 * @param {Boolean} cannull - Whether the data object might be null.
  276 	 * @param {Boolean} isblob - Whether the data object is a blob.
  277 	 * @param sub - If the data object is a nested structure interface, 
  278 	 * this is the allocated class of that interface.
  279 	 * @private
  280 	 * @function _fillField
  281 	 * @memberof ort
  282 	 */
  283 	function _fillField(e, strct, name, custom, obj, inc, cannull, isblob, sub)
  284 	{
  285 		var i;
  286 		var fname;
  287 		var list;
  288 		fname = strct + '-' + name;
  289 		/* First handle our has/no null situation. */
  290 		if (cannull) {
  291 			if (null === obj) {
  292 				_hidecl(e, strct + '-has-' + name, inc);
  293 				_showcl(e, strct + '-no-' + name, inc);
  294 			} else {
  295 				_showcl(e, strct + '-has-' + name, inc);
  296 				_hidecl(e, strct + '-no-' + name, inc);
  297 			}
  298 		}
  299 		/* Don't process null values that can be null. */
  300 		if (cannull && null === obj) {
  301 			if (null !== custom && fname in custom) {
  302 				if (custom[fname] instanceof Array) {
  303 					for (i = 0; i < custom[fname].length; i++)
  304 						custom[fname][i](e, fname, null);
  305 				} else {
  306 					custom[fname](e, fname, null);
  307 				}
  308 			}
  309 			return;
  310 		}
  311 		/* Non-null non-structs. */
  312 		/* Don't account for blobs. */
  313 		if (null !== sub) {
  314 			list = _elemList(e, fname + '-obj', inc);
  315 			for (i = 0; i < list.length; i++) {
  316 				sub.fillInner(list[i], custom);
  317 			}
  318 		} else if ( ! isblob) {
  319 			list = _elemList(e, fname + '-enum-select', inc);
  320 			for (i = 0; i < list.length; i++) {
  321 				_fillValueSelect(list[i], obj);
  322 			}
  323 			_replcl(e, fname + '-text', obj, inc);
  324 			_attrcl(e, 'value', fname + '-value', obj, inc);
  325 			_fillValueChecked(e, fname, obj, inc);
  326 		}
  327 		/* Lastly, handle the custom callback. */
  328 		if (null !== custom && fname in custom) {
  329 			if (custom[fname] instanceof Array) {
  330 				for (i = 0; i < custom[fname].length; i++)
  331 					custom[fname][i](e, fname, obj);
  332 			} else {
  333 				custom[fname](e, fname, obj);
  334 			}
  335 		}
  336 	}
  337 
  338 	function _replcl(e, name, text, inc)
  339 	{
  340 		var list;
  341 		var i;
  342 		if (null === e)
  343 			return;
  344 		list = _elemList(e, name, inc);
  345 		for (i = 0; i < list.length; i++)
  346 			_repl(list[i], text);
  347 	}
  348 
  349 	function _classadd(e, name)
  350 	{
  351 		if (null === e)
  352 			return(null);
  353 		if ( ! e.classList.contains(name))
  354 			e.classList.add(name);
  355 		return(e);
  356 	}
  357 
  358 	function _classaddcl(e, name, cls, inc)
  359 	{
  360 		var list;
  361 		var i;
  362 		if (null === e)
  363 			return;
  364 		list = _elemList(e, name, inc);
  365 		for (i = 0; i < list.length; i++)
  366 			_classadd(list[i], cls);
  367 	}
  368 
  369 	function _hide(e)
  370 	{
  371 		if (null === e)
  372 			return null;
  373 		if ( ! e.classList.contains('hide'))
  374 			e.classList.add('hide');
  375 		return e;
  376 	}
  377 
  378 	function _hidecl(e, name, inc)
  379 	{
  380 		var list;
  381 		var i;
  382 		if (null === e)
  383 			return;
  384 		list = _elemList(e, name, inc);
  385 		for (i = 0; i < list.length; i++)
  386 			_hide(list[i]);
  387 	}
  388 
  389 	function _show(e)
  390 	{
  391 		if (null === e)
  392 			return null;
  393 		if (e.classList.contains('hide'))
  394 			e.classList.remove('hide');
  395 		return e;
  396 	}
  397 
  398 	function _showcl(e, name, inc)
  399 	{
  400 		var list;
  401 		var i;
  402 		if (null === e)
  403 			return;
  404 		list = _elemList(e, name, inc);
  405 		for (i = 0; i < list.length; i++)
  406 			_show(list[i]);
  407 	}
  408 
  409 	/**
  410 	 * All possible callback functions for passing to the "custom" 
  411 	 * associative array when filling in DOM trees.
  412 	 * @interface ort.DataCallbacks
  413 	 */
  414 	/**
  415 	 * 
  416 	 * Controlling organisation.<br/>
  417 	 * 
  418 	 * @interface ort.companyData
  419 	 */
  420 	/**
  421 	 * 
  422 	 * A regular user.<br/>
  423 	 * 
  424 	 * @interface ort.userData
  425 	 */
  426 	/**
  427 	 * 
  428 	 * Authenticated session.<br/>
  429 	 * 
  430 	 * @interface ort.sessionData
  431 	 */
  432 	/**
  433 	 * Accepts {@link ort.companyData} for writing into a DOM tree.
  434 	 * @param {(ort.companyData|ort.companyData[])} obj - The object(s) 
  435 	 * to write.
  436 	 * @memberof ort
  437 	 * @constructor
  438 	 * @class
  439 	 */
  440 	var company = (function()
  441 	{
  442 		function company(o)
  443 		{
  444 			this.obj = o;
  445 		}
  446 		/**
  447 		 * Write the {@link ort.companyData} into the given HTMLElement 
  448 		 * in the DOM tree.
  449 		 * If constructed with an array, the first element is used.
  450 		 * Elements within (and including) "e" having the following 
  451 		 * classes are manipulated as follows:
  452 		 * <ul>
  453 		 * <li>company-name-enum-select: sets the <code>select</code> 
  454 		 * attribute for <code>&lt;option&gt;</code> values matching 
  455 		 * <i>name</i> under the element</li>
  456 		 * <li>company-name-value-checked: sets the <code>checked</code> 
  457 		 * attribute under the element matching the input</li>
  458 		 * <li>company-name-text: replace contents with <i>name</i> 
  459 		 * data</li>
  460 		 * <li>company-name-value: replace <code>value</code> attribute 
  461 		 * with <i>name</i> data</li>
  462 		 * <li>company-id-enum-select: sets the <code>select</code> 
  463 		 * attribute for <code>&lt;option&gt;</code> values matching 
  464 		 * <i>id</i> under the element</li>
  465 		 * <li>company-id-value-checked: sets the <code>checked</code> 
  466 		 * attribute under the element matching the input</li>
  467 		 * <li>company-id-text: replace contents with <i>id</i> data</li>
  468 		 * <li>company-id-value: replace <code>value</code> attribute 
  469 		 * with <i>id</i> data</li>
  470 		 * <li>company-has-somenum: <code>hide</code> class removed if 
  471 		 * <i>somenum</i> not null, otherwise <code>hide</code> class is 
  472 		 * added</li>
  473 		 * <li>company-no-somenum: <code>hide</code> class added if 
  474 		 * <i>somenum</i> not null, otherwise <code>hide</code> class is 
  475 		 * removed</li>
  476 		 * <li>company-somenum-enum-select: sets the <code>select</code> 
  477 		 * attribute for <code>&lt;option&gt;</code> values matching 
  478 		 * <i>somenum</i> under the element (if non-null)</li>
  479 		 * <li>company-somenum-value-checked: sets the 
  480 		 * <code>checked</code> attribute under the element matching the 
  481 		 * input (if non-null)</li>
  482 		 * <li>company-somenum-text: replace contents with <i>somenum</i> 
  483 		 * data (if non-null)</li>
  484 		 * <li>company-somenum-value: replace <code>value</code> 
  485 		 * attribute with <i>somenum</i> data (if non-null)</li>
  486 		 * </ul>
  487 		 * @param {HTMLElement} e - The DOM element.
  488 		 * @param {ort.DataCallbacks} custom - The optional dictionary of 
  489 		 * functions keyed by structure and field name (e.g., <i>foo</i> 
  490 		 * structure, <i>bar</i> field would be <code>foo-bar</code>). 
  491 		 * The value is a function for custom handling that accepts the 
  492 		 * "e" value, the name of the structure-field, and the value of 
  493 		 * the structure and field.
  494 		 * You may also specify an array of functions instead of a 
  495 		 * singleton.
  496 		 * These callbacks are invoked <b>after</b> the generic classes 
  497 		 * are filled.
  498 		 * @function fill
  499 		 * @memberof ort.company#
  500 		 */
  501 		company.prototype.fill = function(e, custom)
  502 		{
  503 			this._fill(e, this.obj, true, custom);
  504 		};
  505 
  506 		/**
  507 		 * Like {@link ort.company#fill} but instead of accepting a 
  508 		 * single element to fill, filling into all elements 
  509 		 * (non-inclusive) matching the given class name beneath 
  510 		 * (non-inclusive) the given root.
  511 		 * @param {HTMLElement} e - The DOM element.
  512 		 * @param {String} name - The name of the class into which to 
  513 		 * fill.
  514 		 * @param {ort.DataCallbacks} custom - The optional custom 
  515 		 * handler dictionary (see {@link ort.company#fill} for details).
  516 		 * @function fillByClass
  517 		 * @memberof ort.company#
  518 		 */
  519 		company.prototype.fillByClass = function(e, name, custom)
  520 		{
  521 			this._fillByClass(e, name, true, custom);
  522 		};
  523 
  524 		/**
  525 		 * Like {@link ort.company#fillByClass} but inclusive the root 
  526 		 * and targets by class.
  527 		 * @param {HTMLElement} e - The DOM element.
  528 		 * @param {String} name - The name of the class into which to 
  529 		 * fill.
  530 		 * @param {ort.DataCallbacks} custom - The optional custom 
  531 		 * handler dictionary (see {@link ort.company#fill} for details).
  532 		 * @function fillInnerByClass
  533 		 * @memberof ort.company#
  534 		 */
  535 		company.prototype.fillInnerByClass = function(e, name, custom)
  536 		{
  537 			this._fillByClass(e, name, false, custom);
  538 		};
  539 
  540 		/**
  541 		 * Like {@link ort.company#fill} but not including the root 
  542 		 * element "e".
  543 		 * @param {HTMLElement} e - The DOM element.
  544 		 * @param {ort.DataCallbacks} custom - The optional custom 
  545 		 * handler dictionary (see {@link ort.company#fill} for details).
  546 		 * @function fillInner
  547 		 * @memberof ort.company#
  548 		 */
  549 		company.prototype.fillInner = function(e, custom)
  550 		{
  551 			this._fill(e, this.obj, false, custom);
  552 		};
  553 
  554 		/**
  555 		 * Implements all {@link ort.company#fill} functions.
  556 		 * @param {HTMLElement} e - The DOM element.
  557 		 * @param {ort.companyData|ort.companyData[]|null} o - The object 
  558 		 * (or array) to fill.
  559 		 * @param {Boolean} inc - Whether to include the root or not when 
  560 		 * processing.
  561 		 * @param {ort.DataCallbacks} custom - The optional custom 
  562 		 * handler dictionary (see {@link ort.company#fill}).
  563 		 * @private
  564 		 * @function _fill
  565 		 * @memberof ort.company#
  566 		 */
  567 		company.prototype._fill = function(e, o, inc, custom)
  568 		{
  569 			var i;
  570 			if (null === o || null === e)
  571 				return;
  572 			if (o instanceof Array) {
  573 				if (0 === o.length)
  574 					return;
  575 				o = o[0];
  576 			}
  577 			if (typeof custom === 'undefined')
  578 				custom = null;
  579 			_fillField(e, 'company', 'name', custom, o.name, inc, false, false, null);
  580 			_fillField(e, 'company', 'id', custom, o.id, inc, false, false, null);
  581 			_fillField(e, 'company', 'somenum', custom, o.somenum, inc, true, false, null);
  582 			if (null !== custom && 'company' in custom) {
  583 				if (custom['company'] instanceof Array) {
  584 					for (i = 0; i < custom['company'].length; i++)
  585 						(custom['company'])[i](e, 'company', o);
  586 				} else {
  587 					(custom['company'])(e, 'company', o);
  588 				}
  589 			}
  590 		};
  591 
  592 		/**
  593 		 * Like {@link ort.company#_fill} but instead of accepting a 
  594 		 * single element to fill, filling into all elements matching the 
  595 		 * given class name beneath the given root.
  596 		 * @param {HTMLElement} e - The DOM element.
  597 		 * @param {String} name - The name of the class into which to 
  598 		 * fill.
  599 		 * @param {Boolean} inc - Whether to include the roots or not 
  600 		 * when processing.
  601 		 * @param {ort.DataCallbacks} custom - The optional custom 
  602 		 * handler dictionary (see {@link ort.company#fill} for details).
  603 		 * @private
  604 		 * @function _fillByClass
  605 		 * @memberof ort.company#
  606 		 */
  607 		company.prototype._fillByClass = function(e, name, inc, custom)
  608 		{
  609 			var i;
  610 			var list;
  611 			list = _elemList(e, name, inc);
  612 			for (i = 0; i < list.length; i++)
  613 				this._fill(list[i], this.obj, inc, custom);
  614 		};
  615 
  616 		/**
  617 		 * Like {@link ort.company#fillArray}, but hiding an element if 
  618 		 * the array is empty or null.
  619 		 * @param {HTMLElement|null} e - The DOM element.
  620 		 * @param {HTMLElement|null} tohide - The DOM element to hide.
  621 		 * @param {ort.companyData|ort.companyData[]|null} o - The array 
  622 		 * (or object) to fill.
  623 		 * @param {ort.DataCallbacks} custom - The optional custom 
  624 		 * handler dictionary (see {@link ort.company#fill}).
  625 		 * @function fillArrayOrHide
  626 		 * @memberof ort.company#
  627 		 */
  628 		company.prototype.fillArrayOrHide = function(e, tohide, custom)
  629 		{
  630 			var len;
  631 			if (null === this.obj)
  632 				len = 0;
  633 			else if (this.obj instanceof Array)
  634 				len = this.obj.length;
  635 			else
  636 				len = 1;
  637 			if (null !== e)
  638 				_hide(e);
  639 			if (null !== tohide)
  640 				_show(tohide);
  641 			this.fillArray(e, custom);
  642 			if (null !== tohide && 0 === len)
  643 				_hide(tohide);
  644 		};
  645 		/**
  646 		 * Like {@link ort.company#fillArray}, but showing an element if 
  647 		 * the array is empty or null.
  648 		 * @param {HTMLElement|null} e - The DOM element.
  649 		 * @param {HTMLElement|null} toshow - The DOM element to show.
  650 		 * @param {ort.companyData|ort.companyData[]|null} o - The array 
  651 		 * (or object) to fill.
  652 		 * @param {ort.DataCallbacks} custom - The optional custom 
  653 		 * handler dictionary (see {@link ort.company#fill}).
  654 		 * @function fillArrayOrShow
  655 		 * @memberof ort.company#
  656 		 */
  657 		company.prototype.fillArrayOrShow = function(e, toshow, custom)
  658 		{
  659 			var len;
  660 			if (null === this.obj)
  661 				len = 0;
  662 			else if (this.obj instanceof Array)
  663 				len = this.obj.length;
  664 			else
  665 				len = 1;
  666 			if (null !== e)
  667 				_hide(e);
  668 			if (null !== toshow)
  669 				_hide(toshow);
  670 			this.fillArray(e, custom);
  671 			if (null !== toshow && 0 === len)
  672 				_show(toshow);
  673 		};
  674 		/**
  675 		 * Like {@link ort.company#fill} but for an array of {@link 
  676 		 * ort.companyData}.
  677 		 * If the data is not an array, it is remapped as an array of 
  678 		 * one.
  679 		 * This will save the first element within "e", remove all 
  680 		 * children of "e", then repeatedly clone the saved element and 
  681 		 * re-append it, filling in the cloned subtree with the array 
  682 		 * (inclusive of the subtree root).
  683 		 * If the input array is empty or null, "e" is hidden by using 
  684 		 * the <code>hide</code> class.
  685 		 * Otherwise, the <code>hide</code> class is removed.
  686 		 * @param {HTMLElement} e - The DOM element.
  687 		 * @param {ort.DataCallbacks} custom - The optional custom 
  688 		 * handler dictionary (see {@link ort.company#fill}).
  689 		 * @memberof ort.company#
  690 		 * @function fillArray
  691 		 */
  692 		company.prototype.fillArray = function(e, custom)
  693 		{
  694 			var j;
  695 			var o;
  696 			var cln;
  697 			var ar;
  698 			var row;
  699 			o = this.obj;
  700 			if (null !== e)
  701 				_hide(e);
  702 			if (null === o || null === e)
  703 				return;
  704 			if ( ! (o instanceof Array)) {
  705 				ar = [];
  706 				ar.push(o);
  707 				o = ar;
  708 			}
  709 			if (0 === o.length)
  710 				return;
  711 			_show(e);
  712 			row = e.children[0];
  713 			if (null === row)
  714 				return;
  715 			e.removeChild(row);
  716 			while (null !== e.firstChild)
  717 				e.removeChild(e.firstChild)
  718 			for (j = 0; j < o.length; j++) {
  719 				cln = row.cloneNode(true);
  720 				e.appendChild(cln);
  721 				this._fill(cln, o[j], true, custom);
  722 			}
  723 		};
  724 		/**
  725 		 * Like {@link ort.company#fillArray} but instead of accepting a 
  726 		 * single element to fill, filling all elements by class name 
  727 		 * beneath the given root (non-inclusive).
  728 		 * @param {HTMLElement} e - The DOM element.
  729 		 * @param {String} name - The name of the class into which to 
  730 		 * fill.
  731 		 * @param {ort.DataCallbacks} custom - The optional custom 
  732 		 * handler dictionary (see {@link ort.company#fill} for details).
  733 		 * @function fillArrayByClass
  734 		 * @memberof ort.company#
  735 		 */
  736 		company.prototype.fillArrayByClass = function(e, name, custom)
  737 		{
  738 			var i;
  739 			var list;
  740 			list = _elemList(e, name, false);
  741 			for (i = 0; i < list.length; i++)
  742 				this.fillArray(list[i], custom);
  743 		};
  744 
  745 		return company;
  746 	}());
  747 	ort.company = company;
  748 
  749 	/**
  750 	 * Accepts {@link ort.userData} for writing into a DOM tree.
  751 	 * @param {(ort.userData|ort.userData[])} obj - The object(s) to 
  752 	 * write.
  753 	 * @memberof ort
  754 	 * @constructor
  755 	 * @class
  756 	 */
  757 	var user = (function()
  758 	{
  759 		function user(o)
  760 		{
  761 			this.obj = o;
  762 		}
  763 		/**
  764 		 * Write the {@link ort.userData} into the given HTMLElement in 
  765 		 * the DOM tree.
  766 		 * If constructed with an array, the first element is used.
  767 		 * Elements within (and including) "e" having the following 
  768 		 * classes are manipulated as follows:
  769 		 * <ul>
  770 		 * <li>user-company-obj: invoke {@link ort.company#fillInner} 
  771 		 * with company data</li>
  772 		 * <li>user-cid-enum-select: sets the <code>select</code> 
  773 		 * attribute for <code>&lt;option&gt;</code> values matching 
  774 		 * <i>cid</i> under the element</li>
  775 		 * <li>user-cid-value-checked: sets the <code>checked</code> 
  776 		 * attribute under the element matching the input</li>
  777 		 * <li>user-cid-text: replace contents with <i>cid</i> data</li>
  778 		 * <li>user-cid-value: replace <code>value</code> attribute with 
  779 		 * <i>cid</i> data</li>
  780 		 * <li>user-sex-enum-select: sets the <code>select</code> 
  781 		 * attribute for <code>&lt;option&gt;</code> values matching 
  782 		 * <i>sex</i> under the element</li>
  783 		 * <li>user-sex-value-checked: sets the <code>checked</code> 
  784 		 * attribute under the element matching the input</li>
  785 		 * <li>user-sex-text: replace contents with <i>sex</i> data</li>
  786 		 * <li>user-sex-value: replace <code>value</code> attribute with 
  787 		 * <i>sex</i> data</li>
  788 		 * <li>user-hash-enum-select: sets the <code>select</code> 
  789 		 * attribute for <code>&lt;option&gt;</code> values matching 
  790 		 * <i>hash</i> under the element</li>
  791 		 * <li>user-hash-value-checked: sets the <code>checked</code> 
  792 		 * attribute under the element matching the input</li>
  793 		 * <li>user-hash-text: replace contents with <i>hash</i> 
  794 		 * data</li>
  795 		 * <li>user-hash-value: replace <code>value</code> attribute with 
  796 		 * <i>hash</i> data</li>
  797 		 * <li>user-email-enum-select: sets the <code>select</code> 
  798 		 * attribute for <code>&lt;option&gt;</code> values matching 
  799 		 * <i>email</i> under the element</li>
  800 		 * <li>user-email-value-checked: sets the <code>checked</code> 
  801 		 * attribute under the element matching the input</li>
  802 		 * <li>user-email-text: replace contents with <i>email</i> 
  803 		 * data</li>
  804 		 * <li>user-email-value: replace <code>value</code> attribute 
  805 		 * with <i>email</i> data</li>
  806 		 * <li>user-name-enum-select: sets the <code>select</code> 
  807 		 * attribute for <code>&lt;option&gt;</code> values matching 
  808 		 * <i>name</i> under the element</li>
  809 		 * <li>user-name-value-checked: sets the <code>checked</code> 
  810 		 * attribute under the element matching the input</li>
  811 		 * <li>user-name-text: replace contents with <i>name</i> 
  812 		 * data</li>
  813 		 * <li>user-name-value: replace <code>value</code> attribute with 
  814 		 * <i>name</i> data</li>
  815 		 * <li>user-uid-enum-select: sets the <code>select</code> 
  816 		 * attribute for <code>&lt;option&gt;</code> values matching 
  817 		 * <i>uid</i> under the element</li>
  818 		 * <li>user-uid-value-checked: sets the <code>checked</code> 
  819 		 * attribute under the element matching the input</li>
  820 		 * <li>user-uid-text: replace contents with <i>uid</i> data</li>
  821 		 * <li>user-uid-value: replace <code>value</code> attribute with 
  822 		 * <i>uid</i> data</li>
  823 		 * </ul>
  824 		 * @param {HTMLElement} e - The DOM element.
  825 		 * @param {ort.DataCallbacks} custom - The optional dictionary of 
  826 		 * functions keyed by structure and field name (e.g., <i>foo</i> 
  827 		 * structure, <i>bar</i> field would be <code>foo-bar</code>). 
  828 		 * The value is a function for custom handling that accepts the 
  829 		 * "e" value, the name of the structure-field, and the value of 
  830 		 * the structure and field.
  831 		 * You may also specify an array of functions instead of a 
  832 		 * singleton.
  833 		 * These callbacks are invoked <b>after</b> the generic classes 
  834 		 * are filled.
  835 		 * @function fill
  836 		 * @memberof ort.user#
  837 		 */
  838 		user.prototype.fill = function(e, custom)
  839 		{
  840 			this._fill(e, this.obj, true, custom);
  841 		};
  842 
  843 		/**
  844 		 * Like {@link ort.user#fill} but instead of accepting a single 
  845 		 * element to fill, filling into all elements (non-inclusive) 
  846 		 * matching the given class name beneath (non-inclusive) the 
  847 		 * given root.
  848 		 * @param {HTMLElement} e - The DOM element.
  849 		 * @param {String} name - The name of the class into which to 
  850 		 * fill.
  851 		 * @param {ort.DataCallbacks} custom - The optional custom 
  852 		 * handler dictionary (see {@link ort.user#fill} for details).
  853 		 * @function fillByClass
  854 		 * @memberof ort.user#
  855 		 */
  856 		user.prototype.fillByClass = function(e, name, custom)
  857 		{
  858 			this._fillByClass(e, name, true, custom);
  859 		};
  860 
  861 		/**
  862 		 * Like {@link ort.user#fillByClass} but inclusive the root and 
  863 		 * targets by class.
  864 		 * @param {HTMLElement} e - The DOM element.
  865 		 * @param {String} name - The name of the class into which to 
  866 		 * fill.
  867 		 * @param {ort.DataCallbacks} custom - The optional custom 
  868 		 * handler dictionary (see {@link ort.user#fill} for details).
  869 		 * @function fillInnerByClass
  870 		 * @memberof ort.user#
  871 		 */
  872 		user.prototype.fillInnerByClass = function(e, name, custom)
  873 		{
  874 			this._fillByClass(e, name, false, custom);
  875 		};
  876 
  877 		/**
  878 		 * Like {@link ort.user#fill} but not including the root element 
  879 		 * "e".
  880 		 * @param {HTMLElement} e - The DOM element.
  881 		 * @param {ort.DataCallbacks} custom - The optional custom 
  882 		 * handler dictionary (see {@link ort.user#fill} for details).
  883 		 * @function fillInner
  884 		 * @memberof ort.user#
  885 		 */
  886 		user.prototype.fillInner = function(e, custom)
  887 		{
  888 			this._fill(e, this.obj, false, custom);
  889 		};
  890 
  891 		/**
  892 		 * Implements all {@link ort.user#fill} functions.
  893 		 * @param {HTMLElement} e - The DOM element.
  894 		 * @param {ort.userData|ort.userData[]|null} o - The object (or 
  895 		 * array) to fill.
  896 		 * @param {Boolean} inc - Whether to include the root or not when 
  897 		 * processing.
  898 		 * @param {ort.DataCallbacks} custom - The optional custom 
  899 		 * handler dictionary (see {@link ort.user#fill}).
  900 		 * @private
  901 		 * @function _fill
  902 		 * @memberof ort.user#
  903 		 */
  904 		user.prototype._fill = function(e, o, inc, custom)
  905 		{
  906 			var i;
  907 			if (null === o || null === e)
  908 				return;
  909 			if (o instanceof Array) {
  910 				if (0 === o.length)
  911 					return;
  912 				o = o[0];
  913 			}
  914 			if (typeof custom === 'undefined')
  915 				custom = null;
  916 			_fillField(e, 'user', 'company', custom, o.company, inc, false, false, new company(o.company));
  917 			_fillField(e, 'user', 'cid', custom, o.cid, inc, false, false, null);
  918 			_fillField(e, 'user', 'sex', custom, o.sex, inc, false, false, null);
  919 			_fillField(e, 'user', 'hash', custom, o.hash, inc, false, false, null);
  920 			_fillField(e, 'user', 'email', custom, o.email, inc, false, false, null);
  921 			_fillField(e, 'user', 'name', custom, o.name, inc, false, false, null);
  922 			_fillField(e, 'user', 'uid', custom, o.uid, inc, false, false, null);
  923 			if (null !== custom && 'user' in custom) {
  924 				if (custom['user'] instanceof Array) {
  925 					for (i = 0; i < custom['user'].length; i++)
  926 						(custom['user'])[i](e, 'user', o);
  927 				} else {
  928 					(custom['user'])(e, 'user', o);
  929 				}
  930 			}
  931 		};
  932 
  933 		/**
  934 		 * Like {@link ort.user#_fill} but instead of accepting a single 
  935 		 * element to fill, filling into all elements matching the given 
  936 		 * class name beneath the given root.
  937 		 * @param {HTMLElement} e - The DOM element.
  938 		 * @param {String} name - The name of the class into which to 
  939 		 * fill.
  940 		 * @param {Boolean} inc - Whether to include the roots or not 
  941 		 * when processing.
  942 		 * @param {ort.DataCallbacks} custom - The optional custom 
  943 		 * handler dictionary (see {@link ort.user#fill} for details).
  944 		 * @private
  945 		 * @function _fillByClass
  946 		 * @memberof ort.user#
  947 		 */
  948 		user.prototype._fillByClass = function(e, name, inc, custom)
  949 		{
  950 			var i;
  951 			var list;
  952 			list = _elemList(e, name, inc);
  953 			for (i = 0; i < list.length; i++)
  954 				this._fill(list[i], this.obj, inc, custom);
  955 		};
  956 
  957 		/**
  958 		 * Like {@link ort.user#fillArray}, but hiding an element if the 
  959 		 * array is empty or null.
  960 		 * @param {HTMLElement|null} e - The DOM element.
  961 		 * @param {HTMLElement|null} tohide - The DOM element to hide.
  962 		 * @param {ort.userData|ort.userData[]|null} o - The array (or 
  963 		 * object) to fill.
  964 		 * @param {ort.DataCallbacks} custom - The optional custom 
  965 		 * handler dictionary (see {@link ort.user#fill}).
  966 		 * @function fillArrayOrHide
  967 		 * @memberof ort.user#
  968 		 */
  969 		user.prototype.fillArrayOrHide = function(e, tohide, custom)
  970 		{
  971 			var len;
  972 			if (null === this.obj)
  973 				len = 0;
  974 			else if (this.obj instanceof Array)
  975 				len = this.obj.length;
  976 			else
  977 				len = 1;
  978 			if (null !== e)
  979 				_hide(e);
  980 			if (null !== tohide)
  981 				_show(tohide);
  982 			this.fillArray(e, custom);
  983 			if (null !== tohide && 0 === len)
  984 				_hide(tohide);
  985 		};
  986 		/**
  987 		 * Like {@link ort.user#fillArray}, but showing an element if the 
  988 		 * array is empty or null.
  989 		 * @param {HTMLElement|null} e - The DOM element.
  990 		 * @param {HTMLElement|null} toshow - The DOM element to show.
  991 		 * @param {ort.userData|ort.userData[]|null} o - The array (or 
  992 		 * object) to fill.
  993 		 * @param {ort.DataCallbacks} custom - The optional custom 
  994 		 * handler dictionary (see {@link ort.user#fill}).
  995 		 * @function fillArrayOrShow
  996 		 * @memberof ort.user#
  997 		 */
  998 		user.prototype.fillArrayOrShow = function(e, toshow, custom)
  999 		{
 1000 			var len;
 1001 			if (null === this.obj)
 1002 				len = 0;
 1003 			else if (this.obj instanceof Array)
 1004 				len = this.obj.length;
 1005 			else
 1006 				len = 1;
 1007 			if (null !== e)
 1008 				_hide(e);
 1009 			if (null !== toshow)
 1010 				_hide(toshow);
 1011 			this.fillArray(e, custom);
 1012 			if (null !== toshow && 0 === len)
 1013 				_show(toshow);
 1014 		};
 1015 		/**
 1016 		 * Like {@link ort.user#fill} but for an array of {@link 
 1017 		 * ort.userData}.
 1018 		 * If the data is not an array, it is remapped as an array of 
 1019 		 * one.
 1020 		 * This will save the first element within "e", remove all 
 1021 		 * children of "e", then repeatedly clone the saved element and 
 1022 		 * re-append it, filling in the cloned subtree with the array 
 1023 		 * (inclusive of the subtree root).
 1024 		 * If the input array is empty or null, "e" is hidden by using 
 1025 		 * the <code>hide</code> class.
 1026 		 * Otherwise, the <code>hide</code> class is removed.
 1027 		 * @param {HTMLElement} e - The DOM element.
 1028 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1029 		 * handler dictionary (see {@link ort.user#fill}).
 1030 		 * @memberof ort.user#
 1031 		 * @function fillArray
 1032 		 */
 1033 		user.prototype.fillArray = function(e, custom)
 1034 		{
 1035 			var j;
 1036 			var o;
 1037 			var cln;
 1038 			var ar;
 1039 			var row;
 1040 			o = this.obj;
 1041 			if (null !== e)
 1042 				_hide(e);
 1043 			if (null === o || null === e)
 1044 				return;
 1045 			if ( ! (o instanceof Array)) {
 1046 				ar = [];
 1047 				ar.push(o);
 1048 				o = ar;
 1049 			}
 1050 			if (0 === o.length)
 1051 				return;
 1052 			_show(e);
 1053 			row = e.children[0];
 1054 			if (null === row)
 1055 				return;
 1056 			e.removeChild(row);
 1057 			while (null !== e.firstChild)
 1058 				e.removeChild(e.firstChild)
 1059 			for (j = 0; j < o.length; j++) {
 1060 				cln = row.cloneNode(true);
 1061 				e.appendChild(cln);
 1062 				this._fill(cln, o[j], true, custom);
 1063 			}
 1064 		};
 1065 		/**
 1066 		 * Like {@link ort.user#fillArray} but instead of accepting a 
 1067 		 * single element to fill, filling all elements by class name 
 1068 		 * beneath the given root (non-inclusive).
 1069 		 * @param {HTMLElement} e - The DOM element.
 1070 		 * @param {String} name - The name of the class into which to 
 1071 		 * fill.
 1072 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1073 		 * handler dictionary (see {@link ort.user#fill} for details).
 1074 		 * @function fillArrayByClass
 1075 		 * @memberof ort.user#
 1076 		 */
 1077 		user.prototype.fillArrayByClass = function(e, name, custom)
 1078 		{
 1079 			var i;
 1080 			var list;
 1081 			list = _elemList(e, name, false);
 1082 			for (i = 0; i < list.length; i++)
 1083 				this.fillArray(list[i], custom);
 1084 		};
 1085 
 1086 		return user;
 1087 	}());
 1088 	ort.user = user;
 1089 
 1090 	/**
 1091 	 * Accepts {@link ort.sessionData} for writing into a DOM tree.
 1092 	 * @param {(ort.sessionData|ort.sessionData[])} obj - The object(s) 
 1093 	 * to write.
 1094 	 * @memberof ort
 1095 	 * @constructor
 1096 	 * @class
 1097 	 */
 1098 	var session = (function()
 1099 	{
 1100 		function session(o)
 1101 		{
 1102 			this.obj = o;
 1103 		}
 1104 		/**
 1105 		 * Write the {@link ort.sessionData} into the given HTMLElement 
 1106 		 * in the DOM tree.
 1107 		 * If constructed with an array, the first element is used.
 1108 		 * Elements within (and including) "e" having the following 
 1109 		 * classes are manipulated as follows:
 1110 		 * <ul>
 1111 		 * <li>session-user-obj: invoke {@link ort.user#fillInner} with 
 1112 		 * user data</li>
 1113 		 * <li>session-userid-enum-select: sets the <code>select</code> 
 1114 		 * attribute for <code>&lt;option&gt;</code> values matching 
 1115 		 * <i>userid</i> under the element</li>
 1116 		 * <li>session-userid-value-checked: sets the 
 1117 		 * <code>checked</code> attribute under the element matching the 
 1118 		 * input</li>
 1119 		 * <li>session-userid-text: replace contents with <i>userid</i> 
 1120 		 * data</li>
 1121 		 * <li>session-userid-value: replace <code>value</code> attribute 
 1122 		 * with <i>userid</i> data</li>
 1123 		 * <li>session-token-enum-select: sets the <code>select</code> 
 1124 		 * attribute for <code>&lt;option&gt;</code> values matching 
 1125 		 * <i>token</i> under the element</li>
 1126 		 * <li>session-token-value-checked: sets the <code>checked</code> 
 1127 		 * attribute under the element matching the input</li>
 1128 		 * <li>session-token-text: replace contents with <i>token</i> 
 1129 		 * data</li>
 1130 		 * <li>session-token-value: replace <code>value</code> attribute 
 1131 		 * with <i>token</i> data</li>
 1132 		 * <li>session-mtime-enum-select: sets the <code>select</code> 
 1133 		 * attribute for <code>&lt;option&gt;</code> values matching 
 1134 		 * <i>mtime</i> under the element</li>
 1135 		 * <li>session-mtime-value-checked: sets the <code>checked</code> 
 1136 		 * attribute under the element matching the input</li>
 1137 		 * <li>session-mtime-text: replace contents with <i>mtime</i> 
 1138 		 * data</li>
 1139 		 * <li>session-mtime-value: replace <code>value</code> attribute 
 1140 		 * with <i>mtime</i> data</li>
 1141 		 * <li>session-mtime-date-value: set the element's 
 1142 		 * <code>value</code> to the ISO-8601 date format of the 
 1143 		 * data</li>
 1144 		 * <li>session-mtime-date-text: like session-mtime-date-value, 
 1145 		 * but replacing contents
 1146 		 * <li>session-id-enum-select: sets the <code>select</code> 
 1147 		 * attribute for <code>&lt;option&gt;</code> values matching 
 1148 		 * <i>id</i> under the element</li>
 1149 		 * <li>session-id-value-checked: sets the <code>checked</code> 
 1150 		 * attribute under the element matching the input</li>
 1151 		 * <li>session-id-text: replace contents with <i>id</i> data</li>
 1152 		 * <li>session-id-value: replace <code>value</code> attribute 
 1153 		 * with <i>id</i> data</li>
 1154 		 * </ul>
 1155 		 * @param {HTMLElement} e - The DOM element.
 1156 		 * @param {ort.DataCallbacks} custom - The optional dictionary of 
 1157 		 * functions keyed by structure and field name (e.g., <i>foo</i> 
 1158 		 * structure, <i>bar</i> field would be <code>foo-bar</code>). 
 1159 		 * The value is a function for custom handling that accepts the 
 1160 		 * "e" value, the name of the structure-field, and the value of 
 1161 		 * the structure and field.
 1162 		 * You may also specify an array of functions instead of a 
 1163 		 * singleton.
 1164 		 * These callbacks are invoked <b>after</b> the generic classes 
 1165 		 * are filled.
 1166 		 * @function fill
 1167 		 * @memberof ort.session#
 1168 		 */
 1169 		session.prototype.fill = function(e, custom)
 1170 		{
 1171 			this._fill(e, this.obj, true, custom);
 1172 		};
 1173 
 1174 		/**
 1175 		 * Like {@link ort.session#fill} but instead of accepting a 
 1176 		 * single element to fill, filling into all elements 
 1177 		 * (non-inclusive) matching the given class name beneath 
 1178 		 * (non-inclusive) the given root.
 1179 		 * @param {HTMLElement} e - The DOM element.
 1180 		 * @param {String} name - The name of the class into which to 
 1181 		 * fill.
 1182 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1183 		 * handler dictionary (see {@link ort.session#fill} for details).
 1184 		 * @function fillByClass
 1185 		 * @memberof ort.session#
 1186 		 */
 1187 		session.prototype.fillByClass = function(e, name, custom)
 1188 		{
 1189 			this._fillByClass(e, name, true, custom);
 1190 		};
 1191 
 1192 		/**
 1193 		 * Like {@link ort.session#fillByClass} but inclusive the root 
 1194 		 * and targets by class.
 1195 		 * @param {HTMLElement} e - The DOM element.
 1196 		 * @param {String} name - The name of the class into which to 
 1197 		 * fill.
 1198 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1199 		 * handler dictionary (see {@link ort.session#fill} for details).
 1200 		 * @function fillInnerByClass
 1201 		 * @memberof ort.session#
 1202 		 */
 1203 		session.prototype.fillInnerByClass = function(e, name, custom)
 1204 		{
 1205 			this._fillByClass(e, name, false, custom);
 1206 		};
 1207 
 1208 		/**
 1209 		 * Like {@link ort.session#fill} but not including the root 
 1210 		 * element "e".
 1211 		 * @param {HTMLElement} e - The DOM element.
 1212 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1213 		 * handler dictionary (see {@link ort.session#fill} for details).
 1214 		 * @function fillInner
 1215 		 * @memberof ort.session#
 1216 		 */
 1217 		session.prototype.fillInner = function(e, custom)
 1218 		{
 1219 			this._fill(e, this.obj, false, custom);
 1220 		};
 1221 
 1222 		/**
 1223 		 * Implements all {@link ort.session#fill} functions.
 1224 		 * @param {HTMLElement} e - The DOM element.
 1225 		 * @param {ort.sessionData|ort.sessionData[]|null} o - The object 
 1226 		 * (or array) to fill.
 1227 		 * @param {Boolean} inc - Whether to include the root or not when 
 1228 		 * processing.
 1229 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1230 		 * handler dictionary (see {@link ort.session#fill}).
 1231 		 * @private
 1232 		 * @function _fill
 1233 		 * @memberof ort.session#
 1234 		 */
 1235 		session.prototype._fill = function(e, o, inc, custom)
 1236 		{
 1237 			var i;
 1238 			if (null === o || null === e)
 1239 				return;
 1240 			if (o instanceof Array) {
 1241 				if (0 === o.length)
 1242 					return;
 1243 				o = o[0];
 1244 			}
 1245 			if (typeof custom === 'undefined')
 1246 				custom = null;
 1247 			_fillField(e, 'session', 'user', custom, o.user, inc, false, false, new user(o.user));
 1248 			_fillField(e, 'session', 'userid', custom, o.userid, inc, false, false, null);
 1249 			_fillField(e, 'session', 'token', custom, o.token, inc, false, false, null);
 1250 			_fillField(e, 'session', 'mtime', custom, o.mtime, inc, false, false, null);
 1251 			_fillDateValue(e, 'session', 'mtime', o.mtime, inc);
 1252 			_fillField(e, 'session', 'id', custom, o.id, inc, false, false, null);
 1253 			if (null !== custom && 'session' in custom) {
 1254 				if (custom['session'] instanceof Array) {
 1255 					for (i = 0; i < custom['session'].length; i++)
 1256 						(custom['session'])[i](e, 'session', o);
 1257 				} else {
 1258 					(custom['session'])(e, 'session', o);
 1259 				}
 1260 			}
 1261 		};
 1262 
 1263 		/**
 1264 		 * Like {@link ort.session#_fill} but instead of accepting a 
 1265 		 * single element to fill, filling into all elements matching the 
 1266 		 * given class name beneath the given root.
 1267 		 * @param {HTMLElement} e - The DOM element.
 1268 		 * @param {String} name - The name of the class into which to 
 1269 		 * fill.
 1270 		 * @param {Boolean} inc - Whether to include the roots or not 
 1271 		 * when processing.
 1272 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1273 		 * handler dictionary (see {@link ort.session#fill} for details).
 1274 		 * @private
 1275 		 * @function _fillByClass
 1276 		 * @memberof ort.session#
 1277 		 */
 1278 		session.prototype._fillByClass = function(e, name, inc, custom)
 1279 		{
 1280 			var i;
 1281 			var list;
 1282 			list = _elemList(e, name, inc);
 1283 			for (i = 0; i < list.length; i++)
 1284 				this._fill(list[i], this.obj, inc, custom);
 1285 		};
 1286 
 1287 		/**
 1288 		 * Like {@link ort.session#fillArray}, but hiding an element if 
 1289 		 * the array is empty or null.
 1290 		 * @param {HTMLElement|null} e - The DOM element.
 1291 		 * @param {HTMLElement|null} tohide - The DOM element to hide.
 1292 		 * @param {ort.sessionData|ort.sessionData[]|null} o - The array 
 1293 		 * (or object) to fill.
 1294 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1295 		 * handler dictionary (see {@link ort.session#fill}).
 1296 		 * @function fillArrayOrHide
 1297 		 * @memberof ort.session#
 1298 		 */
 1299 		session.prototype.fillArrayOrHide = function(e, tohide, custom)
 1300 		{
 1301 			var len;
 1302 			if (null === this.obj)
 1303 				len = 0;
 1304 			else if (this.obj instanceof Array)
 1305 				len = this.obj.length;
 1306 			else
 1307 				len = 1;
 1308 			if (null !== e)
 1309 				_hide(e);
 1310 			if (null !== tohide)
 1311 				_show(tohide);
 1312 			this.fillArray(e, custom);
 1313 			if (null !== tohide && 0 === len)
 1314 				_hide(tohide);
 1315 		};
 1316 		/**
 1317 		 * Like {@link ort.session#fillArray}, but showing an element if 
 1318 		 * the array is empty or null.
 1319 		 * @param {HTMLElement|null} e - The DOM element.
 1320 		 * @param {HTMLElement|null} toshow - The DOM element to show.
 1321 		 * @param {ort.sessionData|ort.sessionData[]|null} o - The array 
 1322 		 * (or object) to fill.
 1323 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1324 		 * handler dictionary (see {@link ort.session#fill}).
 1325 		 * @function fillArrayOrShow
 1326 		 * @memberof ort.session#
 1327 		 */
 1328 		session.prototype.fillArrayOrShow = function(e, toshow, custom)
 1329 		{
 1330 			var len;
 1331 			if (null === this.obj)
 1332 				len = 0;
 1333 			else if (this.obj instanceof Array)
 1334 				len = this.obj.length;
 1335 			else
 1336 				len = 1;
 1337 			if (null !== e)
 1338 				_hide(e);
 1339 			if (null !== toshow)
 1340 				_hide(toshow);
 1341 			this.fillArray(e, custom);
 1342 			if (null !== toshow && 0 === len)
 1343 				_show(toshow);
 1344 		};
 1345 		/**
 1346 		 * Like {@link ort.session#fill} but for an array of {@link 
 1347 		 * ort.sessionData}.
 1348 		 * If the data is not an array, it is remapped as an array of 
 1349 		 * one.
 1350 		 * This will save the first element within "e", remove all 
 1351 		 * children of "e", then repeatedly clone the saved element and 
 1352 		 * re-append it, filling in the cloned subtree with the array 
 1353 		 * (inclusive of the subtree root).
 1354 		 * If the input array is empty or null, "e" is hidden by using 
 1355 		 * the <code>hide</code> class.
 1356 		 * Otherwise, the <code>hide</code> class is removed.
 1357 		 * @param {HTMLElement} e - The DOM element.
 1358 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1359 		 * handler dictionary (see {@link ort.session#fill}).
 1360 		 * @memberof ort.session#
 1361 		 * @function fillArray
 1362 		 */
 1363 		session.prototype.fillArray = function(e, custom)
 1364 		{
 1365 			var j;
 1366 			var o;
 1367 			var cln;
 1368 			var ar;
 1369 			var row;
 1370 			o = this.obj;
 1371 			if (null !== e)
 1372 				_hide(e);
 1373 			if (null === o || null === e)
 1374 				return;
 1375 			if ( ! (o instanceof Array)) {
 1376 				ar = [];
 1377 				ar.push(o);
 1378 				o = ar;
 1379 			}
 1380 			if (0 === o.length)
 1381 				return;
 1382 			_show(e);
 1383 			row = e.children[0];
 1384 			if (null === row)
 1385 				return;
 1386 			e.removeChild(row);
 1387 			while (null !== e.firstChild)
 1388 				e.removeChild(e.firstChild)
 1389 			for (j = 0; j < o.length; j++) {
 1390 				cln = row.cloneNode(true);
 1391 				e.appendChild(cln);
 1392 				this._fill(cln, o[j], true, custom);
 1393 			}
 1394 		};
 1395 		/**
 1396 		 * Like {@link ort.session#fillArray} but instead of accepting a 
 1397 		 * single element to fill, filling all elements by class name 
 1398 		 * beneath the given root (non-inclusive).
 1399 		 * @param {HTMLElement} e - The DOM element.
 1400 		 * @param {String} name - The name of the class into which to 
 1401 		 * fill.
 1402 		 * @param {ort.DataCallbacks} custom - The optional custom 
 1403 		 * handler dictionary (see {@link ort.session#fill} for details).
 1404 		 * @function fillArrayByClass
 1405 		 * @memberof ort.session#
 1406 		 */
 1407 		session.prototype.fillArrayByClass = function(e, name, custom)
 1408 		{
 1409 			var i;
 1410 			var list;
 1411 			list = _elemList(e, name, false);
 1412 			for (i = 0; i < list.length; i++)
 1413 				this.fillArray(list[i], custom);
 1414 		};
 1415 
 1416 		return session;
 1417 	}());
 1418 	ort.session = session;
 1419 
 1420 	/**
 1421 	 * Birthsex of individual<br/>
 1422 	 * This object consists of all values for the <i>sex</i> enumeration.
 1423 	 * It also contains a formatting function designed to work as a 
 1424 	 * custom callback for <code>fill</code> functions.
 1425 	 * All of these values are static: <strong>do not use the 
 1426 	 * constructor</strong>.
 1427 	 * @memberof ort
 1428 	 * @class
 1429 	 */
 1430 	var sex = (function()
 1431 	{
 1432 		function sex() { }
 1433 		/**
 1434 		 * Male<br/>
 1435 		 * @memberof ort.sex#
 1436 		 * @readonly
 1437 		 * @const {number} male
 1438 		 */
 1439 		sex.male = 0;
 1440 		/**
 1441 		 * Female<br/>
 1442 		 * @memberof ort.sex#
 1443 		 * @readonly
 1444 		 * @const {number} female
 1445 		 */
 1446 		sex.female = 1;
 1447 		/**
 1448 		 * Other<br/>
 1449 		 * @memberof ort.sex#
 1450 		 * @readonly
 1451 		 * @const {number} other
 1452 		 */
 1453 		sex.other = 2;
 1454 		/**
 1455 		 * Uses the enumeration item's <i>jslabel</i> (or just the name, 
 1456 		 * if no <i>jslabel</i> is defined) to format a custom label as 
 1457 		 * invoked on an object's <code>fill</code> function. This will 
 1458 		 * act on <code>xxx-yyy-label</code> classes, where 
 1459 		 * <code>xxx</code> is the structure name and <code>yyy</code> is 
 1460 		 * the field name. For example, <code>xxx.fill(e, { 'xxx-yyy': 
 1461 		 * ort.sex.format });</code>, where <code>yyy</code> is a field 
 1462 		 * of type <i>enum sex</i>.
 1463 		 * @static
 1464 		 * @function format
 1465 		 * @param {HTMLElement} e - The DOM element.
 1466 		 * @param {String|null} name - If non-null, data is written to 
 1467 		 * elements under the root with the given class name. Otherwise, 
 1468 		 * data is written directly into the DOM element.
 1469 		 * @param {Number} v - The enumeration value.
 1470 		 * @memberof ort.sex#
 1471 		 */
 1472 		sex.format = function(e, name, v)
 1473 		{
 1474 			var s;
 1475 			if (name !== null)
 1476 				name += '-label';
 1477 			if (v === null && name !== null) {
 1478 				_replcl(e, name, 'not given', false);
 1479 				_classaddcl(e, name, 'noanswer', false);
 1480 				return;
 1481 			} else if (v === null) {
 1482 				_repl(e, 'not given');
 1483 				_classadd(e, 'noanswer');
 1484 				return;
 1485 			}
 1486 			switch(v) {
 1487 			case sex.male:
 1488 				s = _strlang({_default: 'male'});
 1489 				break;
 1490 			case sex.female:
 1491 				s = _strlang({_default: 'female'});
 1492 				break;
 1493 			case sex.other:
 1494 				s = _strlang({_default: 'other'});
 1495 				break;
 1496 			default:
 1497 				console.log('sex.format: unknown value: ' + v);
 1498 				s = '';
 1499 				break;
 1500 			}
 1501 			if (name !== null)
 1502 				_replcl(e, name, s, false);
 1503 			else
 1504 				_repl(e, s);
 1505 		};
 1506 		return sex;
 1507 	}());
 1508 
 1509 	ort.company = company;
 1510 	ort.user = user;
 1511 	ort.session = session;
 1512 	ort.sex = sex;
 1513 })(ort || (ort = {}));