/** * Create a custom overlay for the either the specified object, or the entire contents */function $overlay(show, obj) { 	var overlay = $('overlay'); 	if (!overlay) { 		overlay = new Element('div', { 			'id': 'overlay', 			'class': 'overlay', 			'styles': {				'position': 'absolute',				'zIndex': 99			} 		});		overlay.inject(document.body); 	}; 	var coord = null; 	if (!obj) 		coord = $merge($('Contents').getCoordinates(), {'height': '100%'}); 	else 		coord = obj.getCoordinates();	overlay.setStyles(coord);		 	window.scrollTo(0,0); 	overlay.setStyle('display', show?'':'none');	document.body.setStyle('overflow', show?'hidden':'auto'); 	overlay = null;}/** * Add function for getting the value of an object.  Object can be passed either as a direct * reference to the object, or as a string which will be used on form[0] to find the field * @param obj Can be either the text name of the field, or the actual field itself * @param index, optional.  The index of the form, on which the field exists.  Defaults to 0*/function $v(obj, index) {	var obj0 = obj;	if (typeof obj == 'string')		obj0 = $(obj);	if (!obj0)		if (!index) {			obj0 = eval('document.forms[0].' + obj);		} else {			obj0 = eval('document.forms[' + index + '].' + obj);		}	obj = obj0;		if (!obj)		return null;	var tmp;	switch (obj.type) {	case 'hidden':	case 'text':	case 'textarea':		// treat hidden and text items as the same type as both will only contain text		tmp = obj.value;		break;	case 'select-one':		// treat a single select as a special case.  The first value is always assumed to be an empty select.		tmp = ($defined(obj.options[obj.selectedIndex].value)?obj.options[obj.selectedIndex].value:obj.options[obj.selectedIndex].text)		break;	case 'select-multiple':		// check that at least one value is selected using helper function		tmp = new Array();		for (i=0; i<obj.options.length; i++) {			if (obj.options[i].selected) {				tmp[tmp.length]=($defined(obj[i].value)?obj[i].value:obj[i].text);			}		}		break;	default:		if ($type(obj)=='array' || $type(obj)=='collection') {			tmp = new Array();			for (var i=0; i<obj.length; i++) {				if (obj[i].checked) {					tmp[tmp.length]=(obj[i].value?obj[i].value:obj[i].text?obj[i].text:'');				}			}		} else {			tmp = (obj.checked?($defined(obj.value)?obj.value:obj.text):"");		}		break;	}	return tmp;}/** * Set the specified value for the given field * @param obj Can be either the text name of the field, or the actual field itself * @param v the value to set, check or select * @param index, optional.  The index of the form, on which the field exists.  Defaults to 0 */function $s(obj, v, index) {	var obj0 = obj;	if (typeof obj == 'string')		obj0 = $(obj);	if (!obj0)		if (!index) {			obj0 = eval('document.forms[0].' + obj);		} else {			obj0 = eval('document.forms[' + index + '].' + obj);		}	obj = obj0;		if (!obj)		return null;	var tmp;	switch (($type(obj)=='array' || $type(obj)=='collection') ? obj[0].type : obj.type) {	case 'hidden':	case 'text':	case 'textarea':		// treat hidden and text items as the same type as both will only contain text		obj.value = v;		break;	case 'select-one':	case 'select-multiple':		// check that at least one value is selected using helper function		tmp = new Array();		for (i=0; i<obj.options.length; i++) {			if ($type(v)=='array' || $type(v)=='collection') {				for (var j=0;j<v.length;j++) {					obj[i].selected =  ( ($defined(obj[i].value)?obj[i].value:obj[i].text) == v[j] );				}			} else {				obj[i].selected =  ( ($defined(obj[i].value)?obj[i].value:obj[i].text) == v );			}		}		break;	default:		if ($type(obj)=='array' || $type(obj)=='collection') {			tmp = new Array();			for (var i=0; i<obj.length; i++) {				if ($type(v)=='array' || $type(v)=='collection') {					for (var j=0;j<v.length;j++) {						obj[i].checked =  ( ($defined(obj[i].value)?obj[i].value:obj[i].text) == v[j] );					}				} else {					obj[i].checked =  ( ($defined(obj[i].value)?obj[i].value:obj[i].text) == v );				}			}		} else {			obj.checked =  ( ($defined(obj.value)?obj.value:obj.text) == v );		}		break;	}}var isNumberKey = function(e){    if (e.code > 31 && (e.code < 48 || e.code > 57))         return false;       return true;};var isBackSpaceKey = function(e){    return e.code == 8;};var isArrowKey = function(e) {    return e.code >= 37 && e.code <= 40;};
