+function _set_combo_select(e) {
+ // When combo position is changed via js (eg from searchbox)
+ // no onchange event is generated. To ensure proper change
+ // signaling we must track selectedIndex in onblur handler.
+ e.setAttribute('_last', e.selectedIndex);
+ e.onblur = function() {
+ var box = document.getElementsByName(this.getAttribute('rel'))[0];
+ if ((this.selectedIndex != this.getAttribute('_last'))
+ ||((string_contains(this.className, 'combo') || string_contains(this.className, 'combo3')) && _update_box(this))
+ )
+ this.onchange();
+ }
+ e.onchange = function() {
+ var s = this;
+ this.setAttribute('_last', this.selectedIndex);
+ if(string_contains(s.className, 'combo') || string_contains(this.className, 'combo3'))
+ _update_box(s);
+ if(s.selectedIndex>=0) {
+ var sname = '_'+s.name+'_update';
+ var update = document.getElementsByName(sname)[0];
+ if(update) {
+ JsHttpRequest.request(update);
+ }
+ }
+ return true;
+ }
+ e.onkeydown = function(event) {
+ event = event||window.event;
+ key = event.keyCode||event.which;
+ var box = document.getElementsByName(this.getAttribute('rel'))[0];
+ if(key == 8 || (key==37 && event.altKey)) {
+ event.returnValue = false;
+ return false;
+ }
+ if (box && (key == 32) && (string_contains(this.className, 'combo2'))) {
+ this.style.display = 'none';
+ box.style.display = 'inline';
+ box.value='';
+ setFocus(box);
+ return false;
+ } else {
+ if (key == 13 && !e.length) // prevent chrome issue (blocked cursor after CR on empty selector)
+ return false;
+ }
+ }