4 * Copyright (C) 2006-2015 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)' } },
48 'tos_refu' : { 'it' : 'Rifiutando di sottoscrivere i nuovi termini del servizio non ti sarà più possibile accedere come utente registrato al sito, sei proprio sicuro di voler rifiutare le nuove condizioni d\'uso ?',
49 'en' : 'EN Rifiutando di sottoscrivere i nuovi termini del servizio non ti sarà più possibile accedere come utente registrato al sito, sei proprio sicuro di voler rifiutare le nuove condizioni d\'uso ?'
53 function $(id) { return document.getElementById(id); }
55 function dec2hex(d, padding)
57 var hex = Number(d).toString(16);
58 padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding;
60 while (hex.length < padding) {
67 function getStyle(x,IEstyleProp, MozStyleProp)
70 var y = x.currentStyle[IEstyleProp];
71 } else if (window.getComputedStyle) {
72 var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
77 /* replacement of setInterval on IE */
79 /*if not IE, do nothing*/
80 if(!document.uniqueID){return;};
82 /*Copy the default setInterval behavior*/
83 var nativeSetInterval = window.setInterval;
84 window.setInterval = function(fn,ms) {
86 if(arguments.length <= 2) {
87 return nativeSetInterval(fn,ms);
90 for(var i=2;i<arguments.length;i+=1) {
91 param[i-2] = arguments[i];
95 if(typeof(fn)=='function') {
97 return (function (fn,ms,param) {
98 var fo = function () {
99 fn.apply(window,param);
101 return nativeSetInterval(fo,ms);
104 else if(typeof(fn)=='string')
106 return nativeSetInterval(fn,ms);
110 throw Error('setInterval Error\nInvalid function type');
114 /*Copy the default setTimeout behavior*/
115 var nativeSetTimeout = window.setTimeout;
116 window.setTimeout = function(fn,ms) {
118 if(arguments.length <= 2) {
119 return nativeSetTimeout(fn,ms);
122 for(var i=2;i<arguments.length;i+=1) {
123 param[i-2] = arguments[i];
127 if(typeof(fn)=='function') {
129 return (function (fn,ms,param) {
130 var fo = function () {
131 fn.apply(window,param);
133 return nativeSetTimeout(fo,ms);
136 else if(typeof(fn)=='string')
138 return nativeSetTimeout(fn,ms);
142 throw Error('setTimeout Error\nInvalid function type');
148 function addEvent(obj, type, fn)
150 if (obj.addEventListener) {
151 obj.addEventListener( type, fn, false);
153 else if (obj.attachEvent) {
154 obj["e"+type+fn] = fn;
155 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
156 obj.attachEvent( "on"+type, obj[type+fn] );
159 throw new Error("Event registration not supported");
162 function removeEvent(obj,type,fn)
164 if (obj.removeEventListener) {
165 obj.removeEventListener( type, fn, false );
167 else if (obj.detachEvent) {
168 obj.detachEvent( "on"+type, obj[type+fn] );
170 obj["e"+type+fn] = null;
174 // var card_pos = RANGE 0 <= x < cards_ea_n
176 function show_bigpict(obj, act, x, y)
180 if (arguments.length > 4)
185 big = $(obj.id+"_big"+sfx);
187 big.style.left = obj.offsetLeft + x+"px";
188 big.style.top = obj.offsetTop + y+"px";
189 big.style.visibility = "visible";
192 big.style.visibility = "hidden";
196 function rnd_int(min, max) {
197 return Math.floor(Math.random() * (max - min + 1) + min);
200 function error_images()
202 // alert("GHESEMU!");
203 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
206 function abort_images()
208 // alert("ABORTAIMAGES");
209 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
212 function unload_images()
214 // alert("ABORTAIMAGES");
215 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
218 function reset_images()
220 // alert("ABORTAIMAGES");
221 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
224 function update_images()
226 // MLANG "Immagine caricate" + g_preload_imgsz_arr[g_imgct] + "%."
227 $("imgct").innerHTML = mlang_commons['imgload_a'][g_lang]+g_preload_imgsz_arr[g_imgct]+"%.";
228 if (g_imgct+1 < g_preload_img_arr.length) {
230 setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
232 // $("imgct").innerHTML += "U";
235 function preload_images(arr,idx)
239 // $("imgct").innerHTML = "Stiamo caricando "+arr[idx]+"%.<br>";
240 im.onload = update_images;
241 im.onerror = error_images;
242 im.onabort = abort_images;
243 im.onunload = unload_images;
244 im.onreset = reset_images;
246 // $("imgct").innerHTML += "P";
249 function safestatus(a)
257 function createXMLHttpRequest() {
258 if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
259 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
260 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
262 try { return new XMLHttpRequest(); } catch(e) {}
263 alert("XMLHttpRequest not supported");
267 function send_mesg(mesg)
269 var xhr_wr = createXMLHttpRequest();
270 var is_conn = (sess == "not_connected" ? false : true);
272 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
273 xhr_wr.open('GET', 'index_wr.php?&'+(is_conn ? 'sess='+sess : '')+'&stp='+gst.st+'&mesg='+mesg, (is_conn ? true : false));
274 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
275 xhr_wr.onreadystatechange = function() { return; };
276 if (typeof(g_debug) == 'number' && g_debug > 0
277 && typeof(console) == 'object' && typeof(console.log) == 'function') {
278 var ldate = new Date();
279 console.log(ldate.getTime()+':MESG:'+mesg);
284 if (xhr_wr.responseText != null) {
285 eval(xhr_wr.responseText);
291 sync request to server
292 server_request([arg0=arg1[, arg2=arg3[, ...]]])
293 if var name == '__POST__' than all other vars will be managed as POST content
294 and the call will be a POST
296 function server_request()
298 var xhr_wr = createXMLHttpRequest();
299 var i, collect = "", post_collect = null, is_post = false;
301 if (arguments.length > 0) {
302 for (i = 0 ; i < arguments.length ; i+= 2) {
303 if (arguments[i] == "__POST__") {
310 post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
312 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
315 // alert("Args: "+arguments.length);
317 var is_conn = (sess == "not_connected" ? false : true);
319 // console.log("server_request:preresp: "+xhr_wr.responseText);
322 xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
323 xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
326 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
328 xhr_wr.onreadystatechange = function() { return; };
329 xhr_wr.send(post_collect);
331 if (xhr_wr.responseText != null) {
332 // console.log("server_request:resp: "+xhr_wr.responseText);
333 return (xhr_wr.responseText);
339 /* Stat: CHAT and TABLE */
341 function chatt_checksend(obj,e)
347 if(window.event) { // IE
350 else if(e.which) { // Netscape/Firefox/Opera
353 // alert("OBJ: "+obj);
354 if (keynum == 13 && obj.value != "") { // Enter
355 act_chatt(obj.value);
359 function act_chatt(value)
361 if (value.substring(0, 6) == "/info ") {
362 info_show(value.substring(6));
365 send_mesg("chatt|"+encodeURIComponent(value));
370 obj.disabled = false;
382 function act_sitdown(table)
384 send_mesg("sitdown|"+table);
387 function act_wakeup()
392 function act_splash()
402 function act_passwdhowto()
404 send_mesg("passwdhowto");
407 function act_mesgtoadm()
409 send_mesg("mesgtoadm");
414 act_chatt('/tav '+$('txt_in').value);
415 $('txt_in').value = '';
423 function act_placing()
425 send_mesg("placing");
428 function act_roadmap()
430 send_mesg("roadmap");
433 function act_lascio()
438 function safelascio()
441 // MLANG "Sei sicuro di volere lasciare questa mano?"
442 res = window.confirm(mlang_commons['gamleav'][g_lang]);
447 function act_logout(exitlock)
449 send_mesg("logout|"+exitlock);
452 function act_reloadroom()
454 window.onunload = null;
455 window.onbeforeunload = null;
456 document.location.assign("index.php");
459 function act_shutdown()
463 send_mesg("shutdown");
464 // while (xhr_wr.readyState != 4)
468 function postact_logout()
470 // alert("postact_logout");
475 // eraseCookie("sess");
476 document.location.assign("index.php");
480 type - 'hard' or 'soft'
481 code - if soft: accept (0), refuse (1), download (2), later (3)
482 if hard: accept (0), refuse (1), download (2)
484 function act_tosmgr(type, code, tos_curr, tos_vers)
486 if (type != "soft" && type != "hard") {
492 send_mesg("tosmgr|"+type+"|"+code+"|"+tos_curr+"|"+tos_vers);
503 function tos_confirm(val, url)
509 return (window.confirm(mlang_commons['tos_refu'][g_lang]));
512 dlm = new download_mgr(url);
522 function slowimg(img,x1,y1,deltat,free,action,srcend)
524 x1,y1 - destination coords
525 deltat - time for each frame (in msec)
526 free - when the release the local block for other operations (range: 0 - 1)
527 action - function to run when the image is moved
528 srcend - image to switch when the image is moved
531 function sleep(st, delay)
533 // alert("LOC_NEW PRE: "+st.st_loc_new);
537 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
541 function slowimg(img,x1,y1,deltat,free,action,srcend) {
544 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
545 this.x0 = parseInt(getStyle(this.img,"left", "left"));
546 // alert("img.x0 = "+this.x0);
547 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
548 this.y0 = parseInt(getStyle(this.img,"top", "top"));
551 this.deltat = deltat;
553 this.action = action;
554 this.srcend = srcend;
557 slowimg.prototype = {
576 setstart: function(x0,y0)
582 setaction: function(act)
588 settime: function(time)
590 this.time = (time < this.deltat ? this.deltat : time);
591 this.step_n = parseInt(this.time / this.deltat);
592 this.dx = (this.x1 - this.x0) / this.step_n;
593 this.dy = (this.y1 - this.y0) / this.step_n;
594 if (this.step_n * this.deltat == this.time) {
598 this.step_free = parseInt(this.step_n * this.free);
604 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
606 this.st.st_loc_new++;
608 this.img.style.visibility = "visible";
609 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
614 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
615 if (this.step_cur == 0) {
616 var date = new Date();
617 // $("logz").innerHTML = "Timestart: " + date + "<br>";
619 if (this.step_cur <= this.step_n) {
620 this.img.style.left = this.x0 + this.dx * this.step_cur;
621 this.img.style.top = this.y0 + this.dy * this.step_cur;
623 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
624 if (this.step_cur == this.step_free && this.st != null) {
625 if (this.st.st_loc < this.st.st_loc_new) {
626 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
633 this.img.style.left = this.x1;
634 this.img.style.top = this.y1;
635 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
636 var date = new Date();
637 // $("logz").innerHTML += "Timestop: " + date + "<br>";
639 if (this.action != null) {
643 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
648 if (this.srcend != null) {
649 this.img.src = this.srcend;
655 function div_show(div)
657 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
658 div.style.visibility = "visible";
664 tout: if < 0 => infinite
672 function notify_document(st, text, tout, butt, confirm_func, confirm_func_args, w, h, is_opa, block_time)
674 var i, clo, clodiv_ctx, clodiv_wai, box;
678 this.ancestor = document.body;
679 this.confirm_func = confirm_func;
680 this.confirm_func_args = confirm_func_args;
681 this.st.st_loc_new++;
683 clodiv_ctx = document.createElement("div");
684 clodiv_ctx.className = "notify_clo";
686 for (i = 0 ; i < butt.length ; i++) {
687 this.input_add(butt[i], i, this.hide, clodiv_ctx);
690 if (block_time > 0) {
691 clodiv_wai = document.createElement("div");
692 clodiv_wai.className = "notify_clo";
694 this.input_add("leggere, prego.", 0, null, clodiv_wai);
695 this.clodiv = clodiv_wai;
696 this.clodiv_pkg = clodiv_ctx;
697 clodiv_ctx.style.display = 'none';
700 this.clodiv = clodiv_ctx;
703 cont = document.createElement("div");
705 cont.style.borderBottomStyle = "solid";
706 cont.style.borderBottomWidth = "1px";
707 cont.style.borderBottomColor = "gray";
708 cont.style.height = (h - 50)+"px";
709 cont.style.overflow = "auto";
710 cont.style.textAlign = "left";
711 cont.style.padding = "8px";
712 cont.style.fontFamily = "monospace";
713 cont.innerHTML = text;
715 box = document.createElement("div");
717 box.className = "notify_opaque";
719 box.className = "notify";
721 box.style.zIndex = 200;
722 box.style.width = w+"px";
723 box.style.marginLeft = -parseInt(w/2)+"px";
724 box.style.height = h+"px";
725 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
726 box.appendChild(cont);
727 box.appendChild(this.clodiv);
728 box.style.visibility = "visible";
732 this.ancestor.appendChild(box);
735 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
738 if (block_time != 0) {
739 this.tblkid = setTimeout(function(obj){ obj.notitag.removeChild(obj.clodiv); obj.clodiv = obj.clodiv_pkg; obj.clodiv.style.display = ''; obj.notitag.appendChild(obj.clodiv); }, block_time, this);
743 notify_document.prototype = {
757 confirm_func_args: [],
764 onclick_cb: name of the onclick callback (with signature f(idx) ) or null
765 anc: parent dom object
767 return new button dom object
769 input_add: function(s, idx, onclick_cb, anc)
773 clo = document.createElement("input");
775 clo.className = "button";
776 clo.style.bottom = "4px";
777 clo.style.margin = "2px";
782 clo.onclick = function () { onclick_cb.call(this.obj, this.obj_idx); };
785 anc.appendChild(clo);
792 // alert("quiz: "+this.rett);
798 if (this.st.st_loc < this.st.st_loc_new) {
805 if (this.confirm_func != null) {
808 args = [ val ].concat(this.confirm_func_args);
810 if (this.confirm_func.apply(null, args) == false) {
815 clearTimeout(this.toutid);
816 this.ancestor.removeChild(this.notitag);
824 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
831 this.ancestor = document.body;
833 this.st.st_loc_new++;
835 clo = document.createElement("input");
837 clo.className = "button";
838 clo.style.bottom = "4px";
840 if (block_time > 0) {
841 clo.value = "leggere, prego.";
846 clo.onclick = function () { this.obj.hide() };
849 clodiv = document.createElement("div");
850 clodiv.className = "notify_clo";
852 this.clodiv = clodiv;
854 clodiv.appendChild(clo);
856 cont = document.createElement("div");
858 cont.style.borderBottomStyle = "solid";
859 cont.style.borderBottomWidth = "1px";
860 cont.style.borderBottomColor = "gray";
861 cont.style.height = (h - 30)+"px";
862 cont.style.overflow = "auto";
863 cont.innerHTML = text;
865 box = document.createElement("div");
867 box.className = "notify_opaque";
869 box.className = "notify";
871 box.style.zIndex = 200;
872 box.style.width = w+"px";
873 box.style.marginLeft = -parseInt(w/2)+"px";
874 box.style.height = h+"px";
875 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
876 box.appendChild(cont);
877 box.appendChild(clodiv);
878 box.style.visibility = "visible";
882 this.ancestor.appendChild(box);
884 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
886 if (block_time != 0) {
887 this.tblkid = setTimeout(function(obj){ obj.clo.value = obj.butt; obj.clo.onclick = function () { this.obj.hide() }; formsub_hilite(obj.clo); obj.clo.focus(); }, block_time, this);
897 notify_ex.prototype = {
909 if (this.st.st_loc < this.st.st_loc_new) {
916 clearTimeout(this.toutid);
917 this.ancestor.removeChild(this.notitag);
923 notify.prototype = notify_ex.prototype; // Define sub-class
924 notify.prototype.constructor = notify;
925 notify.baseConstructor = notify_ex;
926 notify.superClass = notify_ex.prototype;
928 function notify(st, text, tout, butt, w, h)
930 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
936 this.st_loc_new = -1;
937 this.comms = new Array;
947 sleep: function(delay) {
951 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
957 if (this.sleep_hdl != null) {
958 clearTimeout(this.sleep_hdl);
959 this.sleep_hdl = null;
964 function remark_step()
966 var ct = $("remark").l_remct;
972 $("remark").className = "remark"+ct;
973 $("remark").l_remct = ct;
974 setTimeout(remark_step,500);
977 $("remark").className = "remark0";
984 if ($("remark").l_remct == 0) {
985 $("remark").l_remct = 1;
986 setTimeout(remark_step,500);
990 function remark_off()
992 $("remark").l_remct = 0;
993 $("remark").className = "remark0";
997 function italizer(ga)
1001 return "<i>"+ga[1]+"</i>";
1007 function exitlock_show(num, islock)
1011 num = (num < 3 ? num : 3);
1012 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
1013 // alert("EXITLOCK: "+$("exitlock").src);
1014 $("exitlock").style.visibility = "visible";
1019 // exitlock_show(0, true);
1022 var chatt_lines = new Array();
1023 var chatt_lines_n = 0;
1025 var CHATT_MAXLINES = 40;
1027 function user_decorator(user, is_real)
1029 var name, i, sp = "", cl = "";
1030 var flags = user[0] & 0x03 | ((user[0] & 0x0c0000) >> 16);
1032 // console.log(user[1]+" FLAGS: "+flags);
1034 for (i = 0 ; i < 4 ; i++) {
1035 if (flags & (1 << i)) {
1036 cl += sp + "au" + i + (is_real ? "" : "_off");
1042 name = "<span class='" + cl + "'><span class='" +
1043 (is_real && (flags & 0xfffffe && ((flags & 0x01) == 0)) ? "id_usr" : "") +
1044 "'>" + user[1] + "</span></span>";
1053 function user_dec_and_state(el)
1058 content = user_decorator(el, true);
1059 content += state_add(el[0],(typeof(el[2]) != 'undefined' ? el[2] : null));
1066 function chatt_sub(dt,data,str)
1068 var must_scroll = false;
1072 var bolder = [ (data[0] | 1), data[1] ];
1073 name = user_decorator(bolder, false);
1075 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
1078 // alert("ARRIVA NAME: "+ name + " STR:"+str);
1079 if (chatt_lines_n == CHATT_MAXLINES) {
1080 $("txt").innerHTML = "";
1081 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
1082 chatt_lines[i] = chatt_lines[i+1];
1083 $("txt").innerHTML += chatt_lines[i];
1085 chatt_lines[i] = dt+name+": "+str+ "<br>";
1086 $("txt").innerHTML += chatt_lines[i];
1089 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
1090 $("txt").innerHTML += chatt_lines[chatt_lines_n];
1093 // $("txt").innerHTML;
1097 $("txt").scrollTop = 10000000;
1099 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
1103 * GESTIONE DEI COOKIES
1105 function createCookie(name,value,hours,path) {
1107 var date = new Date();
1108 date.setTime(date.getTime()+(hours*60*60*1000));
1109 var expires = "; expires="+date.toGMTString();
1111 else var expires = "";
1112 document.cookie = name+"="+value+expires+"; path="+path;
1115 function readCookie(name) {
1116 var nameEQ = name + "=";
1117 var ca = document.cookie.split(';');
1118 for(var i=0;i < ca.length;i++) {
1120 while (c.charAt(0)==' ')
1121 c = c.substring(1,c.length);
1122 if (c.indexOf(nameEQ) == 0)
1123 return c.substring(nameEQ.length,c.length);
1128 function eraseCookie(name) {
1129 createCookie(name,"",-1);
1132 function onbeforeunload_cb () {
1136 function onunload_cb () {
1138 if (typeof(xstm) != "undefined")
1139 xstm.the_end = true;
1146 function room_checkspace(emme,tables,inpe)
1149 for (i = 0 ; i < emme ; i++)
1154 for (i = 0 ; i < 5 ; i++)
1155 alta += nome+"<br>";
1157 for (i = 0 ; i < tables ; i++) {
1158 $("table"+i).innerHTML = alta;
1160 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
1163 stand = "<table class=\"table_standup\"><tbody><tr>";
1164 for (i = 0 ; i < inpe ; i++) {
1165 stand += "<td>"+nome+"</td>";
1166 if ((i+1) % 4 == 0) {
1167 stand += "</tr><tr>";
1171 $("standup").innerHTML = stand;
1173 // VERIFY: what is this button ?
1175 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
1178 function unescapeHTML(cont) {
1179 var div = document.createElement('div');
1183 div.innerHTML = cont;
1184 if (div.childNodes[0]) {
1185 if (div.childNodes.length > 1) {
1186 if (div.childNodes.toArray)
1189 var length = div.childNodes.length, results = new Array(length);
1191 results[length] = div.childNodes[length];
1193 for (i=0 ; i<results.length ; i++)
1194 memo = memo + results[i].nodeValue;
1200 return (div.childNodes[0].nodeValue);
1208 function playsound(tag, sound) {
1209 // g_withflash is a global var
1211 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
1212 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
1213 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
1214 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
1215 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
1216 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
1220 function topbanner_init()
1222 setInterval(topbanner_cb, 666);
1226 function topbanner_cb()
1230 a = $('topbanner').style.backgroundColor;
1231 b = $('topbanner').style.borderLeftColor;
1233 $('topbanner').style.backgroundColor = b;
1234 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1236 // console.log("A: "+a+" B: "+b);
1239 function sidebanner_init(idx)
1241 setInterval(function () { sidebanner_cb(idx); }, 666);
1244 function sidebanner_cb(idx)
1248 a = $('sidebanner'+idx).style.backgroundColor;
1249 b = $('sidebanner'+idx).style.borderLeftColor;
1251 $('sidebanner'+idx).style.backgroundColor = b;
1252 $('sidebanner'+idx).style.borderColor = a+" "+a+" "+a+" "+a;
1254 // console.log("A: "+a+" B: "+b);
1258 function langtolng(lang)
1266 function formtext_hilite(obj)
1268 obj.className = 'input_text';
1269 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1270 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1273 function formsub_hilite(obj)
1275 obj.className = 'input_sub';
1276 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1277 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1280 // return the value of the radio button that is checked
1281 // return an empty string if none are checked, or
1282 // there are no radio buttons
1283 function get_checked_value(radioObj) {
1286 var radioLength = radioObj.length;
1287 if(radioLength == undefined)
1288 if(radioObj.checked)
1289 return radioObj.value;
1292 for(var i = 0; i < radioLength; i++) {
1293 if(radioObj[i].checked) {
1294 return radioObj[i].value;
1300 // set the radio button with the given value as being checked
1301 // do nothing if there are no radio buttons
1302 // if the given value does not exist, all the radio buttons
1303 // are reset to unchecked
1304 function set_checked_value(radioObj, newValue) {
1307 var radioLength = radioObj.length;
1308 if(radioLength == undefined) {
1309 radioObj.checked = (radioObj.value == newValue.toString());
1312 for(var i = 0; i < radioLength; i++) {
1313 radioObj[i].checked = false;
1314 if(radioObj[i].value == newValue.toString()) {
1315 radioObj[i].checked = true;
1320 function url_append_arg(url, name, value)
1322 var pos, sep, pref, rest;
1324 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1325 pos = url.indexOf('&'+name+'=');
1328 if ((pos = url.indexOf('?')) != -1)
1333 return (url+sep+name+"="+encodeURIComponent(value));
1336 pref = url.substring(0, pos+1);
1337 rest = url.substring(pos+1);
1338 // alert("rest: "+rest+" pos: "+pos);
1339 if ((pos = rest.indexOf('&')) != -1) {
1340 rest = rest.substring(pos);
1345 return (pref+name+"="+encodeURIComponent(value)+rest);
1349 function url_append_args(url)
1354 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1355 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1361 function url_complete(parent, url)
1364 var host = "", path = "";
1367 p = parent.indexOf("://");
1369 rest = parent.substring(p+3);
1370 p2 = rest.indexOf("/");
1372 host = parent.substring(0, p+3+p2);
1373 rest = parent.substring(p+3+p2);
1385 p = rest.lastIndexOf("/");
1387 path = rest.substring(0, p+1);
1390 // alert("host: ["+host+"] path: ["+path+"]");
1391 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/' || url.substring(0,4) == 'ws:/') {
1394 else if (url.substring(0,1) == '/') {
1398 return (host+path+url);
1402 function download_mgr(url)
1406 if ((ifra = $('the_downloader')) == null) {
1407 ifra = document.createElement("iframe");
1408 ifra.style.display = "none";
1409 ifra.id = 'the_downloader';
1410 document.body.appendChild(ifra);
1413 ifra.contentWindow.location.href = url;
1418 download_mgr.prototype = {
1422 function submit_click(obj)
1424 obj.form.elements['realsub'].value = obj.id;