+var _focus;
+
+function debug(msg) {
+ box = document.getElementById('msgbox')
+ box.innerHTML= box.innerHTML+'<br>'+msg
+}
+
+function progbar(container) {
+ container.innerHTML= "<center><img src='"+
+ user.theme+"images/progressbar1.gif' /> "+
+ user.loadtxt+"</center>";
+}
+
+function save_focus(e) {
+ _focus = e.name||e.id;
+ var h = document.getElementById('hints');
+ if (h) {
+ h.style.display = e.title && e.title.length ? 'inline' : 'none';
+ h.innerHTML = e.title ? e.title : '';
+ }
+}
+
+function _expand(tabobj) {
+
+ var ul = tabobj.parentNode.parentNode;
+ var alltabs=ul.getElementsByTagName("input");
+ var frm = tabobj.form;
+
+ if (ul.getAttribute("rel")){
+ for (var i=0; i<alltabs.length; i++){
+ alltabs[i].className = "ajaxbutton" //deselect all tabs
+ }
+ tabobj.className = "current";
+ JsHttpRequest.request(tabobj)
+ }
+}
+
+//interface for selecting a tab (plus expand corresponding content)
+function expandtab(tabcontentid, tabnumber) {
+ var tabs = document.getElementById(tabcontentid);
+ _expand(tabs.getElementsByTagName("input")[tabnumber]);
+}
+
+function _set_combo_input(e) {
+ e.setAttribute('_last', e.value);
+ e.onblur=function() {
+ var but_name = this.name.substring(0, this.name.length-4)+'button';
+ var button = document.getElementsByName(but_name)[0];
+ var select = document.getElementsByName(this.getAttribute('rel'))[0];
+ save_focus(select);
+// submit request if there is submit_on_change option set and
+// search field has changed.
+ if (button && (this.value != this.getAttribute('_last'))) {
+ JsHttpRequest.request(button);
+ } else if(this.className=='combo2') {
+ this.style.display = 'none';
+ select.style.display = 'inline';
+ setFocus(select.name);
+ }
+ return false;
+ };
+ e.onkeyup = function(ev) {
+ var select = document.getElementsByName(this.getAttribute('rel'))[0];
+ if(select && select.selectedIndex>=0) {
+ var len = select.length;
+ var byid = this.className=='combo';
+ var ac = this.value.toUpperCase();
+ select.options[select.selectedIndex].selected = false;
+ for (i = 0; i < len; i++) {
+ var txt = byid ? select.options[i].value : select.options[i].text;
+ if (txt.toUpperCase().indexOf(ac) >= 0) {
+ select.options[i].selected = true;
+ break;
+ }
+ }
+ }
+ };
+ e.onkeydown = function(ev) {
+ ev = ev||window.event;
+ key = ev.keyCode||ev.which;
+ if(key == 13) {
+ this.blur();
+ return false;
+ }
+ }
+}
+
+function _update_box(s) {
+ var byid = s.className=='combo';
+ var rel = s.getAttribute('rel');
+ var box = document.getElementsByName(rel)[0];
+ if(box && s.selectedIndex>=0) {
+ var opt = s.options[s.selectedIndex];
+ if(box) {
+ box.value = byid ? opt.value : opt.text;
+ box.setAttribute('_last', box.value);
+ }
+ }
+}
+
+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() {
+ if(this.className=='combo')
+ _update_box(this);
+ if (this.selectedIndex != this.getAttribute('_last'))
+ this.onchange();
+ }
+ e.onchange = function() {
+ var s = this;
+
+ if(s.className=='combo')
+ _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 (box && key == 32 && this.className == 'combo2') {
+ this.style.display = 'none';
+ box.style.display = 'inline';
+ box.value='';
+ setFocus(box.name);
+ return false;
+ }
+ }
+}
+