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') {
285 var ldate = new Date();
286 console.log(ldate.getTime()+':MESG:'+mesg);
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 var moder_win = null;
461 function act_moderate()
463 send_mesg("moderate");
466 function moderate(enable)
469 moder_win = window.open("moderation.php", "moderation", "width=800,height=600,toolbar=no,location=no,menubar=no,status=no");
472 if (moder_win != null) {
480 function act_reloadroom()
482 window.onunload = null;
483 window.onbeforeunload = null;
484 document.location.assign("index.php");
488 function act_shutdown()
492 send_mesg("shutdown");
493 // while (xhr_wr.readyState != 4)
497 function postact_logout()
499 // alert("postact_logout");
504 // eraseCookie("sess");
505 document.location.assign("index.php");
509 function slowimg(img,x1,y1,deltat,free,action,srcend)
511 x1,y1 - destination coords
512 deltat - time for each frame (in msec)
513 free - when the release the local block for other operations (range: 0 - 1)
514 action - function to run when the image is moved
515 srcend - image to switch when the image is moved
518 function sleep(st, delay)
520 // alert("LOC_NEW PRE: "+st.st_loc_new);
524 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
528 function slowimg(img,x1,y1,deltat,free,action,srcend) {
531 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
532 this.x0 = parseInt(getStyle(this.img,"left", "left"));
533 // alert("img.x0 = "+this.x0);
534 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
535 this.y0 = parseInt(getStyle(this.img,"top", "top"));
538 this.deltat = deltat;
540 this.action = action;
541 this.srcend = srcend;
544 slowimg.prototype = {
563 setstart: function(x0,y0)
569 setaction: function(act)
575 settime: function(time)
577 this.time = (time < this.deltat ? this.deltat : time);
578 this.step_n = parseInt(this.time / this.deltat);
579 this.dx = (this.x1 - this.x0) / this.step_n;
580 this.dy = (this.y1 - this.y0) / this.step_n;
581 if (this.step_n * this.deltat == this.time) {
585 this.step_free = parseInt(this.step_n * this.free);
591 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
593 this.st.st_loc_new++;
595 this.img.style.visibility = "visible";
596 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
601 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
602 if (this.step_cur == 0) {
603 var date = new Date();
604 // $("logz").innerHTML = "Timestart: " + date + "<br>";
606 if (this.step_cur <= this.step_n) {
607 this.img.style.left = this.x0 + this.dx * this.step_cur;
608 this.img.style.top = this.y0 + this.dy * this.step_cur;
610 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
611 if (this.step_cur == this.step_free && this.st != null) {
612 if (this.st.st_loc < this.st.st_loc_new) {
613 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
620 this.img.style.left = this.x1;
621 this.img.style.top = this.y1;
622 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
623 var date = new Date();
624 // $("logz").innerHTML += "Timestop: " + date + "<br>";
626 if (this.action != null) {
630 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
635 if (this.srcend != null) {
636 this.img.src = this.srcend;
642 function div_show(div)
644 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
645 div.style.visibility = "visible";
648 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
655 this.ancestor = document.body;
657 this.st.st_loc_new++;
659 clo = document.createElement("input");
661 clo.className = "button";
662 clo.style.bottom = "4px";
664 if (block_time > 0) {
665 clo.value = "leggere, prego.";
670 clo.onclick = this.input_hide;
673 clodiv = document.createElement("div");
674 clodiv.className = "notify_clo";
676 this.clodiv = clodiv;
678 clodiv.appendChild(clo);
680 cont = document.createElement("div");
682 cont.style.borderBottomStyle = "solid";
683 cont.style.borderBottomWidth = "1px";
684 cont.style.borderBottomColor = "gray";
685 cont.style.height = (h - 30)+"px";
686 cont.style.overflow = "auto";
687 cont.innerHTML = text;
689 box = document.createElement("div");
691 box.className = "notify_opaque";
693 box.className = "notify";
695 box.style.zIndex = 200;
696 box.style.width = w+"px";
697 box.style.marginLeft = -parseInt(w/2)+"px";
698 box.style.height = h+"px";
699 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
700 box.appendChild(cont);
701 box.appendChild(clodiv);
702 box.style.visibility = "visible";
706 this.ancestor.appendChild(box);
708 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
710 if (block_time != 0) {
711 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);
721 notify_ex.prototype = {
733 if (this.st.st_loc < this.st.st_loc_new) {
740 clearTimeout(this.toutid);
741 this.ancestor.removeChild(this.notitag);
745 input_hide: function()
747 clearTimeout(this.obj.toutid);
748 this.obj.ancestor.removeChild(this.obj.notitag);
754 notify.prototype = notify_ex.prototype; // Define sub-class
755 notify.prototype.constructor = notify;
756 notify.baseConstructor = notify_ex;
757 notify.superClass = notify_ex.prototype;
759 function notify(st, text, tout, butt, w, h)
761 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
766 return document.getElementById(id);
773 this.st_loc_new = -1;
774 this.comms = new Array;
784 sleep: function(delay) {
788 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
794 if (this.sleep_hdl != null) {
795 clearTimeout(this.sleep_hdl);
796 this.sleep_hdl = null;
801 function remark_step()
803 var ct = $("remark").l_remct;
809 $("remark").className = "remark"+ct;
810 $("remark").l_remct = ct;
811 setTimeout(remark_step,500);
814 $("remark").className = "remark0";
821 if ($("remark").l_remct == 0) {
822 $("remark").l_remct = 1;
823 setTimeout(remark_step,500);
827 function remark_off()
829 $("remark").l_remct = 0;
830 $("remark").className = "remark0";
834 function italizer(ga)
838 return "<i>"+ga[1]+"</i>";
844 function exitlock_show(num, islock)
848 num = (num < 3 ? num : 3);
849 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
850 // alert("EXITLOCK: "+$("exitlock").src);
851 $("exitlock").style.visibility = "visible";
856 // exitlock_show(0, true);
859 var chatt_lines = new Array();
860 var chatt_lines_n = 0;
862 var CHATT_MAXLINES = 40;
864 function user_decorator(user)
867 var flags = user[BSK_USER_FLAGS];
868 var flags_vlt = user[BSK_USER_FLGVL];
869 if ((flags & 0x03) != 0)
870 name = "<span class='au" + (flags & 0x03) + "'>"+user[BSK_USER_NICK]+"</span>";
872 name = user[BSK_USER_NICK];
877 function user_dec_and_state(el)
882 content = user_decorator(el);
883 content += state_add(el[BSK_USER_FLAGS], el[BSK_USER_FLGVL],
884 (typeof(el[BSK_USER_SCOL]) != 'undefined' ? el[BSK_USER_SCOL] : null));
891 function chatt_sub(dt,data,str)
893 var must_scroll = false;
897 var bolder = [ (data[BSK_USER_FLAGS] | 1), data[BSK_USER_FLGVL], data[BSK_USER_NICK] ];
898 name = user_decorator(bolder);
900 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
903 // alert("ARRIVA NAME: "+ name + " STR:"+str);
904 if (chatt_lines_n == CHATT_MAXLINES) {
905 $("txt").innerHTML = "";
906 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
907 chatt_lines[i] = chatt_lines[i+1];
908 $("txt").innerHTML += chatt_lines[i];
910 chatt_lines[i] = dt+name+": "+str+ "<br>";
911 $("txt").innerHTML += chatt_lines[i];
914 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
915 $("txt").innerHTML += chatt_lines[chatt_lines_n];
918 // $("txt").innerHTML;
922 $("txt").scrollTop = 10000000;
924 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
928 * GESTIONE DEI COOKIES
930 function createCookie(name,value,hours,path) {
932 var date = new Date();
933 date.setTime(date.getTime()+(hours*60*60*1000));
934 var expires = "; expires="+date.toGMTString();
936 else var expires = "";
937 document.cookie = name+"="+value+expires+"; path="+path;
940 function readCookie(name) {
941 var nameEQ = name + "=";
942 var ca = document.cookie.split(';');
943 for(var i=0;i < ca.length;i++) {
945 while (c.charAt(0)==' ') c = c.substring(1,c.length);
946 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
951 function eraseCookie(name) {
952 createCookie(name,"",-1);
955 function onbeforeunload_cb () {
959 function onunload_cb () {
961 if (typeof(hstm) != "undefined")
969 function room_checkspace(emme,tables,inpe)
972 for (i = 0 ; i < emme ; i++)
977 for (i = 0 ; i < 5 ; i++)
980 for (i = 0 ; i < tables ; i++) {
981 $("table"+i).innerHTML = alta;
983 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
986 stand = "<table class=\"table_standup\"><tbody><tr>";
987 for (i = 0 ; i < inpe ; i++) {
988 stand += "<td>"+nome+"</td>";
989 if ((i+1) % 4 == 0) {
990 stand += "</tr><tr>";
994 $("standup").innerHTML = stand;
996 // VERIFY: what is this button ?
998 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
1001 function unescapeHTML(cont) {
1002 var div = document.createElement('div');
1006 div.innerHTML = cont;
1007 if (div.childNodes[0]) {
1008 if (div.childNodes.length > 1) {
1009 if (div.childNodes.toArray)
1012 var length = div.childNodes.length, results = new Array(length);
1014 results[length] = div.childNodes[length];
1016 for (i=0 ; i<results.length ; i++)
1017 memo = memo + results[i].nodeValue;
1023 return (div.childNodes[0].nodeValue);
1031 function playsound(tag, sound) {
1032 // g_withflash is a global var
1034 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
1035 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
1036 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
1037 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
1038 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
1039 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
1043 function topbanner_init()
1045 setInterval(topbanner_cb, 666);
1049 function topbanner_cb()
1053 a = $('topbanner').style.backgroundColor;
1054 b = $('topbanner').style.borderLeftColor;
1056 $('topbanner').style.backgroundColor = b;
1057 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1059 // console.log("A: "+a+" B: "+b);
1062 function sidebanner_init()
1064 setInterval(sidebanner_cb, 666);
1067 function sidebanner2_init()
1069 setInterval(sidebanner2_cb, 666);
1072 function sidebanner_cb()
1076 a = $('sidebanner').style.backgroundColor;
1077 b = $('sidebanner').style.borderLeftColor;
1079 $('sidebanner').style.backgroundColor = b;
1080 $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
1082 // console.log("A: "+a+" B: "+b);
1085 function sidebanner2_cb()
1089 a = $('sidebanner2').style.backgroundColor;
1090 b = $('sidebanner2').style.borderLeftColor;
1092 $('sidebanner2').style.backgroundColor = b;
1093 $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
1095 // console.log("A: "+a+" B: "+b);
1099 function langtolng(lang)
1107 function formtext_hilite(obj)
1109 obj.className = 'input_text';
1110 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1111 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1114 function formsub_hilite(obj)
1116 obj.className = 'input_sub';
1117 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1118 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1121 // return the value of the radio button that is checked
1122 // return an empty string if none are checked, or
1123 // there are no radio buttons
1124 function get_checked_value(radioObj) {
1127 var radioLength = radioObj.length;
1128 if(radioLength == undefined)
1129 if(radioObj.checked)
1130 return radioObj.value;
1133 for(var i = 0; i < radioLength; i++) {
1134 if(radioObj[i].checked) {
1135 return radioObj[i].value;
1141 // set the radio button with the given value as being checked
1142 // do nothing if there are no radio buttons
1143 // if the given value does not exist, all the radio buttons
1144 // are reset to unchecked
1145 function set_checked_value(radioObj, newValue) {
1148 var radioLength = radioObj.length;
1149 if(radioLength == undefined) {
1150 radioObj.checked = (radioObj.value == newValue.toString());
1153 for(var i = 0; i < radioLength; i++) {
1154 radioObj[i].checked = false;
1155 if(radioObj[i].value == newValue.toString()) {
1156 radioObj[i].checked = true;
1161 function url_append_arg(url, name, value)
1163 var pos, sep, pref, rest;
1165 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1166 pos = url.indexOf('&'+name+'=');
1169 if ((pos = url.indexOf('?')) != -1)
1174 return (url+sep+name+"="+encodeURIComponent(value));
1177 pref = url.substring(0, pos+1);
1178 rest = url.substring(pos+1);
1179 // alert("rest: "+rest+" pos: "+pos);
1180 if ((pos = rest.indexOf('&')) != -1) {
1181 rest = rest.substring(pos);
1186 return (pref+name+"="+encodeURIComponent(value)+rest);
1190 function url_append_args(url)
1195 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1196 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1202 function url_complete(parent, url)
1205 var host = "", path = "";
1208 p = parent.indexOf("://");
1210 rest = parent.substring(p+3);
1211 p2 = rest.indexOf("/");
1213 host = parent.substring(0, p+3+p2);
1214 rest = parent.substring(p+3+p2);
1226 p = rest.lastIndexOf("/");
1228 path = rest.substring(0, p+1);
1231 // alert("host: ["+host+"] path: ["+path+"]");
1232 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') {
1235 else if (url.substring(0,1) == '/') {
1239 return (host+path+url);