edc7cda7faeee68a6c093812f09de228a14194d9
1 var browserType;
2 var firefoxType;
4 if (document.layers) {browserType = "nn4"}
5 if (document.all) {browserType = "ie"}
6 if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}
7 if (browserType=="gecko" && window.navigator.userAgent.toLowerCase().match("firefox\/2")) {firefoxType= "firefox2"}
8 else {firefoxType= "firefox"};
10 netscape = "";
11 ver= navigator.appVersion; len = ver.length;
13 for (iln = 0; iln < len; iln++){
14 if (ver.charAt(iln) == "("){
15 break;
16 }
17 }
18 netscape= (ver.charAt(iln+1).toUpperCase() != "C");
21 /* Toggle checkbox that matches regex */
22 function chk_set_all(regex,value)
23 {
24 for (var i = 0; i < document.mainform.elements.length; i++) {
25 var _id=document.mainform.elements[i].id;
26 if(_id.match(regex)) {
27 document.getElementById(_id).checked= value;
28 }
29 }
30 }
33 function toggle_all_(regex,state_object)
34 {
35 state = document.getElementById(state_object).checked;
36 chk_set_all(regex, state);
37 }
40 function scrollDown() {
41 document.body.scrollTop = document.body.scrollHeight - document.body.clientHeight;
42 timeout= setTimeout("scrollDown()", 500);
43 }
45 /* Scroll down the body frame */
46 function scrollDown2()
47 {
48 document.body.scrollTop = document.body.scrollHeight - document.body.clientHeight;
49 }
52 /* Toggle checkbox that matches regex */
53 function acl_set_all(regex,value)
54 {
55 for (var i = 0; i < document.mainform.elements.length; i++) {
56 var _id=document.mainform.elements[i].id;
57 if(_id.match(regex)) {
58 document.getElementById(_id).checked= value;
59 }
60 }
61 }
63 /* Toggle checkbox that matches regex */
64 function acl_toggle_all(regex)
65 {
66 for (var i = 0; i < document.mainform.elements.length; i++) {
67 var _id=document.mainform.elements[i].id;
68 if(_id.match(regex)) {
69 if (document.getElementById(_id).checked == true){
70 document.getElementById(_id).checked= false;
71 } else {
72 document.getElementById(_id).checked= true;
73 }
74 }
75 }
76 }
78 function keyPress(DnEvents) {
79 // determines whether Netscape or Internet Explorer
80 k = (netscape) ? DnEvents.keyCode : window.event.keyCode;
81 if (k == 13) { // enter key pressed
82 if(typeof(nextfield)!='undefined') {
83 if(nextfield == 'login') {
84 return true; // submit, we finished all fields
85 } else { // we are not done yet, send focus to next box
86 eval('document.mainform.' + nextfield + '.focus()');
87 return false;
88 }
89 } else {
90 if(netscape) {
91 if(DnEvents.target.type == 'textarea') {
92 return true;
93 } else if (DnEvents.target.type != 'submit') {
94 // TAB
95 var thisfield = document.getElementById(DnEvents.target.id);
96 for (i = 0; i < document.forms[0].elements.length; i++) {
97 if(document.forms[0].elements[i].id==thisfield.id) {
98 // Last form element on page?
99 if(i!=document.forms[0].elements.length-1) {
100 document.forms[0].elements[i+1].focus();
101 }
102 }
103 }
104 return false;
105 } else {
106 return true;
107 }
108 // Check for konqueror
109 } else if(document.clientWidth) {
110 // do nothing ATM
111 } else {
112 if(window.event.srcElement.type == 'textarea') {
113 return true;
114 } else if (window.event.srcElement.type != 'submit') {
115 // TAB
116 var thisfield = document.getElementById(window.event.srcElement.id);
117 for (i = 0; i < document.forms[0].elements.length; i++) {
118 if(document.forms[0].elements[i].id==thisfield.id) {
119 // Last form element on page?
120 if(i!=document.forms[0].elements.length-1) {
121 document.forms[0].elements[i+1].focus();
122 }
123 }
124 }
125 return false;
126 } else {
127 return true;
128 }
129 }
130 }
131 } else if (k==9) {
132 // Tab key pressed
133 if(netscape) {
134 if(DnEvents.target.type == 'textarea') {
135 document.getElementById(DnEvents.target.id).value+="\t";
136 return false;
137 }
138 // Check for konqueror
139 } else if(document.clientWidth) {
140 // do nothing ATM
141 } else {
142 if(window.event.srcElement.type == 'textarea') {
143 document.getElementById(window.event.srcElement.id).value+="\t";
144 return false;
145 }
146 }
147 }
148 }
150 function changeState(myField) {
151 if(document.getElementById(myField) != null){
152 document.getElementById(myField).disabled=(document.getElementById(myField).disabled)?false:true;
153 }
154 }
156 function setHidden(str) {
157 type = document.getElementById(str).style.display;
158 if((type=='')||(type=='block')) {
159 document.getElementById(str).style.display='none';
160 }else{
161 document.getElementById(str).style.display='block';
162 }
163 }
164 function changeSelectState(triggerField, myField) {
165 if (document.getElementById(triggerField).value != 2){
166 document.getElementById(myField).disabled= true;
167 } else {
168 document.getElementById(myField).disabled= false;
169 }
170 }
172 function changeSubselectState(triggerField, myField) {
173 if (document.getElementById(triggerField).checked == true){
174 document.getElementById(myField).disabled= false;
175 } else {
176 document.getElementById(myField).disabled= true;
177 }
178 }
180 function changeTripleSelectState(firstTriggerField, secondTriggerField, myField) {
181 if (
182 document.getElementById(firstTriggerField).checked == true &&
183 document.getElementById(secondTriggerField).checked == true){
184 document.getElementById(myField).disabled= false;
185 } else {
186 document.getElementById(myField).disabled= true;
187 }
188 }
190 <!-- Second field must be non-checked -->
191 function changeTripleSelectState_2nd_neg(firstTriggerField, secondTriggerField, myField) {
192 if (
193 document.getElementById(firstTriggerField).checked == true &&
194 document.getElementById(secondTriggerField).checked == false){
195 document.getElementById(myField).disabled= false;
196 } else {
197 document.getElementById(myField).disabled= true;
198 }
199 }
200 // work together to analyze keystrokes
201 if (netscape){
202 if(firefoxType== "firefox") {
203 window.captureEvents(Event.KEYPRESS);
204 }
205 window.onkeypress= keyPress;
206 } else {
207 document.onkeydown= keyPress;
208 }
210 function hide(element) {
211 if (browserType == "gecko" )
212 document.poppedLayer = document.getElementById(element);
213 else if (browserType == "ie")
214 document.poppedLayer = document.all[element];
215 else
216 document.poppedLayer = document.layers[element];
217 document.poppedLayer.style.visibility = "hidden";
218 }
220 function show(element) {
221 if (browserType == "gecko" )
222 document.poppedLayer = document.getElementById(element);
223 else if (browserType == "ie")
224 document.poppedLayer = document.all[element];
225 else
226 document.poppedLayer = document.layers[element];
227 document.poppedLayer.style.visibility = "visible";
228 }
230 function toggle(element) {
231 if (browserType == "gecko" )
232 document.poppedLayer = document.getElementById(element);
233 else if (browserType == "ie")
234 document.poppedLayer = document.all[element];
235 else
236 document.poppedLayer = document.layers[element];
238 if (document.poppedLayer.style.visibility == "visible") {
239 hide (element);
240 } else {
241 show (element);
242 }
243 }
245 function popup(target, name) {
246 var mypopup=
247 window.open(
248 target,
249 name,
250 "width=600,height=700,location=no,toolbar=no,directories=no,menubar=no,status=no,scrollbars=yes"
251 );
252 mypopup.focus();
253 return false;
254 }
256 function js_check(form) {
257 form.javascript.value = 'true';
258 }
260 function divtoggle(element) {
261 var cell;
262 var cellname="tr_"+(element);
264 if (browserType == "gecko" ) {
265 document.poppedLayer = document.getElementById(element);
266 cell= document.getElementById(cellname);
268 if (document.poppedLayer.style.visibility == "visible") {
269 hide (element);
270 cell.style.height="0px";
271 document.poppedLayer.style.height="0px";
272 } else {
273 show (element);
274 document.poppedLayer.style.height="";
275 if(document.defaultView) {
276 cell.style.height=document.defaultView.getComputedStyle(document.poppedLayer,"").getPropertyValue('height');
277 }
278 }
279 } else if (browserType == "ie") {
280 document.poppedLayer = document.getElementById(element);
281 cell= document.getElementById(cellname);
282 if (document.poppedLayer.style.visibility == "visible") {
283 hide (element);
284 cell.style.height="0px";
285 document.poppedLayer.style.height="0px";
286 document.poppedLayer.style.position="absolute";
287 } else {
288 show (element);
289 cell.style.height="";
290 document.poppedLayer.style.height="";
291 document.poppedLayer.style.position="relative";
292 }
293 }
294 }
296 window.onload = adjust;
297 window.onresize = adjust;
299 function adjust (e) {
300 adjust_height(e);
301 adjust_width(e);
302 }
304 // Automatic resize (height) of divlists
305 function adjust_height(e) {
306 if (!e) e=window.event;
307 if (document.getElementById("menucell") && document.getElementById("d_scrollbody")) {
308 var inner_height= window.innerHeight;
309 var min_height= 450;
310 var px_height= min_height;
311 var suggested= px_height;
313 // document.defaultView allows access to the rendered size of elements and should be supported by modern browsers
314 if(document.defaultView) {
315 var menu_height=parseInt(document.defaultView.getComputedStyle(document.getElementById("menucell"),"").getPropertyValue('height'));
317 // Minimum height for divlist should be the bottom edge of the menu
318 min_height= menu_height-197;
319 suggested= min_height;
320 if((inner_height-230)-suggested>0) {
321 suggested= inner_height-230;
322 }
324 // IE uses other height specifications
325 } else if (browserType == "ie") {
326 suggested= document.all.menucell.offsetHeight;
327 offset= absTop(d_scrollbody);
328 suggested-= offset;
329 if((inner_height-230)-suggested>0) {
330 suggested= inner_height-230;
331 }
332 }
333 document.getElementById("d_scrollbody").style.height=suggested+"px";
334 }
335 return true;
336 }
338 function absTop(e) {
339 return (e.offsetParent)?e.offsetTop+absTop(e.offsetParent) : e.offsetTop;
340 }
342 // Automatic resize (width) of divlists
343 function adjust_width(e) {
344 if (!e) e=window.event;
346 // Known to not work with IE
347 if(document.defaultView && document.getElementById("t_scrolltable")) {
348 // Resize the div
349 var div_width=parseInt(document.defaultView.getComputedStyle(document.getElementById("t_scrolltable"),"").getPropertyValue('width'));
350 var width= parseInt(window.innerWidth);
352 // Resize the body cells
353 var diff= width-div_width-470;
355 // window has been upscaled
356 if(div_width+diff>=600) {
357 document.getElementById('d_scrollbody').style.width=div_width+diff+"px";
358 document.getElementById('t_scrollbody').style.width=(div_width-19)+diff+"px";
360 // Resize the Header cells (only the relative-width ones)
361 document.getElementById('t_scrollhead').style.width=div_width+diff+"px";
363 // window has been downscaled, we must reset the div to 600px
364 } else if (width < 930) {
365 // Reset layout (set width to 600px)
366 div_width=600;
367 document.getElementById('d_scrollbody').style.width=div_width+"px";
368 document.getElementById('t_scrollbody').style.width=(div_width-19)+"px";
370 // Resize the Header cells (only the relative-width ones)
371 document.getElementById('t_scrollhead').style.width=div_width+"px";
372 }
373 } else if(document.defaultView && document.getElementById("t_scrolltable_onlywidth")) {
374 // Resize the div
375 var div_width=parseInt(document.defaultView.getComputedStyle(document.getElementById("t_scrolltable_onlywidth"),"").getPropertyValue('width'));
376 var width= parseInt(window.innerWidth);
378 // Resize the body cells
379 var diff= width-div_width-470;
381 // window has been upscaled
382 if(div_width+diff>=600) {
383 document.getElementById('d_scrollbody_onlywidth').style.width=div_width+diff+"px";
384 document.getElementById('t_scrollbody_onlywidth').style.width=(div_width-19)+diff+"px";
386 // Resize the Header cells (only the relative-width ones)
387 document.getElementById('t_scrollhead_onlywidth').style.width=div_width+diff+"px";
389 // window has been downscaled, we must reset the div to 600px
390 } else if (width < 930) {
391 // Reset layout (set width to 600px)
392 div_width=600;
393 document.getElementById('d_scrollbody_onlywidth').style.width=div_width+"px";
394 document.getElementById('t_scrollbody_onlywidth').style.width=(div_width-19)+"px";
396 // Resize the Header cells (only the relative-width ones)
397 document.getElementById('t_scrollhead_onlywidth').style.width=div_width+"px";
398 }
399 } else {
400 // IE
402 }
403 }
406 /* Set focus to first valid input field
407 avoid IExplorer warning about hidding or disabled fields
408 */
409 function focus_field()
410 {
411 var i = 0;
412 var e = 0;
413 var found = false;
414 var element_name = "";
415 var element =null;
417 while(focus_field.arguments[i] && !found){
419 var tmp = document.getElementsByName(focus_field.arguments[i]);
420 for(e = 0 ; e < tmp.length ; e ++ ){
422 if(tmp[e].disabled != true && tmp[e].type != "none" && tmp[e].type != "hidden" ){
423 found = true;
424 element = tmp[e];
425 }
426 }
427 i++;
428 }
430 if(element && found){
431 element.blur();
432 element.focus();
433 }
434 }
437 // vim:ts=2:syntax