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)' } }
55 function $(id) { return document.getElementById(id); }
57 function $$(win, id) { return win.document.getElementById(id); }
59 function dec2hex(d, padding)
61 var hex = Number(d).toString(16);
62 padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding;
64 while (hex.length < padding) {
71 function getStyle(x,IEstyleProp, MozStyleProp)
74 var y = x.currentStyle[IEstyleProp];
75 } else if (window.getComputedStyle) {
76 var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
81 /* replacement of setInterval on IE */
83 /*if not IE, do nothing*/
84 if(!document.uniqueID){return;};
86 /*Copy the default setInterval behavior*/
87 var nativeSetInterval = window.setInterval;
88 window.setInterval = function(fn,ms) {
90 if(arguments.length <= 2) {
91 return nativeSetInterval(fn,ms);
94 for(var i=2;i<arguments.length;i+=1) {
95 param[i-2] = arguments[i];
99 if(typeof(fn)=='function') {
101 return (function (fn,ms,param) {
102 var fo = function () {
103 fn.apply(window,param);
105 return nativeSetInterval(fo,ms);
108 else if(typeof(fn)=='string')
110 return nativeSetInterval(fn,ms);
114 throw Error('setInterval Error\nInvalid function type');
118 /*Copy the default setTimeout behavior*/
119 var nativeSetTimeout = window.setTimeout;
120 window.setTimeout = function(fn,ms) {
122 if(arguments.length <= 2) {
123 return nativeSetTimeout(fn,ms);
126 for(var i=2;i<arguments.length;i+=1) {
127 param[i-2] = arguments[i];
131 if(typeof(fn)=='function') {
133 return (function (fn,ms,param) {
134 var fo = function () {
135 fn.apply(window,param);
137 return nativeSetTimeout(fo,ms);
140 else if(typeof(fn)=='string')
142 return nativeSetTimeout(fn,ms);
146 throw Error('setTimeout Error\nInvalid function type');
152 function addEvent(obj,type,fn)
154 if (obj.addEventListener) {
155 obj.addEventListener( type, fn, false);
157 else if (obj.attachEvent) {
158 obj["e"+type+fn] = fn;
159 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
160 obj.attachEvent( "on"+type, obj[type+fn] );
163 throw new Error("Event registration not supported");
166 function removeEvent(obj,type,fn)
168 if (obj.removeEventListener) {
169 obj.removeEventListener( type, fn, false );
171 else if (obj.detachEvent) {
172 obj.detachEvent( "on"+type, obj[type+fn] );
174 obj["e"+type+fn] = null;
178 // var card_pos = RANGE 0 <= x < cards_ea_n
180 function show_bigpict(obj, act, x, y)
184 if (arguments.length > 4)
189 big = $(obj.id+"_big"+sfx);
191 big.style.left = obj.offsetLeft + x+"px";
192 big.style.top = obj.offsetTop + y+"px";
193 big.style.visibility = "visible";
196 big.style.visibility = "hidden";
200 function rnd_int(min, max) {
201 return Math.floor(Math.random() * (max - min + 1) + min);
204 function error_images()
206 // alert("GHESEMU!");
207 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
210 function abort_images()
212 // alert("ABORTAIMAGES");
213 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
216 function unload_images()
218 // alert("ABORTAIMAGES");
219 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
222 function reset_images()
224 // alert("ABORTAIMAGES");
225 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
228 function update_images()
230 // MLANG "Immagine caricate" + g_preload_imgsz_arr[g_imgct] + "%."
231 $("imgct").innerHTML = mlang_commons['imgload_a'][g_lang]+g_preload_imgsz_arr[g_imgct]+"%.";
232 if (g_imgct+1 < g_preload_img_arr.length) {
234 setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
236 // $("imgct").innerHTML += "U";
239 function preload_images(arr,idx)
243 // $("imgct").innerHTML = "Stiamo caricando "+arr[idx]+"%.<br>";
244 im.onload = update_images;
245 im.onerror = error_images;
246 im.onabort = abort_images;
247 im.onunload = unload_images;
248 im.onreset = reset_images;
250 // $("imgct").innerHTML += "P";
253 function safestatus(a)
261 function createXMLHttpRequest() {
262 if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
263 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
264 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
266 try { return new XMLHttpRequest(); } catch(e) {}
267 alert("XMLHttpRequest not supported");
271 function send_mesg(mesg)
273 var xhr_wr = createXMLHttpRequest();
274 var is_conn = (sess == "not_connected" ? false : true);
276 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
277 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
278 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
279 xhr_wr.onreadystatechange = function() { return; };
280 if (typeof(g_debug) == 'number' && g_debug > 0
281 && typeof(console) == 'object' && typeof(console.log) == 'function') {
282 var ldate = new Date();
283 console.log(ldate.getTime()+':MESG:'+mesg);
288 if (xhr_wr.responseText != null) {
289 eval(xhr_wr.responseText);
295 sync request to server
296 server_request([arg0=arg1[, arg2=arg3[, ...]]])
297 if var name == '__POST__' than all other vars will be managed as POST content
298 and the call will be a POST
300 function server_request()
302 var xhr_wr = createXMLHttpRequest();
303 var i, collect = "", post_collect = null, is_post = false;
305 if (arguments.length > 0) {
306 for (i = 0 ; i < arguments.length ; i+= 2) {
307 if (arguments[i] == "__POST__") {
314 post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
316 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
319 // alert("Args: "+arguments.length);
321 var is_conn = (sess == "not_connected" ? false : true);
323 // console.log("server_request:preresp: "+xhr_wr.responseText);
326 xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
327 xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
330 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
332 xhr_wr.onreadystatechange = function() { return; };
333 xhr_wr.send(post_collect);
335 if (xhr_wr.responseText != null) {
336 // console.log("server_request:resp: "+xhr_wr.responseText);
337 return (xhr_wr.responseText);
343 /* Stat: CHAT and TABLE */
345 function chatt_checksend(obj,e)
351 if(window.event) { // IE
354 else if(e.which) { // Netscape/Firefox/Opera
357 // alert("OBJ: "+obj);
358 if (keynum == 13 && obj.value != "") { // Enter
359 act_chatt(obj.value);
363 function act_chatt(value)
365 send_mesg("chatt|"+encodeURIComponent(value));
369 obj.disabled = false;
381 function act_sitdown(table)
383 send_mesg("sitdown|"+table);
386 function act_wakeup()
391 function act_splash()
401 function act_passwdhowto()
403 send_mesg("passwdhowto");
406 function act_mesgtoadm()
408 send_mesg("mesgtoadm");
413 act_chatt('/tav '+$('txt_in').value);
414 $('txt_in').value = '';
422 function act_placing()
424 send_mesg("placing");
427 function act_roadmap()
429 send_mesg("roadmap");
432 function act_whysupport()
434 send_mesg("whysupport");
437 function act_lascio()
442 function safelascio()
445 // MLANG "Sei sicuro di volere lasciare questa mano?"
446 res = window.confirm(mlang_commons['gamleav'][g_lang]);
451 function act_logout(exitlock)
453 send_mesg("logout|"+exitlock);
456 var moder_win = null;
458 function act_moderate()
460 send_mesg("moderate");
463 function moderate(enable)
466 moder_win = window.open("moderation.php", "moderation", "width=800,height=600,toolbar=no,location=no,menubar=no,status=no");
469 if (moder_win != null) {
477 function act_reloadroom()
479 window.onunload = null;
480 window.onbeforeunload = null;
481 document.location.assign("index.php");
485 function act_shutdown()
489 send_mesg("shutdown");
490 // while (xhr_wr.readyState != 4)
494 function postact_logout()
496 // alert("postact_logout");
501 // eraseCookie("sess");
502 document.location.assign("index.php");
506 function slowimg(img,x1,y1,deltat,free,action,srcend)
508 x1,y1 - destination coords
509 deltat - time for each frame (in msec)
510 free - when the release the local block for other operations (range: 0 - 1)
511 action - function to run when the image is moved
512 srcend - image to switch when the image is moved
515 function sleep(st, delay)
517 // alert("LOC_NEW PRE: "+st.st_loc_new);
521 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
525 function slowimg(img,x1,y1,deltat,free,action,srcend) {
528 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
529 this.x0 = parseInt(getStyle(this.img,"left", "left"));
530 // alert("img.x0 = "+this.x0);
531 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
532 this.y0 = parseInt(getStyle(this.img,"top", "top"));
535 this.deltat = deltat;
537 this.action = action;
538 this.srcend = srcend;
541 slowimg.prototype = {
560 setstart: function(x0,y0)
566 setaction: function(act)
572 settime: function(time)
574 this.time = (time < this.deltat ? this.deltat : time);
575 this.step_n = parseInt(this.time / this.deltat);
576 this.dx = (this.x1 - this.x0) / this.step_n;
577 this.dy = (this.y1 - this.y0) / this.step_n;
578 if (this.step_n * this.deltat == this.time) {
582 this.step_free = parseInt(this.step_n * this.free);
588 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
590 this.st.st_loc_new++;
592 this.img.style.visibility = "visible";
593 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
598 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
599 if (this.step_cur == 0) {
600 var date = new Date();
601 // $("logz").innerHTML = "Timestart: " + date + "<br>";
603 if (this.step_cur <= this.step_n) {
604 this.img.style.left = this.x0 + this.dx * this.step_cur;
605 this.img.style.top = this.y0 + this.dy * this.step_cur;
607 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
608 if (this.step_cur == this.step_free && this.st != null) {
609 if (this.st.st_loc < this.st.st_loc_new) {
610 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
617 this.img.style.left = this.x1;
618 this.img.style.top = this.y1;
619 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
620 var date = new Date();
621 // $("logz").innerHTML += "Timestop: " + date + "<br>";
623 if (this.action != null) {
627 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
632 if (this.srcend != null) {
633 this.img.src = this.srcend;
639 function div_show(div)
641 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
642 div.style.visibility = "visible";
645 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
652 this.ancestor = document.body;
654 this.st.st_loc_new++;
656 clo = document.createElement("input");
658 clo.className = "button";
659 clo.style.bottom = "4px";
661 if (block_time > 0) {
662 clo.value = "leggere, prego.";
667 clo.onclick = this.input_hide;
670 clodiv = document.createElement("div");
671 clodiv.className = "notify_clo";
673 this.clodiv = clodiv;
675 clodiv.appendChild(clo);
677 cont = document.createElement("div");
679 cont.style.borderBottomStyle = "solid";
680 cont.style.borderBottomWidth = "1px";
681 cont.style.borderBottomColor = "gray";
682 cont.style.height = (h - 30)+"px";
683 cont.style.overflow = "auto";
684 cont.innerHTML = text;
686 box = document.createElement("div");
688 box.className = "notify_opaque";
690 box.className = "notify";
692 box.style.zIndex = 200;
693 box.style.width = w+"px";
694 box.style.marginLeft = -parseInt(w/2)+"px";
695 box.style.height = h+"px";
696 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
697 box.appendChild(cont);
698 box.appendChild(clodiv);
699 box.style.visibility = "visible";
703 this.ancestor.appendChild(box);
705 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
707 if (block_time != 0) {
708 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);
718 notify_ex.prototype = {
730 if (this.st.st_loc < this.st.st_loc_new) {
737 clearTimeout(this.toutid);
738 this.ancestor.removeChild(this.notitag);
742 input_hide: function()
744 clearTimeout(this.obj.toutid);
745 this.obj.ancestor.removeChild(this.obj.notitag);
751 notify.prototype = notify_ex.prototype; // Define sub-class
752 notify.prototype.constructor = notify;
753 notify.baseConstructor = notify_ex;
754 notify.superClass = notify_ex.prototype;
756 function notify(st, text, tout, butt, w, h)
758 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
763 return document.getElementById(id);
770 this.st_loc_new = -1;
771 this.comms = new Array;
781 sleep: function(delay) {
785 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
791 if (this.sleep_hdl != null) {
792 clearTimeout(this.sleep_hdl);
793 this.sleep_hdl = null;
798 function remark_step()
800 var ct = $("remark").l_remct;
806 $("remark").className = "remark"+ct;
807 $("remark").l_remct = ct;
808 setTimeout(remark_step,500);
811 $("remark").className = "remark0";
818 if ($("remark").l_remct == 0) {
819 $("remark").l_remct = 1;
820 setTimeout(remark_step,500);
824 function remark_off()
826 $("remark").l_remct = 0;
827 $("remark").className = "remark0";
831 function italizer(ga)
835 return "<i>"+ga[1]+"</i>";
841 function exitlock_show(num, islock)
845 num = (num < 3 ? num : 3);
846 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
847 // alert("EXITLOCK: "+$("exitlock").src);
848 $("exitlock").style.visibility = "visible";
853 // exitlock_show(0, true);
856 var chatt_lines = new Array();
857 var chatt_lines_n = 0;
859 var CHATT_MAXLINES = 40;
861 function user_decorator(user)
864 var flags = user[BSK_USER_FLAGS];
865 var flags_vlt = user[BSK_USER_FLGVL];
866 if ((flags & 0x03) != 0)
867 name = "<span class='au" + (flags & 0x03) + "'>"+user[BSK_USER_NICK]+"</span>";
869 name = user[BSK_USER_NICK];
874 function user_dec_and_state(el)
879 content = user_decorator(el);
880 content += state_add(el[BSK_USER_FLAGS], el[BSK_USER_FLGVL],
881 (typeof(el[BSK_USER_SCOL]) != 'undefined' ? el[BSK_USER_SCOL] : null));
888 function chatt_sub(dt,data,str)
890 var must_scroll = false;
894 var bolder = [ (data[BSK_USER_FLAGS] | 1), data[BSK_USER_FLGVL], data[BSK_USER_NICK] ];
895 name = user_decorator(bolder);
897 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
900 // alert("ARRIVA NAME: "+ name + " STR:"+str);
901 if (chatt_lines_n == CHATT_MAXLINES) {
902 $("txt").innerHTML = "";
903 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
904 chatt_lines[i] = chatt_lines[i+1];
905 $("txt").innerHTML += chatt_lines[i];
907 chatt_lines[i] = dt+name+": "+str+ "<br>";
908 $("txt").innerHTML += chatt_lines[i];
911 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
912 $("txt").innerHTML += chatt_lines[chatt_lines_n];
915 // $("txt").innerHTML;
919 $("txt").scrollTop = 10000000;
921 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
925 * GESTIONE DEI COOKIES
927 function createCookie(name,value,hours,path) {
929 var date = new Date();
930 date.setTime(date.getTime()+(hours*60*60*1000));
931 var expires = "; expires="+date.toGMTString();
933 else var expires = "";
934 document.cookie = name+"="+value+expires+"; path="+path;
937 function readCookie(name) {
938 var nameEQ = name + "=";
939 var ca = document.cookie.split(';');
940 for(var i=0;i < ca.length;i++) {
942 while (c.charAt(0)==' ') c = c.substring(1,c.length);
943 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
948 function eraseCookie(name) {
949 createCookie(name,"",-1);
952 function onbeforeunload_cb () {
956 function onunload_cb () {
958 if (typeof(hstm) != "undefined")
966 function room_checkspace(emme,tables,inpe)
969 for (i = 0 ; i < emme ; i++)
974 for (i = 0 ; i < 5 ; i++)
977 for (i = 0 ; i < tables ; i++) {
978 $("table"+i).innerHTML = alta;
980 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
983 stand = "<table class=\"table_standup\"><tbody><tr>";
984 for (i = 0 ; i < inpe ; i++) {
985 stand += "<td>"+nome+"</td>";
986 if ((i+1) % 4 == 0) {
987 stand += "</tr><tr>";
991 $("standup").innerHTML = stand;
993 // VERIFY: what is this button ?
995 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
998 function unescapeHTML(cont) {
999 var div = document.createElement('div');
1003 div.innerHTML = cont;
1004 if (div.childNodes[0]) {
1005 if (div.childNodes.length > 1) {
1006 if (div.childNodes.toArray)
1009 var length = div.childNodes.length, results = new Array(length);
1011 results[length] = div.childNodes[length];
1013 for (i=0 ; i<results.length ; i++)
1014 memo = memo + results[i].nodeValue;
1020 return (div.childNodes[0].nodeValue);
1028 function playsound(tag, sound) {
1029 // g_withflash is a global var
1031 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
1032 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
1033 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
1034 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
1035 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
1036 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
1040 function topbanner_init()
1042 setInterval(topbanner_cb, 666);
1046 function topbanner_cb()
1050 a = $('topbanner').style.backgroundColor;
1051 b = $('topbanner').style.borderLeftColor;
1053 $('topbanner').style.backgroundColor = b;
1054 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1056 // console.log("A: "+a+" B: "+b);
1059 function sidebanner_init()
1061 setInterval(sidebanner_cb, 666);
1064 function sidebanner2_init()
1066 setInterval(sidebanner2_cb, 666);
1069 function sidebanner_cb()
1073 a = $('sidebanner').style.backgroundColor;
1074 b = $('sidebanner').style.borderLeftColor;
1076 $('sidebanner').style.backgroundColor = b;
1077 $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
1079 // console.log("A: "+a+" B: "+b);
1082 function sidebanner2_cb()
1086 a = $('sidebanner2').style.backgroundColor;
1087 b = $('sidebanner2').style.borderLeftColor;
1089 $('sidebanner2').style.backgroundColor = b;
1090 $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
1092 // console.log("A: "+a+" B: "+b);
1096 function langtolng(lang)
1104 function formtext_hilite(obj)
1106 obj.className = 'input_text';
1107 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1108 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1111 function formsub_hilite(obj)
1113 obj.className = 'input_sub';
1114 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1115 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1118 // return the value of the radio button that is checked
1119 // return an empty string if none are checked, or
1120 // there are no radio buttons
1121 function get_checked_value(radioObj) {
1124 var radioLength = radioObj.length;
1125 if(radioLength == undefined)
1126 if(radioObj.checked)
1127 return radioObj.value;
1130 for(var i = 0; i < radioLength; i++) {
1131 if(radioObj[i].checked) {
1132 return radioObj[i].value;
1138 // set the radio button with the given value as being checked
1139 // do nothing if there are no radio buttons
1140 // if the given value does not exist, all the radio buttons
1141 // are reset to unchecked
1142 function set_checked_value(radioObj, newValue) {
1145 var radioLength = radioObj.length;
1146 if(radioLength == undefined) {
1147 radioObj.checked = (radioObj.value == newValue.toString());
1150 for(var i = 0; i < radioLength; i++) {
1151 radioObj[i].checked = false;
1152 if(radioObj[i].value == newValue.toString()) {
1153 radioObj[i].checked = true;
1158 function url_append_arg(url, name, value)
1160 var pos, sep, pref, rest;
1162 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1163 pos = url.indexOf('&'+name+'=');
1166 if ((pos = url.indexOf('?')) != -1)
1171 return (url+sep+name+"="+encodeURIComponent(value));
1174 pref = url.substring(0, pos+1);
1175 rest = url.substring(pos+1);
1176 // alert("rest: "+rest+" pos: "+pos);
1177 if ((pos = rest.indexOf('&')) != -1) {
1178 rest = rest.substring(pos);
1183 return (pref+name+"="+encodeURIComponent(value)+rest);
1187 function url_append_args(url)
1192 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1193 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1199 function url_complete(parent, url)
1202 var host = "", path = "";
1205 p = parent.indexOf("://");
1207 rest = parent.substring(p+3);
1208 p2 = rest.indexOf("/");
1210 host = parent.substring(0, p+3+p2);
1211 rest = parent.substring(p+3+p2);
1223 p = rest.lastIndexOf("/");
1225 path = rest.substring(0, p+1);
1228 // alert("host: ["+host+"] path: ["+path+"]");
1229 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') {
1232 else if (url.substring(0,1) == '/') {
1236 return (host+path+url);