3 function cbi_d_add(field, target, value) {
7 if (!cbi_d[target][value]) {
8 cbi_d[target][value] = [];
11 var obj = document.getElementById(field);
15 "parent": obj.parentNode,
16 "next": obj.nextSibling
18 cbi_d[target][value].unshift(entry);
22 function cbi_d_update(target) {
27 for (var x in cbi_d[target]) {
28 for (var i=0; i<cbi_d[target][x].length; i++) {
29 var entry = cbi_d[target][x][i];
30 if (entry.node.parentNode) {
31 entry.parent.removeChild(entry.node)
36 var t = document.getElementById(target);
44 if (t.type == "checkbox") {
45 value = t.checked ? value : "";
49 if (cbi_d[target][value]) {
50 for (var i=0; i<cbi_d[target][value].length; i++) {
51 var entry = cbi_d[target][value][i];
53 entry.parent.appendChild(entry.node);
55 entry.parent.insertBefore(entry.node, entry.next);
61 function cbi_d_init() {
62 for (var x in cbi_d) {
67 function cbi_bind(obj, type, callback, mode) {
68 if (typeof mode == "undefined") {
71 if (!obj.addEventListener) {
72 ieCallback = function(){
74 if (!e.target && e.srcElement) {
75 e.target = e.srcElement;
77 e.target['_eCB' + type + callback] = callback;
78 e.target['_eCB' + type + callback](e);
79 e.target['_eCB' + type + callback] = null;
81 obj.attachEvent('on' + type, ieCallback);
83 obj.addEventListener(type, callback, mode);
88 function cbi_combobox(id, values, def, man) {
89 var obj = document.getElementById(id)
90 var sel = document.createElement("select");
91 obj.parentNode.appendChild(sel);
93 if (!values[obj.value]) {
94 if (obj.value == "") {
95 var optdef = document.createElement("option");
97 optdef.appendChild(document.createTextNode(def));
98 sel.appendChild(optdef);
100 var opt = document.createElement("option");
101 opt.value = obj.value;
102 opt.selected = "selected";
103 opt.appendChild(document.createTextNode(obj.value));
104 sel.appendChild(opt);
108 for (var i in values) {
109 var opt = document.createElement("option");
112 if (obj.value == i) {
113 opt.selected = "selected";
116 opt.appendChild(document.createTextNode(values[i]));
117 sel.appendChild(opt);
120 var optman = document.createElement("option");
122 optman.appendChild(document.createTextNode(man));
123 sel.appendChild(optman);
125 obj.style.display = "none";
127 cbi_bind(sel, "change", function() {
128 if (sel.selectedIndex == sel.options.length - 1) {
129 obj.style.display = "inline";
130 sel.parentNode.removeChild(sel);
133 obj.value = sel.options[sel.selectedIndex].value;
138 function cbi_combobox_init(id, values, def, man) {
139 var obj = document.getElementById(id);
140 cbi_bind(obj, "blur", function() {
141 cbi_combobox(id, values, def, man)
143 cbi_combobox(id, values, def, man);