29003ea5b62fb2800c0497bcf01686d0b415bbe5
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 }
451 /* This function pops up messages from message queue
452 All messages are hidden in html output (style='display:none;').
453 This function makes single messages visible till there are no more dialogs queued.
455 hidden inputs:
456 current_msg_dialogs - Currently visible dialog
457 closed_msg_dialogs - IDs of already closed dialogs
458 pending_msg_dialogs - Queued dialog IDs.
459 */
460 function next_msg_dialog()
461 {
462 var s_pending = "";
463 var a_pending = new Array();
464 var i_id = 0;
465 var i = 0;
466 var tmp = "";
467 var ele = null;
468 var ele2 = null;
469 var cur_id = "";
471 if(document.getElementById('current_msg_dialogs')){
472 cur_id = document.getElementById('current_msg_dialogs').value;
473 if(cur_id != ""){
474 ele = document.getElementById('e_layer' + cur_id);
475 ele.onmousemove = "";
476 hide('e_layer' + cur_id);
477 document.getElementById('closed_msg_dialogs').value += "," + cur_id;
478 document.getElementById('current_msg_dialogs').value= "";
479 }
480 }
482 if(document.getElementById('pending_msg_dialogs')){
483 s_pending = document.getElementById('pending_msg_dialogs').value;
484 a_pending = s_pending.split(",");
485 if(a_pending.length){
486 i_id = a_pending.pop();
487 for (i = 0 ; i < a_pending.length; ++i){
488 tmp = tmp + a_pending[i] + ',';
489 }
490 tmp = tmp.replace(/,$/g,"");
491 if(i_id != ""){
492 ele = document.getElementById('e_layer' + i_id);
493 ele.style.display= 'block' ;
494 document.getElementById('pending_msg_dialogs').value= tmp;
495 document.getElementById('current_msg_dialogs').value= i_id;
496 ele2 = document.getElementById('e_layer2') ;
497 ele.onmousedown = start_move_div_by_cursor;
498 ele2.onmouseup = stop_move_div_by_cursor;
499 ele2.onmousemove = move_div_by_cursor;
500 }else{
501 ele2 = document.getElementById('e_layer2') ;
502 ele2.style.display ="none";
503 }
504 }
505 }
506 }
509 /* Drag & drop for message dialogs */
510 var enable_move_div_by_cursor = false; // Indicates wheter the div movement is enabled or not
511 var mouse_x_on_div = 0; //
512 var mouse_y_on_div = 0;
513 var div_offset_x = 0;
514 var div_offset_y = 0;
516 /* Activates msg_dialog drag & drop
517 * This function is called when clicking on a displayed msg_dialog
518 */
519 function start_move_div_by_cursor(e)
520 {
521 var x = 0;
522 var y = 0;
523 var cur_id = 0;
524 var dialog = null;
525 var event = null;
527 /* Get current msg_dialog position
528 */
529 cur_id = document.getElementById('current_msg_dialogs').value;
530 if(cur_id != ""){
531 dialog = document.getElementById('e_layer' + cur_id);
532 x = dialog.style.left;
533 y = dialog.style.top;
534 x = x.replace(/[^0-9]/g,"");
535 y = y.replace(/[^0-9]/g,"");
536 if(!y) y = 1;
537 if(!x) x = 1;
538 }
540 /* Get mouse position within msg_dialog
541 */
542 if(window.event){
543 event = window.event;
544 if(event.offsetX){
545 div_offset_x = event.clientX -x;
546 div_offset_y = event.clientY -y;
547 enable_move_div_by_cursor = true;
548 }
549 }else if(e){
550 event = e;
551 if(event.layerX){
552 div_offset_x = event.screenX -x;
553 div_offset_y = event.screenY -y;
554 enable_move_div_by_cursor = true;
555 }
556 }
557 }
560 /* Deactivate msg_dialog movement
561 */
562 function stop_move_div_by_cursor()
563 {
564 mouse_x_on_div = 0;
565 mouse_y_on_div = 0;
566 div_offset_x = 0;
567 div_offset_y = 0;
568 enable_move_div_by_cursor = false;
569 }
572 /* Move msg_dialog with cursor */
573 function move_div_by_cursor(e)
574 {
575 var event = false;
576 var mouse_pos_x = 0;
577 var mouse_pos_y = 0;
578 var cur_div_x = 0;
579 var cur_div_y = 0;
580 var cur_id = 0;
581 var dialog = null;
584 if(undefined !== enable_move_div_by_cursor && enable_move_div_by_cursor == true){
586 if(document.getElementById('current_msg_dialogs')){
588 /* Get mouse position on screen
589 */
590 if(window.event){
591 event = window.event;
592 mouse_pos_x =event.clientX;
593 mouse_pos_y =event.clientY;
594 }else if (e){
595 event = e;
596 mouse_pos_x =event.screenX;
597 mouse_pos_y =event.screenY;
598 }else{
599 return;
600 }
602 /* Get id of current msg_dialog */
603 cur_id = document.getElementById('current_msg_dialogs').value;
604 if(cur_id != ""){
605 dialog = document.getElementById('e_layer' + cur_id);
607 /* Calculate new position */
608 cur_div_x = mouse_pos_x - div_offset_x;
609 cur_div_y = mouse_pos_y - div_offset_y;
611 /* Ensure that dialog can't be moved out of screen */
612 if(cur_div_x < 0 ) cur_div_x = 0
613 if(cur_div_y < 0 ) cur_div_y = 0
615 /* Assign new values */
616 dialog.style.left = (cur_div_x ) + "px";
617 dialog.style.top = (cur_div_y ) + "px";
618 }
619 }
620 }
621 }
623 function send_menu_action(str)
624 {
625 if(str != "" && str != "#"){
626 if(document.getElementById('menu_action')){
627 document.getElementById('menu_action').value=str;
628 document.mainform.submit();
629 }
630 }
631 }
633 // vim:ts=2:syntax