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 BSK_USER_FLAGS = 0;
29 var BSK_USER_FLGVL = 1;
30 var BSK_USER_NICK = 2;
31 var BSK_USER_SCOL = 3;
33 var mlang_commons = { 'imgload_a' : { 'it' : 'Immagine caricate ',
34 'en' : 'Loaded images ' },
35 'imgload_b' : { 'it' : '%.',
37 'gamleav' : { 'it' : 'Sei sicuro di volere lasciare questa mano?' ,
38 'en' : 'Are you sure to leave this game?' },
39 'brileav' : { 'it' : ' Vuoi veramente abbandonare la briscola ?\n(clicca annulla o cancel se vuoi ricaricare la briscola)',
40 'en' : ' Are you really sure to leave briscola ?\n(click cancel yo reload it)' },
41 'brireco' : { 'it' : 'Ripristino della briscola fallito, per non perdere la sessione ricaricare la pagina manualmente.',
42 'en' : 'Recovery of briscola failed, to keep the current session reload the page manually.' },
43 'btn_sit' : { 'it' : 'Mi siedo.',
45 'btn_exit' : { 'it' : 'Esco.',
47 'tit_list' : { '0' : { 'it' : '',
49 '1' : { 'it' : '(solo aut.)',
50 'en' : '(only aut.)' },
51 '2' : { 'it' : '(isolam.to)',
52 'en' : '(isolation)' } }
56 if (arguments.length == 1)
57 return document.getElementById(arguments[0]);
59 return (arguments[0]).document.getElementById((arguments[1]));
62 function dec2hex(d, padding)
64 var hex = Number(d).toString(16);
65 padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding;
67 while (hex.length < padding) {
74 function getStyle(x,IEstyleProp, MozStyleProp)
77 var y = x.currentStyle[IEstyleProp];
78 } else if (window.getComputedStyle) {
79 var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
84 /* replacement of setInterval on IE */
86 /*if not IE, do nothing*/
87 if(!document.uniqueID){return;};
89 /*Copy the default setInterval behavior*/
90 var nativeSetInterval = window.setInterval;
91 window.setInterval = function(fn,ms) {
93 if(arguments.length <= 2) {
94 return nativeSetInterval(fn,ms);
97 for(var i=2;i<arguments.length;i+=1) {
98 param[i-2] = arguments[i];
102 if(typeof(fn)=='function') {
104 return (function (fn,ms,param) {
105 var fo = function () {
106 fn.apply(window,param);
108 return nativeSetInterval(fo,ms);
111 else if(typeof(fn)=='string')
113 return nativeSetInterval(fn,ms);
117 throw Error('setInterval Error\nInvalid function type');
121 /*Copy the default setTimeout behavior*/
122 var nativeSetTimeout = window.setTimeout;
123 window.setTimeout = function(fn,ms) {
125 if(arguments.length <= 2) {
126 return nativeSetTimeout(fn,ms);
129 for(var i=2;i<arguments.length;i+=1) {
130 param[i-2] = arguments[i];
134 if(typeof(fn)=='function') {
136 return (function (fn,ms,param) {
137 var fo = function () {
138 fn.apply(window,param);
140 return nativeSetTimeout(fo,ms);
143 else if(typeof(fn)=='string')
145 return nativeSetTimeout(fn,ms);
149 throw Error('setTimeout Error\nInvalid function type');
155 function addEvent(obj,type,fn)
157 if (obj.addEventListener) {
158 obj.addEventListener( type, fn, false);
160 else if (obj.attachEvent) {
161 obj["e"+type+fn] = fn;
162 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
163 obj.attachEvent( "on"+type, obj[type+fn] );
166 throw new Error("Event registration not supported");
169 function removeEvent(obj,type,fn)
171 if (obj.removeEventListener) {
172 obj.removeEventListener( type, fn, false );
174 else if (obj.detachEvent) {
175 obj.detachEvent( "on"+type, obj[type+fn] );
177 obj["e"+type+fn] = null;
181 // var card_pos = RANGE 0 <= x < cards_ea_n
183 function show_bigpict(obj, act, x, y)
187 if (arguments.length > 4)
192 big = $(obj.id+"_big"+sfx);
194 big.style.left = obj.offsetLeft + x+"px";
195 big.style.top = obj.offsetTop + y+"px";
196 big.style.visibility = "visible";
199 big.style.visibility = "hidden";
203 function rnd_int(min, max) {
204 return Math.floor(Math.random() * (max - min + 1) + min);
207 function error_images()
209 // alert("GHESEMU!");
210 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
213 function abort_images()
215 // alert("ABORTAIMAGES");
216 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
219 function unload_images()
221 // alert("ABORTAIMAGES");
222 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
225 function reset_images()
227 // alert("ABORTAIMAGES");
228 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
231 function update_images()
233 // MLANG "Immagine caricate" + g_preload_imgsz_arr[g_imgct] + "%."
234 $("imgct").innerHTML = mlang_commons['imgload_a'][g_lang]+g_preload_imgsz_arr[g_imgct]+"%.";
235 if (g_imgct+1 < g_preload_img_arr.length) {
237 setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
239 // $("imgct").innerHTML += "U";
242 function preload_images(arr,idx)
246 // $("imgct").innerHTML = "Stiamo caricando "+arr[idx]+"%.<br>";
247 im.onload = update_images;
248 im.onerror = error_images;
249 im.onabort = abort_images;
250 im.onunload = unload_images;
251 im.onreset = reset_images;
253 // $("imgct").innerHTML += "P";
256 function safestatus(a)
264 function createXMLHttpRequest() {
265 if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
266 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
267 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
269 try { return new XMLHttpRequest(); } catch(e) {}
270 alert("XMLHttpRequest not supported");
274 function send_mesg(mesg)
276 var xhr_wr = createXMLHttpRequest();
277 var is_conn = (sess == "not_connected" ? false : true);
279 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
280 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
281 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
282 xhr_wr.onreadystatechange = function() { return; };
283 if (typeof(g_debug) == 'number' && g_debug > 0
284 && typeof(console) == 'object' && typeof(console.log) == 'function') { // OK
285 var ldate = new Date();
286 console.log(ldate.getTime()+':MESG:'+mesg); // OK
291 if (xhr_wr.responseText != null) {
292 eval(xhr_wr.responseText);
298 sync request to server
299 server_request([arg0=arg1[, arg2=arg3[, ...]]])
300 if var name == '__POST__' than all other vars will be managed as POST content
301 and the call will be a POST
303 function server_request()
305 var xhr_wr = createXMLHttpRequest();
306 var i, collect = "", post_collect = null, is_post = false;
308 if (arguments.length > 0) {
309 for (i = 0 ; i < arguments.length ; i+= 2) {
310 if (arguments[i] == "__POST__") {
317 post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
319 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
322 // alert("Args: "+arguments.length);
324 var is_conn = (sess == "not_connected" ? false : true);
326 // console.log("server_request:preresp: "+xhr_wr.responseText);
329 xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
330 xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
333 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
335 xhr_wr.onreadystatechange = function() { return; };
336 xhr_wr.send(post_collect);
338 if (xhr_wr.responseText != null) {
339 // console.log("server_request:resp: "+xhr_wr.responseText);
340 return (xhr_wr.responseText);
346 /* Stat: CHAT and TABLE */
348 function chatt_checksend(obj,e)
354 if(window.event) { // IE
357 else if(e.which) { // Netscape/Firefox/Opera
360 // alert("OBJ: "+obj);
361 if (keynum == 13 && obj.value != "") { // Enter
362 act_chatt(obj.value);
366 function act_chatt(value)
368 send_mesg("chatt|"+encodeURIComponent(value));
372 obj.disabled = false;
384 function act_sitdown(table)
386 send_mesg("sitdown|"+table);
389 function act_wakeup()
394 function act_splash()
404 function act_passwdhowto()
406 send_mesg("passwdhowto");
409 function act_mesgtoadm()
411 send_mesg("mesgtoadm");
416 act_chatt('/tav '+$('txt_in').value);
417 $('txt_in').value = '';
425 function act_placing()
427 send_mesg("placing");
430 function act_roadmap()
432 send_mesg("roadmap");
435 function act_whysupport()
437 send_mesg("whysupport");
440 function act_lascio()
445 function safelascio()
448 // MLANG "Sei sicuro di volere lasciare questa mano?"
449 res = window.confirm(mlang_commons['gamleav'][g_lang]);
454 function act_logout(exitlock)
456 send_mesg("logout|"+exitlock);
459 function ModerateItem(item_ar)
465 this.time = item_ar[0];
466 this.usrid = item_ar[1];
467 this.table = item_ar[2];
468 this.name = item_ar[3];
469 this.cont = item_ar[4];
471 this.loctm = date.getTime();
473 date.setTime(this.time * 1000);
475 tr = document.createElement("tr");
476 td = document.createElement("td");
477 // FIXME a more readable date here
478 // td.innerHTML = date.xxxx;
479 td.innerHTML = this.time % 100000;
482 td = document.createElement("td");
483 td.innerHTML = this.table;
486 td = document.createElement("td");
487 td.innerHTML = this.usrid;
490 td = document.createElement("td");
491 td.innerHTML = this.name;
494 td = document.createElement("td");
495 td.innerHTML = this.cont;
501 ModerateItem.prototype = {
513 tr_get: function () {
517 sel_get: function () {
521 sel_set: function (v) {
524 this.tr.className = (v ? 'selected' : 'normal');
531 this.item = new Array();
534 Moderate.prototype = {
543 // max_dt: 1800000, // (msec) maximum delta between current and line time
544 max_dt: 15000, // (msec) FIXME: DEV VERSION maximum delta between current and line time
548 disable: function () {
550 clearTimeout(this.tout);
554 this.win.onbeforeunload = null;
560 activate: function (enable) {
561 if (this.enabled == enable) {
567 // FIXME: remove scrollbars, only for devel reason
568 // this.win = window.open("moderation.php", "_blank", "width=800,height=600,toolbar=no,location=no,menubar=no,status=no");
569 this.win = window.open("moderation.php", "_blank", "width=800,height=600,toolbar=no,location=no,menubar=no,status=no,scrollbars=yes");
570 if (this.win == null) {
574 // to finish initialization we wait for popup page onload event ...
575 this.win_waitonload();
579 this.enabled = false;
584 win_waitonload: function () {
585 if (typeof(this.win.is_loaded) == 'undefined' || this.win.is_loaded != true) {
586 this.tout = setTimeout(function (obj) { obj.win_waitonload(); }, 250, this);
593 post_onload: function() {
597 this.table = $(this.win, 'moder_tab');
599 for (i = 0 ; i < this.item.length ; i++) {
600 this.table.appendChild(this.item[i].tr_get());
601 this.item[i].hide = false;
607 onunload: function() {
611 is_enabled: function() {
612 return (this.enabled);
615 add: function(item) {
620 mi = new ModerateItem(item);
621 mi.tr.className = 'normal';
625 mi.tr.onclick = function () { self.row_select(mi); };
628 this.table.appendChild(mi.tr_get());
631 item_remove: function(idx) {
634 old = this.item.splice(idx,1);
637 this.table.removeChild(old[0].tr_get());
642 // moderation items garbage collector: after this.max_dt a line is removed
643 item_gc: function() {
647 time = date.getTime();
649 for (i = 0 ; i < this.item.length ; i++) {
650 if (time - this.item[i].loctm > this.max_dt) {
657 row_select: function(mi) {
658 for (i = 0 ; i < this.item.length ; i++) {
659 if (this.item[i] == mi) {
660 this.item[i].sel_set(!this.item[i].sel_get());
663 this.item[i].sel_set(false);
666 // mi.tr.className = "selected";
669 room_show_update: function(obj) {
670 this.tab_update(obj.checked, this.table_show);
674 table_show_update: function(obj) {
675 this.tab_update(this.room_show, obj.options[obj.selectedIndex].value );
678 tab_update: function(room_new, table_new)
680 // remove all and add all valid
681 for (i = 0 ; i < this.item.length ; i++) {
682 if (this.item[i].hide)
684 this.table.removeChild(this.item[i].tr_get());
685 this.item[i].hide = true;
688 for (i = 0 ; i < this.item.length ; i++) {
691 if (room_new && table_new == -1) {
694 else if (room_new && table_new != -1) {
695 if (this.item[i].table == table_new || this.item[i].table == -1) {
699 else if (!room_new && table_new == -1) {
700 if (this.item[i].table != -1) {
704 else if (!room_new && table_new != -1) {
705 if (this.item[i].table == table_new) {
710 this.table.appendChild(this.item[i].tr_get());
711 this.item[i].hide = false;
714 this.room_show = room_new;
715 this.table_show = table_new;
719 // function AddBefore(rowId){
720 // var target = document.getElementById(rowId);
721 // var newElement = document.createElement('tr');
722 // target.parentNode.insertBefore(newElement, target);
723 // return newElement;
726 // function AddAfter(rowId){
727 // var target = document.getElementById(rowId);
728 // var newElement = document.createElement('tr');
730 // target.parentNode.insertBefore(newElement, target.nextSibling );
731 // return newElement;
734 function moderate(enable)
736 return (g_moder.activate(enable));
739 var g_moder = new Moderate();
741 function act_moderate()
743 send_mesg("moderate|"+(g_moder.is_enabled() ? "false" : "true"));
748 // // build table with js
750 // g_moder.item = new Array;
751 // g_moder.table = xxx;
754 // if (g_moder == null)
757 // if (g_moder.win != null) {
758 // g_moder.win.close();
759 // g_moder.win = null;
762 // if (g_moder.item != null) {
771 function act_reloadroom()
773 if (g_moder.is_enabled()) {
776 window.onunload = null;
777 window.onbeforeunload = null;
778 document.location.assign("index.php");
782 function act_shutdown()
786 send_mesg("shutdown");
787 // while (xhr_wr.readyState != 4)
791 function postact_logout()
793 // alert("postact_logout");
795 if (g_moder.is_enabled()) {
803 // eraseCookie("sess");
804 document.location.assign("index.php");
808 function slowimg(img,x1,y1,deltat,free,action,srcend)
810 x1,y1 - destination coords
811 deltat - time for each frame (in msec)
812 free - when the release the local block for other operations (range: 0 - 1)
813 action - function to run when the image is moved
814 srcend - image to switch when the image is moved
817 function sleep(st, delay)
819 // alert("LOC_NEW PRE: "+st.st_loc_new);
823 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
827 function slowimg(img,x1,y1,deltat,free,action,srcend) {
830 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
831 this.x0 = parseInt(getStyle(this.img,"left", "left"));
832 // alert("img.x0 = "+this.x0);
833 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
834 this.y0 = parseInt(getStyle(this.img,"top", "top"));
837 this.deltat = deltat;
839 this.action = action;
840 this.srcend = srcend;
843 slowimg.prototype = {
862 setstart: function(x0,y0)
868 setaction: function(act)
874 settime: function(time)
876 this.time = (time < this.deltat ? this.deltat : time);
877 this.step_n = parseInt(this.time / this.deltat);
878 this.dx = (this.x1 - this.x0) / this.step_n;
879 this.dy = (this.y1 - this.y0) / this.step_n;
880 if (this.step_n * this.deltat == this.time) {
884 this.step_free = parseInt(this.step_n * this.free);
890 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
892 this.st.st_loc_new++;
894 this.img.style.visibility = "visible";
895 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
900 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
901 if (this.step_cur == 0) {
902 var date = new Date();
903 // $("logz").innerHTML = "Timestart: " + date + "<br>";
905 if (this.step_cur <= this.step_n) {
906 this.img.style.left = this.x0 + this.dx * this.step_cur;
907 this.img.style.top = this.y0 + this.dy * this.step_cur;
909 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
910 if (this.step_cur == this.step_free && this.st != null) {
911 if (this.st.st_loc < this.st.st_loc_new) {
912 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
919 this.img.style.left = this.x1;
920 this.img.style.top = this.y1;
921 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
922 var date = new Date();
923 // $("logz").innerHTML += "Timestop: " + date + "<br>";
925 if (this.action != null) {
929 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
934 if (this.srcend != null) {
935 this.img.src = this.srcend;
941 function div_show(div)
943 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
944 div.style.visibility = "visible";
947 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
954 this.ancestor = document.body;
956 this.st.st_loc_new++;
958 clo = document.createElement("input");
960 clo.className = "button";
961 clo.style.bottom = "4px";
963 if (block_time > 0) {
964 clo.value = "leggere, prego.";
969 clo.onclick = this.input_hide;
972 clodiv = document.createElement("div");
973 clodiv.className = "notify_clo";
975 this.clodiv = clodiv;
977 clodiv.appendChild(clo);
979 cont = document.createElement("div");
981 cont.style.borderBottomStyle = "solid";
982 cont.style.borderBottomWidth = "1px";
983 cont.style.borderBottomColor = "gray";
984 cont.style.height = (h - 30)+"px";
985 cont.style.overflow = "auto";
986 cont.innerHTML = text;
988 box = document.createElement("div");
990 box.className = "notify_opaque";
992 box.className = "notify";
994 box.style.zIndex = 200;
995 box.style.width = w+"px";
996 box.style.marginLeft = -parseInt(w/2)+"px";
997 box.style.height = h+"px";
998 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
999 box.appendChild(cont);
1000 box.appendChild(clodiv);
1001 box.style.visibility = "visible";
1005 this.ancestor.appendChild(box);
1007 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
1009 if (block_time != 0) {
1010 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);
1013 formsub_hilite(clo);
1020 notify_ex.prototype = {
1032 if (this.st.st_loc < this.st.st_loc_new) {
1039 clearTimeout(this.toutid);
1040 this.ancestor.removeChild(this.notitag);
1044 input_hide: function()
1046 clearTimeout(this.obj.toutid);
1047 this.obj.ancestor.removeChild(this.obj.notitag);
1053 notify.prototype = notify_ex.prototype; // Define sub-class
1054 notify.prototype.constructor = notify;
1055 notify.baseConstructor = notify_ex;
1056 notify.superClass = notify_ex.prototype;
1058 function notify(st, text, tout, butt, w, h)
1060 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
1066 this.st_loc_new = -1;
1067 this.comms = new Array;
1070 globst.prototype = {
1077 sleep: function(delay) {
1080 if (!this.the_end) {
1081 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
1087 if (this.sleep_hdl != null) {
1088 clearTimeout(this.sleep_hdl);
1089 this.sleep_hdl = null;
1094 function remark_step()
1096 var ct = $("remark").l_remct;
1102 $("remark").className = "remark"+ct;
1103 $("remark").l_remct = ct;
1104 setTimeout(remark_step,500);
1107 $("remark").className = "remark0";
1112 function remark_on()
1114 if ($("remark").l_remct == 0) {
1115 $("remark").l_remct = 1;
1116 setTimeout(remark_step,500);
1120 function remark_off()
1122 $("remark").l_remct = 0;
1123 $("remark").className = "remark0";
1127 function italizer(ga)
1131 return "<i>"+ga[1]+"</i>";
1137 function exitlock_show(num, islock)
1141 num = (num < 3 ? num : 3);
1142 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
1143 // alert("EXITLOCK: "+$("exitlock").src);
1144 $("exitlock").style.visibility = "visible";
1149 // exitlock_show(0, true);
1152 var chatt_lines = new Array();
1153 var chatt_lines_n = 0;
1155 var CHATT_MAXLINES = 40;
1157 function user_decorator(user)
1160 var flags = user[BSK_USER_FLAGS];
1161 var flags_vlt = user[BSK_USER_FLGVL];
1162 if ((flags & 0x03) != 0)
1163 name = "<span class='au" + (flags & 0x03) + "'>"+user[BSK_USER_NICK]+"</span>";
1165 name = user[BSK_USER_NICK];
1170 function user_dec_and_state(el)
1175 content = user_decorator(el);
1176 content += state_add(el[BSK_USER_FLAGS], el[BSK_USER_FLGVL],
1177 (typeof(el[BSK_USER_SCOL]) != 'undefined' ? el[BSK_USER_SCOL] : null));
1184 function chatt_sub(dt,data,str)
1186 var must_scroll = false;
1190 var bolder = [ (data[BSK_USER_FLAGS] | 1), data[BSK_USER_FLGVL], data[BSK_USER_NICK] ];
1191 name = user_decorator(bolder);
1193 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
1196 // alert("ARRIVA NAME: "+ name + " STR:"+str);
1197 if (chatt_lines_n == CHATT_MAXLINES) {
1198 $("txt").innerHTML = "";
1199 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
1200 chatt_lines[i] = chatt_lines[i+1];
1201 $("txt").innerHTML += chatt_lines[i];
1203 chatt_lines[i] = dt+name+": "+str+ "<br>";
1204 $("txt").innerHTML += chatt_lines[i];
1207 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
1208 $("txt").innerHTML += chatt_lines[chatt_lines_n];
1211 // $("txt").innerHTML;
1215 $("txt").scrollTop = 10000000;
1217 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
1221 * GESTIONE DEI COOKIES
1223 function createCookie(name,value,hours,path) {
1225 var date = new Date();
1226 date.setTime(date.getTime()+(hours*60*60*1000));
1227 var expires = "; expires="+date.toGMTString();
1229 else var expires = "";
1230 document.cookie = name+"="+value+expires+"; path="+path;
1233 function readCookie(name) {
1234 var nameEQ = name + "=";
1235 var ca = document.cookie.split(';');
1236 for(var i=0;i < ca.length;i++) {
1238 while (c.charAt(0)==' ') c = c.substring(1,c.length);
1239 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
1244 function eraseCookie(name) {
1245 createCookie(name,"",-1);
1248 function onbeforeunload_cb () {
1252 function onunload_cb () {
1254 if (typeof(hstm) != "undefined")
1255 hstm.the_end = true;
1262 function room_checkspace(emme,tables,inpe)
1265 for (i = 0 ; i < emme ; i++)
1270 for (i = 0 ; i < 5 ; i++)
1271 alta += nome+"<br>";
1273 for (i = 0 ; i < tables ; i++) {
1274 $("table"+i).innerHTML = alta;
1276 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
1279 stand = "<table class=\"table_standup\"><tbody><tr>";
1280 for (i = 0 ; i < inpe ; i++) {
1281 stand += "<td>"+nome+"</td>";
1282 if ((i+1) % 4 == 0) {
1283 stand += "</tr><tr>";
1287 $("standup").innerHTML = stand;
1289 // VERIFY: what is this button ?
1291 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
1294 function unescapeHTML(cont) {
1295 var div = document.createElement('div');
1299 div.innerHTML = cont;
1300 if (div.childNodes[0]) {
1301 if (div.childNodes.length > 1) {
1302 if (div.childNodes.toArray)
1305 var length = div.childNodes.length, results = new Array(length);
1307 results[length] = div.childNodes[length];
1309 for (i=0 ; i<results.length ; i++)
1310 memo = memo + results[i].nodeValue;
1316 return (div.childNodes[0].nodeValue);
1324 function playsound(tag, sound) {
1325 // g_withflash is a global var
1327 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
1328 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
1329 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
1330 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
1331 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
1332 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
1336 function topbanner_init()
1338 setInterval(topbanner_cb, 666);
1342 function topbanner_cb()
1346 a = $('topbanner').style.backgroundColor;
1347 b = $('topbanner').style.borderLeftColor;
1349 $('topbanner').style.backgroundColor = b;
1350 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1352 // console.log("A: "+a+" B: "+b);
1355 function sidebanner_init()
1357 setInterval(sidebanner_cb, 666);
1360 function sidebanner2_init()
1362 setInterval(sidebanner2_cb, 666);
1365 function sidebanner_cb()
1369 a = $('sidebanner').style.backgroundColor;
1370 b = $('sidebanner').style.borderLeftColor;
1372 $('sidebanner').style.backgroundColor = b;
1373 $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
1375 // console.log("A: "+a+" B: "+b);
1378 function sidebanner2_cb()
1382 a = $('sidebanner2').style.backgroundColor;
1383 b = $('sidebanner2').style.borderLeftColor;
1385 $('sidebanner2').style.backgroundColor = b;
1386 $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
1388 // console.log("A: "+a+" B: "+b);
1392 function langtolng(lang)
1400 function formtext_hilite(obj)
1402 obj.className = 'input_text';
1403 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1404 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1407 function formsub_hilite(obj)
1409 obj.className = 'input_sub';
1410 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1411 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1414 // return the value of the radio button that is checked
1415 // return an empty string if none are checked, or
1416 // there are no radio buttons
1417 function get_checked_value(radioObj) {
1420 var radioLength = radioObj.length;
1421 if(radioLength == undefined)
1422 if(radioObj.checked)
1423 return radioObj.value;
1426 for(var i = 0; i < radioLength; i++) {
1427 if(radioObj[i].checked) {
1428 return radioObj[i].value;
1434 // set the radio button with the given value as being checked
1435 // do nothing if there are no radio buttons
1436 // if the given value does not exist, all the radio buttons
1437 // are reset to unchecked
1438 function set_checked_value(radioObj, newValue) {
1441 var radioLength = radioObj.length;
1442 if(radioLength == undefined) {
1443 radioObj.checked = (radioObj.value == newValue.toString());
1446 for(var i = 0; i < radioLength; i++) {
1447 radioObj[i].checked = false;
1448 if(radioObj[i].value == newValue.toString()) {
1449 radioObj[i].checked = true;
1454 function url_append_arg(url, name, value)
1456 var pos, sep, pref, rest;
1458 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1459 pos = url.indexOf('&'+name+'=');
1462 if ((pos = url.indexOf('?')) != -1)
1467 return (url+sep+name+"="+encodeURIComponent(value));
1470 pref = url.substring(0, pos+1);
1471 rest = url.substring(pos+1);
1472 // alert("rest: "+rest+" pos: "+pos);
1473 if ((pos = rest.indexOf('&')) != -1) {
1474 rest = rest.substring(pos);
1479 return (pref+name+"="+encodeURIComponent(value)+rest);
1483 function url_append_args(url)
1488 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1489 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1495 function url_complete(parent, url)
1498 var host = "", path = "";
1501 p = parent.indexOf("://");
1503 rest = parent.substring(p+3);
1504 p2 = rest.indexOf("/");
1506 host = parent.substring(0, p+3+p2);
1507 rest = parent.substring(p+3+p2);
1519 p = rest.lastIndexOf("/");
1521 path = rest.substring(0, p+1);
1524 // alert("host: ["+host+"] path: ["+path+"]");
1525 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') {
1528 else if (url.substring(0,1) == '/') {
1532 return (host+path+url);