3f832476f01a8aa053991af8b7c134c9f59fc9d2
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 }
334 /* Reduce height if a list footer is set */
335 if(document.getElementById("t_scrollfoot")){
336 suggested = suggested -20;
337 }
339 document.getElementById("d_scrollbody").style.height=suggested+"px";
340 }
341 return true;
342 }
344 function absTop(e) {
345 return (e.offsetParent)?e.offsetTop+absTop(e.offsetParent) : e.offsetTop;
346 }
348 // Automatic resize (width) of divlists
349 function adjust_width(e)
350 {
352 /* Get event ... it seems to be unused here ...*/
353 if (!e) {
354 e=window.event;
355 }
357 // Known to not work with IE
358 if(document.defaultView && document.getElementById("t_scrolltable")) {
360 // Get current width of divlist
361 var div_width = parseInt(document.defaultView.getComputedStyle(document.getElementById("t_scrolltable"),"").getPropertyValue('width'));
363 // Get window width
364 var width= parseInt(window.innerWidth);
366 // Resize the body cells, 470 represents the info box and the navigation part
367 var diff= width - div_width - 470;
369 // window has been upscaled
370 if(div_width+diff>=600) {
371 document.getElementById('d_scrollbody').style.width=div_width+diff+"px";
372 document.getElementById('t_scrollbody').style.width=(div_width-19)+diff+"px";
374 // Resize the Header cells (only the relative-width ones)
375 document.getElementById('t_scrollhead').style.width=div_width+diff+"px";
377 // window has been downscaled, we must reset the div to 600px
378 } else if (width < 930) {
379 // Reset layout (set width to 600px)
380 div_width=600;
381 document.getElementById('d_scrollbody').style.width=div_width+"px";
382 document.getElementById('t_scrollbody').style.width=(div_width-19)+"px";
384 // Resize the Header cells (only the relative-width ones)
385 document.getElementById('t_scrollhead').style.width=div_width+"px";
386 }
387 } else if(document.defaultView && document.getElementById("t_scrolltable_onlywidth")) {
388 // Resize the div
389 var div_width=parseInt(document.defaultView.getComputedStyle(document.getElementById("t_scrolltable_onlywidth"),"").getPropertyValue('width'));
390 var width= parseInt(window.innerWidth);
392 // Resize the body cells
393 var diff= width-div_width-200;
395 // window has been upscaled
396 if(div_width+diff>=600) {
397 document.getElementById('d_scrollbody_onlywidth').style.width=div_width+diff+"px";
398 document.getElementById('t_scrollbody_onlywidth').style.width=(div_width-19)+diff+"px";
400 // Resize the Header cells (only the relative-width ones)
401 document.getElementById('t_scrollhead_onlywidth').style.width=div_width+diff+"px";
403 // window has been downscaled, we must reset the div to 600px
404 } else if (width < 930) {
405 // Reset layout (set width to 600px)
406 div_width=600;
407 document.getElementById('d_scrollbody_onlywidth').style.width=div_width+"px";
408 document.getElementById('t_scrollbody_onlywidth').style.width=(div_width-19)+"px";
410 // Resize the Header cells (only the relative-width ones)
411 document.getElementById('t_scrollhead_onlywidth').style.width=div_width+"px";
412 }
413 } else {
414 // IE
416 }
417 }
420 /* Set focus to first valid input field
421 avoid IExplorer warning about hidding or disabled fields
422 */
423 function focus_field()
424 {
425 var i = 0;
426 var e = 0;
427 var found = false;
428 var element_name = "";
429 var element =null;
431 while(focus_field.arguments[i] && !found){
433 var tmp = document.getElementsByName(focus_field.arguments[i]);
434 for(e = 0 ; e < tmp.length ; e ++ ){
436 if(tmp[e].disabled != true && tmp[e].type != "none" && tmp[e].type != "hidden" ){
437 found = true;
438 element = tmp[e];
439 }
440 }
441 i++;
442 }
444 if(element && found){
445 element.blur();
446 element.focus();
447 }
448 }
452 function next_msg_dialog()
453 {
454 var s_pending = "";
455 var a_pending = new Array();
456 var i_id = 0;
457 var i = 0;
458 var tmp = "";
460 if(document.getElementById('current_msg_dialogs')){
461 var cur_id = document.getElementById('current_msg_dialogs').value;
462 if(cur_id != ""){
463 hide('e_layer2' + cur_id);
464 document.getElementById('closed_msg_dialogs').value += "," + cur_id;
465 document.getElementById('current_msg_dialogs').value= "";
466 }
467 }
469 if(document.getElementById('pending_msg_dialogs')){
470 s_pending = document.getElementById('pending_msg_dialogs').value;
471 a_pending = s_pending.split(",");
472 if(a_pending.length){
473 i_id = a_pending.pop();
474 for (i = 0 ; i < a_pending.length; ++i){
475 tmp = tmp + a_pending[i] + ',';
476 }
477 tmp = tmp.replace(/,$/g,"");
478 if(i_id != ""){
479 var ele = document.getElementById('e_layer2' + i_id);
480 ele.style.display= 'block' ;
481 document.getElementById('pending_msg_dialogs').value= tmp;
482 document.getElementById('current_msg_dialogs').value= i_id;
484 }
485 }
486 }
487 }
510 // vim:ts=2:syntax