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