4 * Copyright (C) 2006-2012 Matteo Nastasi
5 * mailto: nastasi@alternativeoutput.it
6 * matteo.nastasi@milug.org
7 * web: http://www.alternativeoutput.it
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.
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.
25 var EXIT_BAN_TIME = 3600;
26 var cookiepath = "/brisk/";
28 var mlang_commons = { 'imgload_a' : { 'it' : 'Immagini caricate ',
29 'en' : 'Loaded images ' },
30 'imgload_b' : { 'it' : '%.',
32 'gamleav' : { 'it' : 'Sei sicuro di volere lasciare questa mano?' ,
33 'en' : 'Are you sure to leave this game?' },
34 'brileav' : { 'it' : ' Vuoi veramente abbandonare la briscola ?\n(clicca annulla o cancel se vuoi ricaricare la briscola)',
35 'en' : ' Are you really sure to leave briscola ?\n(click cancel yo reload it)' },
36 'brireco' : { 'it' : 'Ripristino della briscola fallito, per non perdere la sessione ricaricare la pagina manualmente.',
37 'en' : 'Recovery of briscola failed, to keep the current session reload the page manually.' },
38 'btn_sit' : { 'it' : 'Mi siedo.',
40 'btn_exit' : { 'it' : 'Esco.',
42 'tit_list' : { '0' : { 'it' : '',
44 '1' : { 'it' : '(solo aut.)',
45 'en' : '(only aut.)' },
46 '2' : { 'it' : '(isolam.to)',
47 'en' : '(isolation)' } }
50 function $(id) { return document.getElementById(id); }
52 function dec2hex(d, padding)
54 var hex = Number(d).toString(16);
55 padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding;
57 while (hex.length < padding) {
64 function getStyle(x,IEstyleProp, MozStyleProp)
67 var y = x.currentStyle[IEstyleProp];
68 } else if (window.getComputedStyle) {
69 var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
74 /* replacement of setInterval on IE */
76 /*if not IE, do nothing*/
77 if(!document.uniqueID){return;};
79 /*Copy the default setInterval behavior*/
80 var nativeSetInterval = window.setInterval;
81 window.setInterval = function(fn,ms) {
83 if(arguments.length <= 2) {
84 return nativeSetInterval(fn,ms);
87 for(var i=2;i<arguments.length;i+=1) {
88 param[i-2] = arguments[i];
92 if(typeof(fn)=='function') {
94 return (function (fn,ms,param) {
95 var fo = function () {
96 fn.apply(window,param);
98 return nativeSetInterval(fo,ms);
101 else if(typeof(fn)=='string')
103 return nativeSetInterval(fn,ms);
107 throw Error('setInterval Error\nInvalid function type');
111 /*Copy the default setTimeout behavior*/
112 var nativeSetTimeout = window.setTimeout;
113 window.setTimeout = function(fn,ms) {
115 if(arguments.length <= 2) {
116 return nativeSetTimeout(fn,ms);
119 for(var i=2;i<arguments.length;i+=1) {
120 param[i-2] = arguments[i];
124 if(typeof(fn)=='function') {
126 return (function (fn,ms,param) {
127 var fo = function () {
128 fn.apply(window,param);
130 return nativeSetTimeout(fo,ms);
133 else if(typeof(fn)=='string')
135 return nativeSetTimeout(fn,ms);
139 throw Error('setTimeout Error\nInvalid function type');
145 function addEvent(obj,type,fn)
147 if (obj.addEventListener) {
148 obj.addEventListener( type, fn, false);
150 else if (obj.attachEvent) {
151 obj["e"+type+fn] = fn;
152 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
153 obj.attachEvent( "on"+type, obj[type+fn] );
156 throw new Error("Event registration not supported");
159 function removeEvent(obj,type,fn)
161 if (obj.removeEventListener) {
162 obj.removeEventListener( type, fn, false );
164 else if (obj.detachEvent) {
165 obj.detachEvent( "on"+type, obj[type+fn] );
167 obj["e"+type+fn] = null;
171 // var card_pos = RANGE 0 <= x < cards_ea_n
173 function show_bigpict(obj, act, x, y)
177 if (arguments.length > 4)
182 big = $(obj.id+"_big"+sfx);
184 big.style.left = obj.offsetLeft + x+"px";
185 big.style.top = obj.offsetTop + y+"px";
186 big.style.visibility = "visible";
189 big.style.visibility = "hidden";
193 function rnd_int(min, max) {
194 return Math.floor(Math.random() * (max - min + 1) + min);
197 function error_images()
199 // alert("GHESEMU!");
200 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
203 function abort_images()
205 // alert("ABORTAIMAGES");
206 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
209 function unload_images()
211 // alert("ABORTAIMAGES");
212 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
215 function reset_images()
217 // alert("ABORTAIMAGES");
218 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
221 function update_images()
223 // MLANG "Immagine caricate" + g_preload_imgsz_arr[g_imgct] + "%."
224 $("imgct").innerHTML = mlang_commons['imgload_a'][g_lang]+g_preload_imgsz_arr[g_imgct]+"%.";
225 if (g_imgct+1 < g_preload_img_arr.length) {
227 setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
229 // $("imgct").innerHTML += "U";
232 function preload_images(arr,idx)
236 // $("imgct").innerHTML = "Stiamo caricando "+arr[idx]+"%.<br>";
237 im.onload = update_images;
238 im.onerror = error_images;
239 im.onabort = abort_images;
240 im.onunload = unload_images;
241 im.onreset = reset_images;
243 // $("imgct").innerHTML += "P";
246 function safestatus(a)
254 function createXMLHttpRequest() {
255 if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
256 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
257 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
259 try { return new XMLHttpRequest(); } catch(e) {}
260 alert("XMLHttpRequest not supported");
264 function send_mesg(mesg)
266 var xhr_wr = createXMLHttpRequest();
267 var is_conn = (sess == "not_connected" ? false : true);
269 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
270 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
271 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
272 xhr_wr.onreadystatechange = function() { return; };
273 if (typeof(g_debug) == 'number' && g_debug > 0
274 && typeof(console) == 'object' && typeof(console.log) == 'function') {
275 var ldate = new Date();
276 console.log(ldate.getTime()+':MESG:'+mesg);
281 if (xhr_wr.responseText != null) {
282 eval(xhr_wr.responseText);
288 sync request to server
289 server_request([arg0=arg1[, arg2=arg3[, ...]]])
290 if var name == '__POST__' than all other vars will be managed as POST content
291 and the call will be a POST
293 function server_request()
295 var xhr_wr = createXMLHttpRequest();
296 var i, collect = "", post_collect = null, is_post = false;
298 if (arguments.length > 0) {
299 for (i = 0 ; i < arguments.length ; i+= 2) {
300 if (arguments[i] == "__POST__") {
307 post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
309 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
312 // alert("Args: "+arguments.length);
314 var is_conn = (sess == "not_connected" ? false : true);
316 // console.log("server_request:preresp: "+xhr_wr.responseText);
319 xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
320 xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
323 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
325 xhr_wr.onreadystatechange = function() { return; };
326 xhr_wr.send(post_collect);
328 if (xhr_wr.responseText != null) {
329 // console.log("server_request:resp: "+xhr_wr.responseText);
330 return (xhr_wr.responseText);
336 /* Stat: CHAT and TABLE */
338 function chatt_checksend(obj,e)
344 if(window.event) { // IE
347 else if(e.which) { // Netscape/Firefox/Opera
350 // alert("OBJ: "+obj);
351 if (keynum == 13 && obj.value != "") { // Enter
352 act_chatt(obj.value);
356 function act_chatt(value)
358 send_mesg("chatt|"+encodeURIComponent(value));
362 obj.disabled = false;
374 function act_sitdown(table)
376 send_mesg("sitdown|"+table);
379 function act_wakeup()
384 function act_splash()
394 function act_passwdhowto()
396 send_mesg("passwdhowto");
399 function act_mesgtoadm()
401 send_mesg("mesgtoadm");
406 act_chatt('/tav '+$('txt_in').value);
407 $('txt_in').value = '';
415 function act_placing()
417 send_mesg("placing");
420 function act_roadmap()
422 send_mesg("roadmap");
425 function act_whysupport()
427 send_mesg("whysupport");
430 function act_lascio()
435 function safelascio()
438 // MLANG "Sei sicuro di volere lasciare questa mano?"
439 res = window.confirm(mlang_commons['gamleav'][g_lang]);
444 function act_logout(exitlock)
446 send_mesg("logout|"+exitlock);
449 function act_reloadroom()
451 window.onunload = null;
452 window.onbeforeunload = null;
453 document.location.assign("index.php");
456 function act_shutdown()
460 send_mesg("shutdown");
461 // while (xhr_wr.readyState != 4)
465 function postact_logout()
467 // alert("postact_logout");
472 // eraseCookie("sess");
473 document.location.assign("index.php");
477 function slowimg(img,x1,y1,deltat,free,action,srcend)
479 x1,y1 - destination coords
480 deltat - time for each frame (in msec)
481 free - when the release the local block for other operations (range: 0 - 1)
482 action - function to run when the image is moved
483 srcend - image to switch when the image is moved
486 function sleep(st, delay)
488 // alert("LOC_NEW PRE: "+st.st_loc_new);
492 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
496 function slowimg(img,x1,y1,deltat,free,action,srcend) {
499 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
500 this.x0 = parseInt(getStyle(this.img,"left", "left"));
501 // alert("img.x0 = "+this.x0);
502 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
503 this.y0 = parseInt(getStyle(this.img,"top", "top"));
506 this.deltat = deltat;
508 this.action = action;
509 this.srcend = srcend;
512 slowimg.prototype = {
531 setstart: function(x0,y0)
537 setaction: function(act)
543 settime: function(time)
545 this.time = (time < this.deltat ? this.deltat : time);
546 this.step_n = parseInt(this.time / this.deltat);
547 this.dx = (this.x1 - this.x0) / this.step_n;
548 this.dy = (this.y1 - this.y0) / this.step_n;
549 if (this.step_n * this.deltat == this.time) {
553 this.step_free = parseInt(this.step_n * this.free);
559 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
561 this.st.st_loc_new++;
563 this.img.style.visibility = "visible";
564 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
569 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
570 if (this.step_cur == 0) {
571 var date = new Date();
572 // $("logz").innerHTML = "Timestart: " + date + "<br>";
574 if (this.step_cur <= this.step_n) {
575 this.img.style.left = this.x0 + this.dx * this.step_cur;
576 this.img.style.top = this.y0 + this.dy * this.step_cur;
578 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
579 if (this.step_cur == this.step_free && this.st != null) {
580 if (this.st.st_loc < this.st.st_loc_new) {
581 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
588 this.img.style.left = this.x1;
589 this.img.style.top = this.y1;
590 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
591 var date = new Date();
592 // $("logz").innerHTML += "Timestop: " + date + "<br>";
594 if (this.action != null) {
598 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
603 if (this.srcend != null) {
604 this.img.src = this.srcend;
610 function div_show(div)
612 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
613 div.style.visibility = "visible";
616 function notify_document(st, text, tout, butt, w, h, is_opa, block_time)
618 var clo, clodiv_ctx, clodiv_wai, box;
623 this.ancestor = document.body;
625 this.st.st_loc_new++;
627 clodiv_ctx = document.createElement("div");
628 clodiv_ctx.className = "notify_clo";
630 for (i = 0 ; i < butt.length ; i++) {
631 clo = document.createElement("input");
633 clo.className = "button";
634 clo.style.bottom = "4px";
637 clo.onclick = function () { this.obj.hide() };
639 clodiv_ctx.appendChild(clo);
643 // if (block_time > 0) {
644 // clo.value = "leggere, prego.";
648 // this.clodiv = clodiv_ctx;
649 // // this.clo = clo;
657 this.clodiv = clodiv_ctx;
660 cont = document.createElement("div");
662 cont.style.borderBottomStyle = "solid";
663 cont.style.borderBottomWidth = "1px";
664 cont.style.borderBottomColor = "gray";
665 cont.style.height = (h - 30)+"px";
666 cont.style.overflow = "auto";
667 cont.innerHTML = text;
669 box = document.createElement("div");
671 box.className = "notify_opaque";
673 box.className = "notify";
675 box.style.zIndex = 200;
676 box.style.width = w+"px";
677 box.style.marginLeft = -parseInt(w/2)+"px";
678 box.style.height = h+"px";
679 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
680 box.appendChild(cont);
681 box.appendChild(this.clodiv);
682 box.style.visibility = "visible";
686 this.ancestor.appendChild(box);
688 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
690 // if (block_time != 0) {
691 // this.tblkid = setTimeout(function(obj){ obj.clo.value = obj.butt; obj.clo.onclick = obj.input_hide; formsub_hilite(obj.clo); obj.clo.focus(); }, block_time, this);
694 // formsub_hilite(clo);
701 function notify_document_old(st, text, tout, butt, w, h, is_opa, block_time)
703 var clo, clodiv, box;
708 this.ancestor = document.body;
710 this.st.st_loc_new++;
712 clo = document.createElement("input");
714 clo.className = "button";
715 clo.style.bottom = "4px";
717 if (block_time > 0) {
718 clo.value = "leggere, prego.";
723 clo.onclick = this.input_hide;
726 clodiv = document.createElement("div");
727 clodiv.className = "notify_clo";
729 this.clodiv = clodiv;
731 clodiv.appendChild(clo);
733 cont = document.createElement("div");
735 cont.style.borderBottomStyle = "solid";
736 cont.style.borderBottomWidth = "1px";
737 cont.style.borderBottomColor = "gray";
738 cont.style.height = (h - 30)+"px";
739 cont.style.overflow = "auto";
740 cont.innerHTML = text;
742 box = document.createElement("div");
744 box.className = "notify_opaque";
746 box.className = "notify";
748 box.style.zIndex = 200;
749 box.style.width = w+"px";
750 box.style.marginLeft = -parseInt(w/2)+"px";
751 box.style.height = h+"px";
752 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
753 box.appendChild(cont);
754 box.appendChild(clodiv);
755 box.style.visibility = "visible";
759 this.ancestor.appendChild(box);
761 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
763 if (block_time != 0) {
764 this.tblkid = setTimeout(function(obj){ obj.clo.value = obj.butt; obj.clo.onclick = obj.input_hide; formsub_hilite(obj.clo); obj.clo.focus(); }, block_time, this);
773 notify_document.prototype = {
787 // alert("quiz: "+this.rett);
793 if (this.st.st_loc < this.st.st_loc_new) {
801 clearTimeout(this.toutid);
802 this.ancestor.removeChild(this.notitag);
810 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
817 this.ancestor = document.body;
819 this.st.st_loc_new++;
821 clo = document.createElement("input");
823 clo.className = "button";
824 clo.style.bottom = "4px";
826 if (block_time > 0) {
827 clo.value = "leggere, prego.";
832 clo.onclick = this.input_hide;
835 clodiv = document.createElement("div");
836 clodiv.className = "notify_clo";
838 this.clodiv = clodiv;
840 clodiv.appendChild(clo);
842 cont = document.createElement("div");
844 cont.style.borderBottomStyle = "solid";
845 cont.style.borderBottomWidth = "1px";
846 cont.style.borderBottomColor = "gray";
847 cont.style.height = (h - 30)+"px";
848 cont.style.overflow = "auto";
849 cont.innerHTML = text;
851 box = document.createElement("div");
853 box.className = "notify_opaque";
855 box.className = "notify";
857 box.style.zIndex = 200;
858 box.style.width = w+"px";
859 box.style.marginLeft = -parseInt(w/2)+"px";
860 box.style.height = h+"px";
861 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
862 box.appendChild(cont);
863 box.appendChild(clodiv);
864 box.style.visibility = "visible";
868 this.ancestor.appendChild(box);
870 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
872 if (block_time != 0) {
873 this.tblkid = setTimeout(function(obj){ obj.clo.value = obj.butt; obj.clo.onclick = obj.input_hide; formsub_hilite(obj.clo); obj.clo.focus(); }, block_time, this);
883 notify_ex.prototype = {
895 if (this.st.st_loc < this.st.st_loc_new) {
902 clearTimeout(this.toutid);
903 this.ancestor.removeChild(this.notitag);
907 input_hide: function()
909 clearTimeout(this.obj.toutid);
910 this.obj.ancestor.removeChild(this.obj.notitag);
916 notify.prototype = notify_ex.prototype; // Define sub-class
917 notify.prototype.constructor = notify;
918 notify.baseConstructor = notify_ex;
919 notify.superClass = notify_ex.prototype;
921 function notify(st, text, tout, butt, w, h)
923 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
928 return document.getElementById(id);
935 this.st_loc_new = -1;
936 this.comms = new Array;
946 sleep: function(delay) {
950 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
956 if (this.sleep_hdl != null) {
957 clearTimeout(this.sleep_hdl);
958 this.sleep_hdl = null;
963 function remark_step()
965 var ct = $("remark").l_remct;
971 $("remark").className = "remark"+ct;
972 $("remark").l_remct = ct;
973 setTimeout(remark_step,500);
976 $("remark").className = "remark0";
983 if ($("remark").l_remct == 0) {
984 $("remark").l_remct = 1;
985 setTimeout(remark_step,500);
989 function remark_off()
991 $("remark").l_remct = 0;
992 $("remark").className = "remark0";
996 function italizer(ga)
1000 return "<i>"+ga[1]+"</i>";
1006 function exitlock_show(num, islock)
1010 num = (num < 3 ? num : 3);
1011 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
1012 // alert("EXITLOCK: "+$("exitlock").src);
1013 $("exitlock").style.visibility = "visible";
1018 // exitlock_show(0, true);
1021 var chatt_lines = new Array();
1022 var chatt_lines_n = 0;
1024 var CHATT_MAXLINES = 40;
1026 function user_decorator(user)
1029 var flags = user[0];
1030 if ((flags & 0x03) != 0)
1031 name = "<span class='au" + (flags & 0x03) + "'>"+user[1]+"</span>";
1038 function user_dec_and_state(el)
1043 content = user_decorator(el);
1044 content += state_add(el[0],(typeof(el[2]) != 'undefined' ? el[2] : null));
1051 function chatt_sub(dt,data,str)
1053 var must_scroll = false;
1057 var bolder = [ (data[0] | 1), data[1] ];
1058 name = user_decorator(bolder);
1060 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
1063 // alert("ARRIVA NAME: "+ name + " STR:"+str);
1064 if (chatt_lines_n == CHATT_MAXLINES) {
1065 $("txt").innerHTML = "";
1066 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
1067 chatt_lines[i] = chatt_lines[i+1];
1068 $("txt").innerHTML += chatt_lines[i];
1070 chatt_lines[i] = dt+name+": "+str+ "<br>";
1071 $("txt").innerHTML += chatt_lines[i];
1074 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
1075 $("txt").innerHTML += chatt_lines[chatt_lines_n];
1078 // $("txt").innerHTML;
1082 $("txt").scrollTop = 10000000;
1084 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
1088 * GESTIONE DEI COOKIES
1090 function createCookie(name,value,hours,path) {
1092 var date = new Date();
1093 date.setTime(date.getTime()+(hours*60*60*1000));
1094 var expires = "; expires="+date.toGMTString();
1096 else var expires = "";
1097 document.cookie = name+"="+value+expires+"; path="+path;
1100 function readCookie(name) {
1101 var nameEQ = name + "=";
1102 var ca = document.cookie.split(';');
1103 for(var i=0;i < ca.length;i++) {
1105 while (c.charAt(0)==' ') c = c.substring(1,c.length);
1106 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
1111 function eraseCookie(name) {
1112 createCookie(name,"",-1);
1115 function onbeforeunload_cb () {
1119 function onunload_cb () {
1121 if (typeof(hstm) != "undefined")
1122 hstm.the_end = true;
1129 function room_checkspace(emme,tables,inpe)
1132 for (i = 0 ; i < emme ; i++)
1137 for (i = 0 ; i < 5 ; i++)
1138 alta += nome+"<br>";
1140 for (i = 0 ; i < tables ; i++) {
1141 $("table"+i).innerHTML = alta;
1143 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
1146 stand = "<table class=\"table_standup\"><tbody><tr>";
1147 for (i = 0 ; i < inpe ; i++) {
1148 stand += "<td>"+nome+"</td>";
1149 if ((i+1) % 4 == 0) {
1150 stand += "</tr><tr>";
1154 $("standup").innerHTML = stand;
1156 // VERIFY: what is this button ?
1158 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
1161 function unescapeHTML(cont) {
1162 var div = document.createElement('div');
1166 div.innerHTML = cont;
1167 if (div.childNodes[0]) {
1168 if (div.childNodes.length > 1) {
1169 if (div.childNodes.toArray)
1172 var length = div.childNodes.length, results = new Array(length);
1174 results[length] = div.childNodes[length];
1176 for (i=0 ; i<results.length ; i++)
1177 memo = memo + results[i].nodeValue;
1183 return (div.childNodes[0].nodeValue);
1191 function playsound(tag, sound) {
1192 // g_withflash is a global var
1194 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
1195 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
1196 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
1197 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
1198 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
1199 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
1203 function topbanner_init()
1205 setInterval(topbanner_cb, 666);
1209 function topbanner_cb()
1213 a = $('topbanner').style.backgroundColor;
1214 b = $('topbanner').style.borderLeftColor;
1216 $('topbanner').style.backgroundColor = b;
1217 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1219 // console.log("A: "+a+" B: "+b);
1222 function sidebanner_init()
1224 setInterval(sidebanner_cb, 666);
1227 function sidebanner2_init()
1229 setInterval(sidebanner2_cb, 666);
1232 function sidebanner_cb()
1236 a = $('sidebanner').style.backgroundColor;
1237 b = $('sidebanner').style.borderLeftColor;
1239 $('sidebanner').style.backgroundColor = b;
1240 $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
1242 // console.log("A: "+a+" B: "+b);
1245 function sidebanner2_cb()
1249 a = $('sidebanner2').style.backgroundColor;
1250 b = $('sidebanner2').style.borderLeftColor;
1252 $('sidebanner2').style.backgroundColor = b;
1253 $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
1255 // console.log("A: "+a+" B: "+b);
1259 function langtolng(lang)
1267 function formtext_hilite(obj)
1269 obj.className = 'input_text';
1270 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1271 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1274 function formsub_hilite(obj)
1276 obj.className = 'input_sub';
1277 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1278 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1281 // return the value of the radio button that is checked
1282 // return an empty string if none are checked, or
1283 // there are no radio buttons
1284 function get_checked_value(radioObj) {
1287 var radioLength = radioObj.length;
1288 if(radioLength == undefined)
1289 if(radioObj.checked)
1290 return radioObj.value;
1293 for(var i = 0; i < radioLength; i++) {
1294 if(radioObj[i].checked) {
1295 return radioObj[i].value;
1301 // set the radio button with the given value as being checked
1302 // do nothing if there are no radio buttons
1303 // if the given value does not exist, all the radio buttons
1304 // are reset to unchecked
1305 function set_checked_value(radioObj, newValue) {
1308 var radioLength = radioObj.length;
1309 if(radioLength == undefined) {
1310 radioObj.checked = (radioObj.value == newValue.toString());
1313 for(var i = 0; i < radioLength; i++) {
1314 radioObj[i].checked = false;
1315 if(radioObj[i].value == newValue.toString()) {
1316 radioObj[i].checked = true;
1321 function url_append_arg(url, name, value)
1323 var pos, sep, pref, rest;
1325 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1326 pos = url.indexOf('&'+name+'=');
1329 if ((pos = url.indexOf('?')) != -1)
1334 return (url+sep+name+"="+encodeURIComponent(value));
1337 pref = url.substring(0, pos+1);
1338 rest = url.substring(pos+1);
1339 // alert("rest: "+rest+" pos: "+pos);
1340 if ((pos = rest.indexOf('&')) != -1) {
1341 rest = rest.substring(pos);
1346 return (pref+name+"="+encodeURIComponent(value)+rest);
1350 function url_append_args(url)
1355 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1356 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1362 function url_complete(parent, url)
1365 var host = "", path = "";
1368 p = parent.indexOf("://");
1370 rest = parent.substring(p+3);
1371 p2 = rest.indexOf("/");
1373 host = parent.substring(0, p+3+p2);
1374 rest = parent.substring(p+3+p2);
1386 p = rest.lastIndexOf("/");
1388 path = rest.substring(0, p+1);
1391 // alert("host: ["+host+"] path: ["+path+"]");
1392 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/' || url.substring(0,4) == 'ws:/') {
1395 else if (url.substring(0,1) == '/') {
1399 return (host+path+url);