cb9f8c1950a304e9eb6952dae699ea10b2588196
1 var browserType;
3 if (document.layers) {browserType = "nn4"}
4 if (document.all) {browserType = "ie"}
5 if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}
7 netscape = "";
8 ver= navigator.appVersion; len = ver.length;
10 for (iln = 0; iln < len; iln++){
11 if (ver.charAt(iln) == "("){
12 break;
13 }
14 }
15 netscape= (ver.charAt(iln+1).toUpperCase() != "C");
18 /* Toggle checkbox that matches regex */
19 function acl_set_all(regex,value)
20 {
21 for (var i = 0; i < document.mainform.elements.length; i++) {
22 var _id=document.mainform.elements[i].id;
23 if(_id.match(regex)) {
24 document.getElementById(_id).checked= value;
25 }
26 }
27 }
29 /* Toggle checkbox that matches regex */
30 function acl_toggle_all(regex)
31 {
32 for (var i = 0; i < document.mainform.elements.length; i++) {
33 var _id=document.mainform.elements[i].id;
34 if(_id.match(regex)) {
35 if (document.getElementById(_id).checked == true){
36 document.getElementById(_id).checked= false;
37 } else {
38 document.getElementById(_id).checked= true;
39 }
40 }
41 }
42 }
44 function keyPress(DnEvents) {
45 // determines whether Netscape or Internet Explorer
46 k = (netscape) ? DnEvents.keyCode : window.event.keyCode;
47 if (k == 13) { // enter key pressed
48 if(typeof(nextfield)!='undefined') {
49 if(nextfield == 'login') {
50 return true; // submit, we finished all fields
51 } else { // we are not done yet, send focus to next box
52 eval('document.mainform.' + nextfield + '.focus()');
53 return false;
54 }
55 } else {
56 if(netscape) {
57 if(DnEvents.target.type == 'textarea') {
58 return true;
59 } else if (DnEvents.target.type != 'submit') {
60 // TAB
61 var thisfield = document.getElementById(DnEvents.target.id);
62 for (i = 0; i < document.forms[0].elements.length; i++) {
63 if(document.forms[0].elements[i].id==thisfield.id) {
64 // Last form element on page?
65 if(i!=document.forms[0].elements.length-1) {
66 document.forms[0].elements[i+1].focus();
67 }
68 }
69 }
70 return false;
71 } else {
72 return true;
73 }
74 // Check for konqueror
75 } else if(document.clientWidth) {
76 // do nothing ATM
77 } else {
78 if(window.event.srcElement.type == 'textarea') {
79 return true;
80 } else if (window.event.srcElement.type != 'submit') {
81 // TAB
82 var thisfield = document.getElementById(window.event.srcElement.id);
83 for (i = 0; i < document.forms[0].elements.length; i++) {
84 if(document.forms[0].elements[i].id==thisfield.id) {
85 // Last form element on page?
86 if(i!=document.forms[0].elements.length-1) {
87 document.forms[0].elements[i+1].focus();
88 }
89 }
90 }
91 return false;
92 } else {
93 return true;
94 }
95 }
96 }
97 } else if (k==9) {
98 // Tab key pressed
99 if(netscape) {
100 if(DnEvents.target.type == 'textarea') {
101 document.getElementById(DnEvents.target.id).value+="\t";
102 return false;
103 }
104 // Check for konqueror
105 } else if(document.clientWidth) {
106 // do nothing ATM
107 } else {
108 if(window.event.srcElement.type == 'textarea') {
109 document.getElementById(window.event.srcElement.id).value+="\t";
110 return false;
111 }
112 }
113 }
114 }
116 function changeState(myField) {
117 if(document.getElementById(myField) != null){
118 document.getElementById(myField).disabled=(document.getElementById(myField).disabled)?false:true;
119 }
120 }
122 function setHidden(str) {
123 type = document.getElementById(str).style.display;
124 if((type=='')||(type=='block')) {
125 document.getElementById(str).style.display='none';
126 }else{
127 document.getElementById(str).style.display='block';
128 }
129 }
130 function changeSelectState(triggerField, myField) {
131 if (document.getElementById(triggerField).value != 2){
132 document.getElementById(myField).disabled= true;
133 } else {
134 document.getElementById(myField).disabled= false;
135 }
136 }
138 function changeSubselectState(triggerField, myField) {
139 if (document.getElementById(triggerField).checked == true){
140 document.getElementById(myField).disabled= false;
141 } else {
142 document.getElementById(myField).disabled= true;
143 }
144 }
146 function changeTripleSelectState(firstTriggerField, secondTriggerField, myField) {
147 if (
148 document.getElementById(firstTriggerField).checked == true &&
149 document.getElementById(secondTriggerField).checked == true){
150 document.getElementById(myField).disabled= false;
151 } else {
152 document.getElementById(myField).disabled= true;
153 }
154 }
156 <!-- Second field must be non-checked -->
157 function changeTripleSelectState_2nd_neg(firstTriggerField, secondTriggerField, myField) {
158 if (
159 document.getElementById(firstTriggerField).checked == true &&
160 document.getElementById(secondTriggerField).checked == false){
161 document.getElementById(myField).disabled= false;
162 } else {
163 document.getElementById(myField).disabled= true;
164 }
165 }
166 // work together to analyze keystrokes
167 if (netscape){
168 document.captureEvents(Event.KEYPRESS);
169 document.onkeypress= keyPress;
170 } else {
171 document.onkeydown= keyPress;
172 }
174 function hide(element) {
175 if (browserType == "gecko" )
176 document.poppedLayer = document.getElementById(element);
177 else if (browserType == "ie")
178 document.poppedLayer = document.all[element];
179 else
180 document.poppedLayer = document.layers[element];
181 document.poppedLayer.style.visibility = "hidden";
182 }
184 function show(element) {
185 if (browserType == "gecko" )
186 document.poppedLayer = document.getElementById(element);
187 else if (browserType == "ie")
188 document.poppedLayer = document.all[element];
189 else
190 document.poppedLayer = document.layers[element];
191 document.poppedLayer.style.visibility = "visible";
192 }
194 function toggle(element) {
195 if (browserType == "gecko" )
196 document.poppedLayer = document.getElementById(element);
197 else if (browserType == "ie")
198 document.poppedLayer = document.all[element];
199 else
200 document.poppedLayer = document.layers[element];
202 if (document.poppedLayer.style.visibility == "visible") {
203 hide (element);
204 } else {
205 show (element);
206 }
207 }
209 function popup(target, name) {
210 var mypopup=
211 window.open(
212 target,
213 name,
214 "width=600,height=700,location=no,toolbar=no,directories=no,menubar=no,status=no,scrollbars=yes"
215 );
216 mypopup.focus();
217 return false;
218 }
220 function js_check(form) {
221 form.javascript.value = 'true';
222 }
224 function divtoggle(element) {
225 var cell;
226 var cellname="tr_"+(element);
228 if (browserType == "gecko" ) {
229 document.poppedLayer = document.getElementById(element);
230 cell= document.getElementById(cellname);
232 if (document.poppedLayer.style.visibility == "visible") {
233 hide (element);
234 cell.style.height="0px";
235 document.poppedLayer.style.height="0px";
236 } else {
237 show (element);
238 document.poppedLayer.style.height="";
239 if(document.defaultView) {
240 cell.style.height=document.defaultView.getComputedStyle(document.poppedLayer,"").getPropertyValue('height');
241 }
242 }
243 } else if (browserType == "ie") {
244 document.poppedLayer = document.getElementById(element);
245 cell= document.getElementById(cellname);
246 if (document.poppedLayer.style.visibility == "visible") {
247 hide (element);
248 cell.style.height="0px";
249 document.poppedLayer.style.height="0px";
250 document.poppedLayer.style.position="absolute";
251 } else {
252 show (element);
253 cell.style.height="";
254 document.poppedLayer.style.height="";
255 document.poppedLayer.style.position="relative";
256 }
257 }
258 }
260 window.onload = adjust;
261 window.onresize = adjust;
263 function adjust (e) {
264 adjust_height(e);
265 adjust_width(e);
266 }
268 // Automatic resize (height) of divlists
269 function adjust_height(e) {
270 if (!e) e=window.event;
271 if (document.getElementById("menucell") && document.getElementById("d_scrollbody")) {
272 var inner_height= window.innerHeight;
273 var min_height= 450;
274 var px_height= min_height;
275 var suggested= px_height;
277 // document.defaultView allows access to the rendered size of elements and should be supported by modern browsers
278 if(document.defaultView) {
279 var menu_height=parseInt(document.defaultView.getComputedStyle(document.getElementById("menucell"),"").getPropertyValue('height'));
281 // Minimum height for divlist should be the bottom edge of the menu
282 min_height= menu_height-197;
283 suggested= min_height;
284 if((inner_height-230)-suggested>0) {
285 suggested= inner_height-230;
286 }
288 } else if(px_height >= 450) {
289 suggested= px_height-230;
290 }
291 document.getElementById("d_scrollbody").style.height=suggested+"px";
292 }
293 return true;
294 }
296 // Automatic resize (width) of divlists
297 function adjust_width(e) {
298 if (!e) e=window.event;
300 // Known to not work with IE
301 if(document.defaultView && document.getElementById("t_scrolltable")) {
302 // Resize the div
303 var div_width=parseInt(document.defaultView.getComputedStyle(document.getElementById("t_scrolltable"),"").getPropertyValue('width'));
304 var width= parseInt(window.innerWidth);
306 // Resize the body cells
307 var diff= width-div_width-470;
309 // window has been upscaled
310 if(div_width+diff>=600) {
311 document.getElementById('d_scrollbody').style.width=div_width+diff+"px";
312 document.getElementById('t_scrollbody').style.width=(div_width-19)+diff+"px";
314 // Resize the Header cells (only the relative-width ones)
315 document.getElementById('t_scrollhead').style.width=div_width+diff+"px";
317 // window has been downscaled, we must reset the div to 600px
318 } else if (width < 930) {
319 // Reset layout (set width to 600px)
320 div_width=600;
321 document.getElementById('d_scrollbody').style.width=div_width+"px";
322 document.getElementById('t_scrollbody').style.width=(div_width-19)+"px";
324 // Resize the Header cells (only the relative-width ones)
325 document.getElementById('t_scrollhead').style.width=div_width+"px";
326 }
327 } else if(document.defaultView && document.getElementById("t_scrolltable_onlywidth")) {
328 // Resize the div
329 var div_width=parseInt(document.defaultView.getComputedStyle(document.getElementById("t_scrolltable_onlywidth"),"").getPropertyValue('width'));
330 var width= parseInt(window.innerWidth);
332 // Resize the body cells
333 var diff= width-div_width-470;
335 // window has been upscaled
336 if(div_width+diff>=600) {
337 document.getElementById('d_scrollbody_onlywidth').style.width=div_width+diff+"px";
338 document.getElementById('t_scrollbody_onlywidth').style.width=(div_width-19)+diff+"px";
340 // Resize the Header cells (only the relative-width ones)
341 document.getElementById('t_scrollhead_onlywidth').style.width=div_width+diff+"px";
343 // window has been downscaled, we must reset the div to 600px
344 } else if (width < 930) {
345 // Reset layout (set width to 600px)
346 div_width=600;
347 document.getElementById('d_scrollbody_onlywidth').style.width=div_width+"px";
348 document.getElementById('t_scrollbody_onlywidth').style.width=(div_width-19)+"px";
350 // Resize the Header cells (only the relative-width ones)
351 document.getElementById('t_scrollhead_onlywidth').style.width=div_width+"px";
352 }
353 } else {
354 // IE
356 }
357 }
359 // vim:ts=2:syntax