new listen preferences reload and init managed
[brisk.git] / web / room.js
1 /*
2  *  brisk - room.js
3  *
4  *  Copyright (C) 2006-2012 Matteo Nastasi
5  *                          mailto: nastasi@alternativeoutput.it 
6  *                                  matteo.nastasi@milug.org
7  *                          web: http://www.alternativeoutput.it
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details. You should have received a
18  * copy of the GNU General Public License along with this program; if
19  * not, write to the Free Software Foundation, Inc, 59 Temple Place -
20  * Suite 330, Boston, MA 02111-1307, USA.
21  *
22  */
23
24
25 /* 
26
27    data = [ [ flags, name ],  ... ]
28    
29 */
30
31
32 var l_list_all = 0x00;
33 var l_list_auth = 0x01;
34 var l_list_isol = 0x02;
35
36 function client_prefs()
37 {
38 }
39
40 client_prefs.prototype = {
41     listen: -1
42 }
43
44 function state_add(flags)
45 {
46     var content = "", supercont = "";
47     var st, superst, name = "", supername = "", supersfx = "";
48     var tit = "", supertit = "";
49
50
51     if ((flags & 0xf00) != 0) {
52         st = flags & 0xf00;
53         // MLANG 4,12,16,20,24,28
54         switch (st) {
55         case 0x100:
56             name = "st_pau.png";
57             tit = (g_lang == 'en' ? "I'm doing a break" : "sono in pausa");
58             break;
59         case 0x200:
60             name = "st_out.png";
61             tit = (g_lang == 'en' ? "I'm away" : "sono fuori");
62             break;
63         case 0x300:
64             name = "st_dog.png";
65             tit = (g_lang == 'en' ? "Dog time" : "sono a spasso col cane");
66             break;
67         case 0x400:
68             name = "st_eat.png";
69             tit = (g_lang == 'en' ? "I'm eating" : "sto mangiando");
70             break;
71         case 0x500:
72             name = "st_wrk.png";
73             tit = (g_lang == 'en' ? "I'm working" : "sono a lavoro");
74             break;
75         case 0x600:
76             name = "st_smk.png";
77             tit = (g_lang == 'en' ? "I'm smoking a sigarett (and keeping a cancer)" : "sto fumando una sigaretta (e facendomi venire il cancro)");
78             break;
79         case 0x700:
80             name = "st_eye.png";
81             tit = (g_lang == 'en' ? "I'm here!" : "sono presente!");
82             break;
83         case 0x800:
84             name = "st_rabbit.png";
85             tit = (g_lang == 'en' ? "Rabbit time" : "sono a spasso col coniglio");
86             break;
87         case 0x900:
88             name = "st_soccer.png";
89             tit = (g_lang == 'en' ? "Soccer time" : "c'è la partita!!");
90             break;
91         case 0xa00:
92             name = "st_baby.png";
93             tit = (g_lang == 'en' ? "Children time" : "ho il pupo da accudire");
94             break;
95         case 0xb00:
96             name = "st_mop.png";
97             tit = (g_lang == 'en' ? "Mop time" : "sto rassettando");
98             break;
99         case 0xc00:
100             name = "st_babbo.png";
101             tit = (g_lang == 'en' ? "Sto dando i regali" : "sto dando i regali");
102             break;
103         case 0xd00:
104             name = "st_renna.png";
105             tit = (g_lang == 'en' ? "in giro per regali" : "in giro per regali");
106             break;
107         case 0xe00:
108             name = "st_pupaz.png";
109             tit = (g_lang == 'en' ? "Neve a gogò" : "neve a gogò");
110             break;
111         case 0xf00:
112             name = "st_visch.png";
113             tit = (g_lang == 'en' ? "aspettando sotto al vischio" : "aspettando sotto al vischio");
114             break;
115         default:
116             break;
117         }
118     }
119
120     if ((flags & 0xf0000) != 0) {
121         superst = flags & 0xf0000;
122         if (name != "") {
123             supersfx = "_side";                
124         }
125
126         switch (superst) {
127         case 0x20000:
128             supername = "superuser"+supersfx+".png";
129             supertit = (g_lang == 'en' ? "Brisk Supporter" : "Brisk Supporter");
130             break;
131         }
132     }
133
134     if (supername != "") {
135         content += '&nbsp;<img title="'+supertit+'" class="inline" src="img/'+supername+'">';
136     }
137     
138     if (name != "") {
139         content += '&nbsp;<img title="'+tit+'" class="inline" src="img/'+name+'">';
140     }
141
142     return content;
143 }
144
145 var standup_data_old = null;
146
147 // TODO !!
148 // appendChild , removeChild
149
150 function table_add(curtag, td)
151 {
152     var tbody  = null, tr, ct;
153
154     do {
155         // console.log("wt: "+curtag.tagName);
156
157         if (curtag.tagName.toLowerCase() == "div" || 
158             curtag.tagName.toLowerCase() == "table") {
159             curtag = curtag.firstChild;
160         }
161         else if (curtag.tagName.toLowerCase() == "tbody") {
162             tbody = curtag;
163             break;
164         }
165         else
166             curtag = null;
167     } while (curtag != null);
168     
169     curtag = tbody.firstChild;
170     ct = 0;
171     do {
172         if (curtag.tagName.toLowerCase() == "tr") {
173             if (curtag.firstChild != null) {
174                 curtag = curtag.firstChild;
175                 ct++;
176             }
177             else {
178                 curtag.appendChild(td);
179                 return(true);
180             }
181         }
182         else if (curtag.tagName.toLowerCase() == "td") {
183             if (curtag.nextSibling != null) {
184                 curtag = curtag.nextSibling;
185                 ct++;
186             }
187             else {
188                 if (ct < 4) {
189                     curtag.parentNode.appendChild(td);
190                     return (true);
191                 }
192                 else {
193                     ct = 0;
194                     curtag = curtag.parentNode.nextSibling;
195                 }
196             }
197         }
198         else {
199             curtag = curtag.parentNode;
200         }
201
202     } while (curtag != null);
203
204     tr = document.createElement("tr");
205     tr.appendChild(td);
206     tbody.appendChild(tr);
207
208     return (true);
209 }
210
211 function spcs(c1, c2, n)
212 {
213     var ret = "";
214     var i;
215
216     for (i = 0 ; i < n ; i++) {
217         if ((i % 2) == 0)
218             ret += c1;
219         else
220             ret += c2;
221     }
222
223     return (ret);
224 }
225
226
227 function table_walk(curtag)
228 {
229     do {
230         // console.log("wt: "+curtag.tagName);
231         if (curtag.tagName.toLowerCase() == "div" || 
232             curtag.tagName.toLowerCase() == "table" ||
233             curtag.tagName.toLowerCase() == "tbody") {
234             curtag = curtag.firstChild;
235         }
236         else if (curtag.tagName.toLowerCase() == "tr") {
237             if (curtag.firstChild != null)
238                 curtag = curtag.firstChild;
239             else if (curtag.tagName != '')
240                 curtag = curtag.nextSibling;
241             else
242                 curtag = null;
243         }
244         else if (curtag.tagName.toLowerCase() == "td") {
245             if (curtag.nextSibling != null)
246                 curtag = curtag.nextSibling;
247             else {
248                 if (curtag.parentNode.nextSibling != null && curtag.parentNode.nextSibling.tagName != '')
249                     curtag = curtag.parentNode.nextSibling;
250                 else
251                     curtag = null;
252             }
253         }
254         else
255             curtag = null;
256
257     } while (curtag != null && curtag.tagName.toLowerCase() != "td");
258
259     if (1 == 0) {
260         if (curtag == null)
261             alert("outtag == null"); 
262         else
263             alert("outtag: "+curtag.tagName);
264     }
265     return (curtag);
266 }
267
268 function j_stand_tdcont(el)
269 {
270     return (user_dec_and_state(el));
271 }
272
273 function j_stand_cont(ddata)
274 {
275     var i, ii;
276     var content;
277     var st = 0, name = "";
278     var curtag, nextag;
279
280     var data;
281
282     if (g_listen & l_list_isol) {
283         data = new Array();
284
285         for (i = 0, ii = 0 ; ii < ddata.length ; ii++) {
286             if ((ddata[ii][0] & 0x02) == 0) {
287                 continue;
288             }
289             data[i++] = ddata[ii];
290         }
291     }
292     else
293         data = ddata;
294
295     if (standup_data_old == null || data.length < 4) {
296     // if (standup_data_old == null) {
297         
298         content = '<table cols="'+(data.length < 4 ? data.length : 4)+'" class="table_standup">';
299         for (i = 0 ; i < data.length ; i++) {
300             if ((i % 4) == 0)
301                 content += '<tr>';
302             content += '<td id="'+i+'" class="room_standup">';
303             content += j_stand_tdcont(data[i]);
304             content += '</td>';
305             
306             if ((i % 4) == 3)
307                 content += '</tr>';
308         }
309         if ((i % 4) < 3)
310             content += '</tr>';
311         content += '</table>';
312         
313         $("standup").innerHTML = content;
314
315         // console.log("inizio");
316         // for (i = 0 , curtag = table_walk($("standup")) ; curtag != null ;  curtag = table_walk(curtag), i++ ) {
317         //     console.log("inloop["+i+"]: "+curtag.tagName+"  ID: "+curtag.id);
318         // }
319         // console.log("fine "+i);
320
321         // walktable($("standup"), nextag);
322         // console.log($("standup").firstChild);
323         // console.log($("standup").firstChild.firstChild.firstChild.firstChild);
324
325         // log_walk($("standup"));
326
327         standup_data_old = data;
328     }
329     else {
330         var idx_del, arr_add, idx_mod, arr_mod;
331         var idx_del_n = 0, idx_add_n = 0, idx_mod_n = 0;
332         var i, e;
333         var i_del, i_mod, i_add;
334         var td;
335
336         idx_del = new Array();
337         arr_add = new Array();
338         map_add = new Array();
339         idx_mod = new Array();
340         arr_mod = new Array();
341         map_cur = new Array();
342         
343         // find removed entries
344         for (i = 0 ; i < standup_data_old.length ; i++) {
345             for (e = 0 ; e < data.length ; e++) {
346                 if (standup_data_old[i][1] == data[e][1]) {
347                     break;
348                 }
349             }
350             if (e == data.length) {
351                 idx_del[idx_del_n++] = i;
352                 map_cur[i] = -1;
353             }
354             else {
355                 /* modified entries */
356                 if (standup_data_old[i][0] != data[e][0]) {
357                     arr_mod[idx_mod_n] = data[e];
358                     idx_mod[idx_mod_n++] = i;
359                 }
360                 map_cur[i] = e;
361             }
362         }
363
364         // find new entries
365         for (e = 0 ; e < data.length ; e++) {
366             for (i = 0 ; i < standup_data_old.length ; i++) {
367                 if (data[e][1] == standup_data_old[i][1] ) {
368                     break;
369                 }
370             }
371             if (i == standup_data_old.length) {
372                 // console.log("ADD: "+data[e][1]);
373                 arr_add[idx_add_n]   = data[e];
374                 map_add[idx_add_n++] = e;
375             }
376         }
377         
378         // TODO: qui travaso add in del
379
380         i_del = 0;
381         // alert("del: ["+j_stand_tdcont(standup_data_old[idx_del[i_del]])+"]");
382         for (i = 0 , i_del = 0, i_mod = 0, i_add = 0, curtag = table_walk($("standup")) ; curtag != null ;  curtag = table_walk(curtag), i++ ) {
383             // console.log("cur.id: "+curtag.id);
384
385             // alert("i: "+i+"  tagname: "+curtag.tagName+"  innerHTML: ["+curtag.innerHTML+"]");
386             // console.log("inloop["+i+"]: "+curtag.tagName+"  ID: "+curtag.id);
387             if (curtag.innerHTML == "") {
388                 // console.log("innerHTML == none");
389                 if (i_add < idx_add_n) {
390                     // console.log("  to be new");
391                     // console.log("  add:   CONT:"+j_stand_tdcont(arr_add[i_add]));
392                     curtag.innerHTML = j_stand_tdcont(arr_add[i_add]);
393                     curtag.id = map_add[i_add];
394                     i_add++
395                 }
396             }
397
398             // else if (i_del < idx_del_n && curtag.innerHTML == j_stand_tdcont(standup_data_old[idx_del[i_del]])) {
399             else if (i_del < idx_del_n && curtag.id == idx_del[i_del]) {
400                 // console.log("to be cancel["+i+"]:  ID: "+curtag.id);
401                 if (i_add < idx_add_n) {
402                     // console.log("  to be new");
403                     // console.log("  add:   CONT:"+j_stand_tdcont(arr_add[i_add]));
404                     curtag.innerHTML = j_stand_tdcont(arr_add[i_add]);
405                     curtag.id = map_add[i_add];
406                     i_add++
407                 }
408                 else {
409                     // console.log("  to be del");
410                     curtag.innerHTML = "";
411                     curtag.id = -1;
412                 }
413                 i_del++;
414             }
415             // else if (i_mod < idx_mod_n && curtag.innerHTML == j_stand_tdcont(standup_data_old[idx_mod[i_mod]])) {
416             else if (i_mod < idx_mod_n && curtag.id == idx_mod[i_mod]) {
417                 // console.log("  to be mod");
418                 // console.log("mod: "+idx_mod[i_mod]+ "  CONT:"+j_stand_tdcont(arr_mod[i_mod]));
419                 curtag.innerHTML = j_stand_tdcont(arr_mod[i_mod]);
420                 curtag.id = map_cur[curtag.id];
421                 i_mod++;
422             }
423             else
424                 curtag.id = map_cur[curtag.id];
425         }
426         // console.log("fineloop");
427
428         for (i ; i_add < idx_add_n ; i_add++, i++) {
429             // console.log("ADD: "+i+" arr_add: "+ arr_add[i_add][1]);
430             td = document.createElement("td");
431             td.className = "room_standup";
432             td.id = map_add[i_add];
433             td.innerHTML = j_stand_tdcont(arr_add[i_add]);
434
435             table_add($("standup"), td);
436         }
437
438         standup_data_old = data;
439         return;
440     }
441     // $("esco").innerHTML =  '<input class="button" name="logout" value="Esco." onclick="esco_cb();" type="button">';
442 }
443
444 function esco_cb() {
445     window.onbeforeunload = null; 
446     window.onunload = null; 
447     // nonunload = true; 
448     act_logout(0);
449  };
450
451
452
453 function j_tab_cont(table_idx, data)
454 {
455     var i;
456     var content = '';
457
458     for (i = 0 ; i < data.length ; i++) {
459         // content += user_decorator(data[i]);
460         // content += state_add(data[i][0]);
461         content += j_stand_tdcont(data[i]);
462
463         content += '<br>';
464     }
465     $("table"+table_idx).innerHTML = content;
466 }
467
468 function j_tab_act_cont(idx, act)
469 {
470     if (act == 'sit') {
471         // MLANG 1
472         $("table_act"+idx).innerHTML = '<input type="button" class="button" name="xhenter'+idx+'"  value="'+(g_lang == 'en' ? "Sit down." : "Mi siedo.")+'" onclick="act_sitdown('+idx+');">';
473     }
474     else if (act == 'sitreser') {
475         // <img class="nobo" title="tavolo riservato agli utenti registrati" style="display: inline; margin-right: 80px;" src="img/okauth.png">
476         // MLANG 1
477         $("table_act"+idx).innerHTML = '<input type="button" style="background-repeat: no-repeat; background-position: center; background-image: url(\'img/okauth.png\');" class="button" name="xhenter'+idx+'"  value="'+(g_lang == 'en' ? "Sit down." : "Mi siedo.")+'" onclick="act_sitdown('+idx+');">';
478     }
479     else if (act == 'wake') {
480         // MLANG 1
481         $("table_act"+idx).innerHTML = '<input type="button" class="button" name="xwakeup"  value="'+(g_lang == 'en' ? "Wake up." : "Mi alzo.")+'" onclick="act_wakeup();">';
482     }
483     else if (act == 'reserved') {
484         // MLANG 1
485         $("table_act"+idx).innerHTML = '<img class="nobo" title="'+(g_lang == 'en' ? "reserved table for authenticated users only" : "tavolo riservato agli utenti registrati")+'" style="margin-right: 20px;" src="img/onlyauth.png">';
486     }
487     else {
488         $("table_act"+idx).innerHTML = '';
489     }
490 }
491
492 function j_login_manager(form)
493 {
494     var token;
495
496     if (form.elements['passid'].value == '')
497         return (true);
498
499     else {
500         // console.log("richiesta token");
501         /* richiede token */
502         token = server_request('mesg', 'getchallenge', 'cli_name', encodeURIComponent(form.elements['nameid'].value));
503         tokens = token.split('|');
504         
505         // console.log('XX token: '+token);
506         // console.log(tokens);
507         if (token == null)
508             return (false);
509
510         token = calcMD5(tokens[1]+calcMD5(form.elements['passid'].value));
511         
512         form.elements['passid_private'].value = token;
513         form.elements['passid'].value = ""; // FIXME da sost con la stessa len di A
514
515         return (true);
516     }
517     
518     return (false);
519 }
520
521 function login_formtext_hilite()
522 {
523     formtext_hilite($("nameid"));
524     formtext_hilite($("passid"));
525     formsub_hilite($("sub"));
526 }
527
528 function login_init()
529 {
530     menu_init();
531     login_formtext_hilite();
532 }
533
534 function warrant_formtext_hilite(form)
535 {
536     /*
537     formtext_hilite($("nameid"));
538     formtext_hilite($("emailid"));
539     formsub_hilite($("subid"));
540     formsub_hilite($("cloid"));
541     */
542     formtext_hilite(form.elements['name']);
543     formtext_hilite(form.elements['email']);
544     formsub_hilite(form.elements['sub']);
545     formsub_hilite(form.elements['clo']);
546 }
547
548 function mesgtoadm_formtext_hilite(form)
549 {
550     /*
551     formtext_hilite($("subjid"));
552     formtext_hilite($("mesgid"));
553     formsub_hilite($("subid"));
554     formsub_hilite($("cloid"));
555     */
556     formtext_hilite(form.elements['subj']);
557     formtext_hilite(form.elements['mesg']);
558     formsub_hilite(form.elements['sub']);
559     formsub_hilite(form.elements['clo']);
560 }
561
562
563 function j_check_email(email)
564 {
565     if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
566         return (true);
567     return (false);
568 }
569
570 function j_authbox(form)
571 {
572     var no; 
573
574     do {
575         if (form.elements['realsub'].value == "chiudi") {
576             $('authbox').style.visibility = "hidden";
577             break;
578         }
579
580         if (form.elements['name'].value == '' || j_check_email(form.elements['email'].value) == false) {
581             // MLANG 2-4
582             no = new notify(gst, 
583                             (g_lang == 'en' ? "<br><b>nickname</b> and/or <b>e-mail</b> fields are invalid;<br>please, fix them." :
584                              "<br>I campi <b>nickname</b> e/o <b>e-mail</b> non sono validi;<br> correggeteli per favore."),
585                             1, (g_lang == 'en' ? "close" : "chiudi"), 280, 100); 
586             break;
587         }
588
589         // submit the request
590         token = server_request('mesg', 'warranty', 
591                                'cli_name', encodeURIComponent(form.elements['name'].value),
592                                'cli_email', encodeURIComponent(form.elements['email'].value) );
593         if (token == "1") {
594             $('authbox').style.visibility = "hidden";
595             form.elements['name'].value = "";
596             form.elements['email'].value = "";
597             break;
598         }
599     } while (0);
600
601     return (false);
602 }
603
604 function authbox(w, h)
605 {
606     var box;
607
608     box = $('authbox');
609
610     box.style.zIndex = 200;
611     box.style.width  = w+"px";
612     box.style.marginLeft  = -parseInt(w/2)+"px";
613     box.style.height = h+"px";
614     box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
615
616     warrant_formtext_hilite($('auth_form'));
617
618     box.style.visibility = "visible";
619     $("nameid").focus();
620 }
621
622 function j_mesgtoadmbox(form)
623 {
624     var no; 
625
626     do {
627         if (form.elements['realsub'].value == "chiudi") {
628             $('mesgtoadmbox').style.visibility = "hidden";
629             break;
630         }
631
632         if (form.elements['mesg'].value == '' || form.elements['subj'].value == '') {
633             // MLANG 1-3
634             no = new notify(gst, (g_lang == 'en' ? "<br><b>subject</b> and the <b>message</b> cannot be void;<br>please, fix them." :
635                                   "<br>Il <b>soggetto</b> e il <b>messaggo</b> non possono essere vuoti;<br>correggeteli per favore."), 1, 
636                                   (g_lang == 'en' ? "close" : "chiudi"), 280, 100); 
637             break;
638         }
639                 
640         // submit the request
641         token = server_request('mesg', 'mesgtoadm', 
642                                'cli_subj', encodeURIComponent(form.elements['subj'].value),
643                                'cli_mesg', encodeURIComponent(form.elements['mesg'].value) );
644         if (token == "1") {
645             $('mesgtoadmbox').style.visibility = "hidden";
646             form.elements['subj'].value = "";
647             form.elements['mesg'].value = "";
648             break;
649         }
650     } while (0);
651
652     return (false);
653 }
654
655 function mesgtoadmbox(w, h)
656 {
657     var box;
658
659     box = $('mesgtoadmbox');
660
661     box.style.zIndex = 200;
662     box.style.width  = w+"px";
663     box.style.marginLeft  = -parseInt(w/2)+"px";
664     box.style.height = h+"px";
665     box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
666
667     mesgtoadm_formtext_hilite($('mesgtoadm_form'));
668
669     box.style.visibility = "visible";
670     $('mesgtoadm_form').elements['subj'].focus();
671 }
672
673 function j_pollbox(form)
674 {
675     var no, i, choose; 
676
677     do {
678         // submit the request
679         
680         for (i = 0 ; i < form.elements.length ; i++) {
681             if (form.elements[i].checked == true)
682                 break;
683         }
684         if (i == form.elements.length) {
685             // MLANG 1-3
686             no = new notify(gst, (g_lang == 'en' ? "<br>You must choose ah item;<br> please, fix it." :
687                                   "<br>Non hai espresso nessuna preferenza;<br> correggi per favore."), 1, 
688                             (g_lang == 'en' ? "close" : "chiudi"), 280, 100); 
689             return false;
690         }
691         else
692             choose = form.elements[i].value;
693
694         token = server_request('mesg', 'poll', 
695                                'cli_choose', encodeURIComponent(choose) );
696
697         if (token == "1") {
698             // TODO: mesg to user
699             // $('mesgtoadmbox').style.visibility = "hidden";
700             break;
701         }
702     } while (0);
703
704     return (false);
705 }
706
707 function prefs_assign(content)
708 {
709     var prefs_new;
710     var s;
711
712     s = "prefs_new = " + content;
713     eval(s);
714
715     return (prefs_new);
716 }
717
718 var prefs_list_idx  = new Array( 0x00, 0x01, 0x02 );
719 var prefs_list_id   = new Array( "all", "auth", "isol" );
720
721 function prefs_apply(prefs_new)
722 {
723     if (typeof(g_prefs) == 'undefined')
724         return false;
725
726     /* listen management */
727     if (g_prefs.listen != prefs_new.listen) {
728         for (i = 0 ; i < prefs_list_idx.length ; i++) {
729             set_checked_value($('ra_listen_'+prefs_list_id[i]), prefs_new.listen);
730             if (prefs_new.listen == prefs_list_idx[i]) {
731                 $('list_'+prefs_list_id[i]).style.color = 'red';
732                 $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang];
733             }
734             else {
735                 $('list_'+prefs_list_id[i]).style.color = 'black';
736             }
737         }
738
739         g_prefs.listen = prefs_new.listen;
740         relo = true;
741     }
742 }
743
744 function prefs_load(content)
745 {
746     var prefs_new;
747
748     if ((prefs_new = prefs_assign(content)) == null)
749         return false;
750
751     return prefs_apply(prefs_new);
752 }
753
754 function list_set(what, is_update, info)
755 {
756     var i;
757     var relo = false;
758     var old_st = readCookie("CO_list");
759     
760     if (what == 'auth') {
761         $('list_auth').style.color = 'red';
762         $('list_isol').style.color = 'black';
763         $('list_all').style.color = 'black';
764         if (old_st == 'isolation')
765             relo = true;
766         g_listen = l_list_auth;
767     }
768     else if (what == 'isolation') {
769         $('list_auth').style.color = 'black';
770         $('list_isol').style.color = 'red';
771         $('list_all').style.color = 'black';
772         if (old_st != 'isolation')
773             relo = true;
774         g_listen = l_list_isol;
775     }
776     else {
777         $('list_auth').style.color = 'black';
778         $('list_isol').style.color = 'black';
779         $('list_all').style.color = 'red';
780         if (old_st == 'isolation')
781             relo = true;
782         g_listen = l_list_all;
783     }
784
785     set_checked_value($('ra_listen_auth'), what);
786     set_checked_value($('ra_listen_isol'), what);
787     set_checked_value($('ra_listen_all'),  what);
788
789     $('list_info').innerHTML = info;
790     if (is_update) {
791         createCookie("CO_list", what, 24*365, cookiepath);
792     }
793
794
795     if (relo || !is_update) {
796         for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
797             
798             if (i % 4 == 0) {
799                 $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
800             }
801             
802             $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
803         }
804         if (what == 'isolation') {
805             tra.hide_noauth();
806         }
807         else {
808             tra.show_noauth();
809         }
810             
811         if (false) {
812             // ricalculation of standup area
813             if (standup_data_old != null) {
814                 standup_data = standup_data_old;
815                 standup_data_old = null;
816                 j_stand_cont(standup_data);
817             }
818         }
819     }
820 }
821
822 function sideslide(domobj, height, step)
823 {
824     this.st = 'wait';
825     this.twait = 5000;
826
827     this.domobj = domobj;
828     this.height = height;
829     this.step = step;
830
831     this.start();
832 }
833
834 sideslide.prototype = {
835     id: null,
836     st: 'wait',
837     twait: 0,
838     scroll: 0,
839     countdown: 0,
840
841     domobj: null,
842     height: 0,
843     step: 0,
844
845     start: function() {
846         var instant = this;
847         
848         this.st = 'wait';
849         this.id = setTimeout(function () { instant.sideslide_cb(); }, this.twait);
850     },
851
852     sideslide_cb: function() {
853         var instant = this;
854
855         if (this.st == 'wait') {
856             this.st = 'scroll';
857             this.countdown = 10;
858             this.id = setInterval(function () { instant.sideslide_cb(); }, 100);
859         }
860         else if (this.st == 'scroll') {
861             this.scroll += (this.step / 10);
862             if (this.scroll >= this.height - this.step) {
863                 this.scroll = 0;
864             }
865             this.domobj.scrollTop = this.scroll;
866             this.countdown--;
867             if (this.countdown == 0) {
868                 this.stop();
869                 this.st = 'wait';
870                 this.id = setTimeout(function () { instant.sideslide_cb(); }, this.twait);
871             }
872         }
873     },
874
875
876     stop: function() {
877         if (this.id != null) {
878             clearInterval(this.id);
879             this.id = null;
880         }
881     }
882
883 }