4 * Copyright (C) 2006-2012 Matteo Nastasi
5 * mailto: nastasi@alternativeoutput.it
6 * matteo.nastasi@milug.org
7 * web: http://www.alternativeoutput.it
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. You should have received a
18 * copy of the GNU General Public License along with this program; if
19 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
20 * Suite 330, Boston, MA 02111-1307, USA.
25 var EXIT_BAN_TIME = 3600;
26 var cookiepath = "/brisk/";
28 var mlang_commons = { 'imgload_a' : { 'it' : 'Immagine caricate ',
29 'en' : 'Loaded images ' },
30 'imgload_b' : { 'it' : '%.',
32 'gamleav' : { 'it' : 'Sei sicuro di volere lasciare questa mano?' ,
33 'en' : 'Are you sure to leave this game?' },
34 'brileav' : { 'it' : ' Vuoi veramente abbandonare la briscola ?\n(clicca annulla o cancel se vuoi ricaricare la briscola)',
35 'en' : ' Are you really sure to leave briscola ?\n(click cancel yo reload it)' },
36 'brireco' : { 'it' : 'Ripristino della briscola fallito, per non perdere la sessione ricaricare la pagina manualmente.',
37 'en' : 'Recovery of briscola failed, to keep the current session reload the page manually.' },
38 'btn_sit' : { 'it' : 'Mi siedo.',
40 'btn_exit' : { 'it' : 'Esco.',
42 'tit_list' : { '0' : { 'it' : '',
44 '1' : { 'it' : '(solo aut.)',
45 'en' : '(only aut.)' },
46 '2' : { 'it' : '(isolam.to)',
47 'en' : '(isolation)' } }
50 function $(id) { return document.getElementById(id); }
52 function getStyle(x,IEstyleProp, MozStyleProp)
55 var y = x.currentStyle[IEstyleProp];
56 } else if (window.getComputedStyle) {
57 var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
62 /* replacement of setInterval on IE */
64 /*if not IE, do nothing*/
65 if(!document.uniqueID){return;};
67 /*Copy the default setInterval behavior*/
68 var nativeSetInterval = window.setInterval;
69 window.setInterval = function(fn,ms) {
71 if(arguments.length <= 2) {
72 return nativeSetInterval(fn,ms);
75 for(var i=2;i<arguments.length;i+=1) {
76 param[i-2] = arguments[i];
80 if(typeof(fn)=='function') {
82 return (function (fn,ms,param) {
83 var fo = function () {
84 fn.apply(window,param);
86 return nativeSetInterval(fo,ms);
89 else if(typeof(fn)=='string')
91 return nativeSetInterval(fn,ms);
95 throw Error('setInterval Error\nInvalid function type');
99 /*Copy the default setTimeout behavior*/
100 var nativeSetTimeout = window.setTimeout;
101 window.setTimeout = function(fn,ms) {
103 if(arguments.length <= 2) {
104 return nativeSetTimeout(fn,ms);
107 for(var i=2;i<arguments.length;i+=1) {
108 param[i-2] = arguments[i];
112 if(typeof(fn)=='function') {
114 return (function (fn,ms,param) {
115 var fo = function () {
116 fn.apply(window,param);
118 return nativeSetTimeout(fo,ms);
121 else if(typeof(fn)=='string')
123 return nativeSetTimeout(fn,ms);
127 throw Error('setTimeout Error\nInvalid function type');
133 function addEvent(obj,type,fn)
135 if (obj.addEventListener) {
136 obj.addEventListener( type, fn, false);
138 else if (obj.attachEvent) {
139 obj["e"+type+fn] = fn;
140 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
141 obj.attachEvent( "on"+type, obj[type+fn] );
144 throw new Error("Event registration not supported");
147 function removeEvent(obj,type,fn)
149 if (obj.removeEventListener) {
150 obj.removeEventListener( type, fn, false );
152 else if (obj.detachEvent) {
153 obj.detachEvent( "on"+type, obj[type+fn] );
155 obj["e"+type+fn] = null;
159 // var card_pos = RANGE 0 <= x < cards_ea_n
161 function show_bigpict(obj, act, x, y)
165 if (arguments.length > 4)
170 big = $(obj.id+"_big"+sfx);
172 big.style.left = obj.offsetLeft + x+"px";
173 big.style.top = obj.offsetTop + y+"px";
174 big.style.visibility = "visible";
177 big.style.visibility = "hidden";
181 function rnd_int(min, max) {
182 return Math.floor(Math.random() * (max - min + 1) + min);
185 function error_images()
187 // alert("GHESEMU!");
188 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
191 function abort_images()
193 // alert("ABORTAIMAGES");
194 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
197 function unload_images()
199 // alert("ABORTAIMAGES");
200 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
203 function reset_images()
205 // alert("ABORTAIMAGES");
206 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
209 function update_images()
211 // MLANG "Immagine caricate" + g_preload_imgsz_arr[g_imgct] + "%."
212 $("imgct").innerHTML = mlang_commons['imgload_a'][g_lang]+g_preload_imgsz_arr[g_imgct]+"%.";
213 if (g_imgct+1 < g_preload_img_arr.length) {
215 setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
217 // $("imgct").innerHTML += "U";
220 function preload_images(arr,idx)
224 // $("imgct").innerHTML = "Stiamo caricando "+arr[idx]+"%.<br>";
225 im.onload = update_images;
226 im.onerror = error_images;
227 im.onabort = abort_images;
228 im.onunload = unload_images;
229 im.onreset = reset_images;
231 // $("imgct").innerHTML += "P";
234 function safestatus(a)
242 function createXMLHttpRequest() {
243 if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
244 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
245 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
247 try { return new XMLHttpRequest(); } catch(e) {}
248 alert("XMLHttpRequest not supported");
252 function send_mesg(mesg)
254 var xhr_wr = createXMLHttpRequest();
255 var is_conn = (sess == "not_connected" ? false : true);
257 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
258 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
259 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
260 xhr_wr.onreadystatechange = function() { return; };
261 if (typeof(g_debug) == 'number' && g_debug > 0
262 && typeof(console) == 'object' && typeof(console.log) == 'function') {
263 var ldate = new Date();
264 console.log(ldate.getTime()+':MESG:'+mesg);
269 if (xhr_wr.responseText != null) {
270 eval(xhr_wr.responseText);
276 sync request to server
277 server_request([arg0=arg1[, arg2=arg3[, ...]]])
278 if var name == '__POST__' than all other vars will be managed as POST content
279 and the call will be a POST
281 function server_request()
283 var xhr_wr = createXMLHttpRequest();
284 var i, collect = "", post_collect = null, is_post = false;
286 if (arguments.length > 0) {
287 for (i = 0 ; i < arguments.length ; i+= 2) {
288 if (arguments[i] == "__POST__") {
295 post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
297 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
300 // alert("Args: "+arguments.length);
302 var is_conn = (sess == "not_connected" ? false : true);
304 // console.log("server_request:preresp: "+xhr_wr.responseText);
307 xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
308 xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
311 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
313 xhr_wr.onreadystatechange = function() { return; };
314 xhr_wr.send(post_collect);
316 if (xhr_wr.responseText != null) {
317 // console.log("server_request:resp: "+xhr_wr.responseText);
318 return (xhr_wr.responseText);
324 /* Stat: CHAT and TABLE */
326 function chatt_checksend(obj,e)
332 if(window.event) { // IE
335 else if(e.which) { // Netscape/Firefox/Opera
338 // alert("OBJ: "+obj);
339 if (keynum == 13 && obj.value != "") { // Enter
340 act_chatt(obj.value);
344 function act_chatt(value)
346 send_mesg("chatt|"+encodeURIComponent(value));
350 obj.disabled = false;
362 function act_sitdown(table)
364 send_mesg("sitdown|"+table);
367 function act_wakeup()
372 function act_splash()
382 function act_passwdhowto()
384 send_mesg("passwdhowto");
387 function act_mesgtoadm()
389 send_mesg("mesgtoadm");
394 act_chatt('/tav '+$('txt_in').value);
395 $('txt_in').value = '';
403 function act_placing()
405 send_mesg("placing");
408 function act_roadmap()
410 send_mesg("roadmap");
413 function act_whysupport()
415 send_mesg("whysupport");
418 function act_lascio()
423 function safelascio()
426 // MLANG "Sei sicuro di volere lasciare questa mano?"
427 res = window.confirm(mlang_commons['gamleav'][g_lang]);
432 function act_logout(exitlock)
434 send_mesg("logout|"+exitlock);
437 function act_reloadroom()
439 window.onunload = null;
440 window.onbeforeunload = null;
441 document.location.assign("index.php");
444 function act_shutdown()
448 send_mesg("shutdown");
449 // while (xhr_wr.readyState != 4)
453 function postact_logout()
455 // alert("postact_logout");
460 // eraseCookie("sess");
461 document.location.assign("index.php");
465 function slowimg(img,x1,y1,deltat,free,action,srcend)
467 x1,y1 - destination coords
468 deltat - time for each frame (in msec)
469 free - when the release the local block for other operations (range: 0 - 1)
470 action - function to run when the image is moved
471 srcend - image to switch when the image is moved
474 function sleep(st, delay)
476 // alert("LOC_NEW PRE: "+st.st_loc_new);
480 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
484 function slowimg(img,x1,y1,deltat,free,action,srcend) {
487 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
488 this.x0 = parseInt(getStyle(this.img,"left", "left"));
489 // alert("img.x0 = "+this.x0);
490 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
491 this.y0 = parseInt(getStyle(this.img,"top", "top"));
494 this.deltat = deltat;
496 this.action = action;
497 this.srcend = srcend;
500 slowimg.prototype = {
519 setstart: function(x0,y0)
525 setaction: function(act)
531 settime: function(time)
533 this.time = (time < this.deltat ? this.deltat : time);
534 this.step_n = parseInt(this.time / this.deltat);
535 this.dx = (this.x1 - this.x0) / this.step_n;
536 this.dy = (this.y1 - this.y0) / this.step_n;
537 if (this.step_n * this.deltat == this.time) {
541 this.step_free = parseInt(this.step_n * this.free);
547 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
549 this.st.st_loc_new++;
551 this.img.style.visibility = "visible";
552 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
557 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
558 if (this.step_cur == 0) {
559 var date = new Date();
560 // $("logz").innerHTML = "Timestart: " + date + "<br>";
562 if (this.step_cur <= this.step_n) {
563 this.img.style.left = this.x0 + this.dx * this.step_cur;
564 this.img.style.top = this.y0 + this.dy * this.step_cur;
566 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
567 if (this.step_cur == this.step_free && this.st != null) {
568 if (this.st.st_loc < this.st.st_loc_new) {
569 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
576 this.img.style.left = this.x1;
577 this.img.style.top = this.y1;
578 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
579 var date = new Date();
580 // $("logz").innerHTML += "Timestop: " + date + "<br>";
582 if (this.action != null) {
586 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
591 if (this.srcend != null) {
592 this.img.src = this.srcend;
598 function div_show(div)
600 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
601 div.style.visibility = "visible";
604 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
611 this.ancestor = document.body;
613 this.st.st_loc_new++;
615 clo = document.createElement("input");
617 clo.className = "button";
618 clo.style.bottom = "4px";
620 if (block_time > 0) {
621 clo.value = "leggere, prego.";
626 clo.onclick = this.input_hide;
629 clodiv = document.createElement("div");
630 clodiv.className = "notify_clo";
632 this.clodiv = clodiv;
634 clodiv.appendChild(clo);
636 cont = document.createElement("div");
638 cont.style.borderBottomStyle = "solid";
639 cont.style.borderBottomWidth = "1px";
640 cont.style.borderBottomColor = "gray";
641 cont.style.height = (h - 30)+"px";
642 cont.style.overflow = "auto";
643 cont.innerHTML = text;
645 box = document.createElement("div");
647 box.className = "notify_opaque";
649 box.className = "notify";
651 box.style.zIndex = 200;
652 box.style.width = w+"px";
653 box.style.marginLeft = -parseInt(w/2)+"px";
654 box.style.height = h+"px";
655 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
656 box.appendChild(cont);
657 box.appendChild(clodiv);
658 box.style.visibility = "visible";
662 this.ancestor.appendChild(box);
664 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
666 if (block_time != 0) {
667 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);
677 notify_ex.prototype = {
689 if (this.st.st_loc < this.st.st_loc_new) {
696 clearTimeout(this.toutid);
697 this.ancestor.removeChild(this.notitag);
701 input_hide: function()
703 clearTimeout(this.obj.toutid);
704 this.obj.ancestor.removeChild(this.obj.notitag);
710 notify.prototype = notify_ex.prototype; // Define sub-class
711 notify.prototype.constructor = notify;
712 notify.baseConstructor = notify_ex;
713 notify.superClass = notify_ex.prototype;
715 function notify(st, text, tout, butt, w, h)
717 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
722 return document.getElementById(id);
729 this.st_loc_new = -1;
730 this.comms = new Array;
740 sleep: function(delay) {
744 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
750 if (this.sleep_hdl != null) {
751 clearTimeout(this.sleep_hdl);
752 this.sleep_hdl = null;
757 function remark_step()
759 var ct = $("remark").l_remct;
765 $("remark").className = "remark"+ct;
766 $("remark").l_remct = ct;
767 setTimeout(remark_step,500);
770 $("remark").className = "remark0";
777 if ($("remark").l_remct == 0) {
778 $("remark").l_remct = 1;
779 setTimeout(remark_step,500);
783 function remark_off()
785 $("remark").l_remct = 0;
786 $("remark").className = "remark0";
790 function italizer(ga)
794 return "<i>"+ga[1]+"</i>";
800 function exitlock_show(num, islock)
804 num = (num < 3 ? num : 3);
805 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
806 // alert("EXITLOCK: "+$("exitlock").src);
807 $("exitlock").style.visibility = "visible";
812 // exitlock_show(0, true);
815 var chatt_lines = new Array();
816 var chatt_lines_n = 0;
818 var CHATT_MAXLINES = 40;
820 function user_decorator(user)
824 if ((flags & 0x03) != 0)
825 name = "<span class='au" + (flags & 0x03) + "'>"+user[1]+"</span>";
832 function user_dec_and_state(el)
837 content = user_decorator(el);
838 content += state_add(el[0]);
845 function chatt_sub(dt,data,str)
847 var must_scroll = false;
851 var bolder = [ (data[0] | 1), data[1] ];
852 name = user_decorator(bolder);
854 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
857 // alert("ARRIVA NAME: "+ name + " STR:"+str);
858 if (chatt_lines_n == CHATT_MAXLINES) {
859 $("txt").innerHTML = "";
860 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
861 chatt_lines[i] = chatt_lines[i+1];
862 $("txt").innerHTML += chatt_lines[i];
864 chatt_lines[i] = dt+name+": "+str+ "<br>";
865 $("txt").innerHTML += chatt_lines[i];
868 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
869 $("txt").innerHTML += chatt_lines[chatt_lines_n];
872 // $("txt").innerHTML;
876 $("txt").scrollTop = 10000000;
878 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
882 * GESTIONE DEI COOKIES
884 function createCookie(name,value,hours,path) {
886 var date = new Date();
887 date.setTime(date.getTime()+(hours*60*60*1000));
888 var expires = "; expires="+date.toGMTString();
890 else var expires = "";
891 document.cookie = name+"="+value+expires+"; path="+path;
894 function readCookie(name) {
895 var nameEQ = name + "=";
896 var ca = document.cookie.split(';');
897 for(var i=0;i < ca.length;i++) {
899 while (c.charAt(0)==' ') c = c.substring(1,c.length);
900 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
905 function eraseCookie(name) {
906 createCookie(name,"",-1);
909 function onbeforeunload_cb () {
913 function onunload_cb () {
915 if (typeof(hstm) != "undefined")
923 function room_checkspace(emme,tables,inpe)
926 for (i = 0 ; i < emme ; i++)
931 for (i = 0 ; i < 5 ; i++)
934 for (i = 0 ; i < tables ; i++) {
935 $("table"+i).innerHTML = alta;
937 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
940 stand = "<table class=\"table_standup\"><tbody><tr>";
941 for (i = 0 ; i < inpe ; i++) {
942 stand += "<td>"+nome+"</td>";
943 if ((i+1) % 4 == 0) {
944 stand += "</tr><tr>";
948 $("standup").innerHTML = stand;
950 // VERIFY: what is this button ?
952 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
955 function unescapeHTML(cont) {
956 var div = document.createElement('div');
960 div.innerHTML = cont;
961 if (div.childNodes[0]) {
962 if (div.childNodes.length > 1) {
963 if (div.childNodes.toArray)
966 var length = div.childNodes.length, results = new Array(length);
968 results[length] = div.childNodes[length];
970 for (i=0 ; i<results.length ; i++)
971 memo = memo + results[i].nodeValue;
977 return (div.childNodes[0].nodeValue);
985 function playsound(tag, sound) {
986 // g_withflash is a global var
988 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
989 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
990 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
991 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
992 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
993 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
997 function topbanner_init()
999 setInterval(topbanner_cb, 666);
1003 function topbanner_cb()
1007 a = $('topbanner').style.backgroundColor;
1008 b = $('topbanner').style.borderLeftColor;
1010 $('topbanner').style.backgroundColor = b;
1011 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1013 // console.log("A: "+a+" B: "+b);
1016 function sidebanner_init()
1018 setInterval(sidebanner_cb, 666);
1021 function sidebanner2_init()
1023 setInterval(sidebanner2_cb, 666);
1026 function sidebanner_cb()
1030 a = $('sidebanner').style.backgroundColor;
1031 b = $('sidebanner').style.borderLeftColor;
1033 $('sidebanner').style.backgroundColor = b;
1034 $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
1036 // console.log("A: "+a+" B: "+b);
1039 function sidebanner2_cb()
1043 a = $('sidebanner2').style.backgroundColor;
1044 b = $('sidebanner2').style.borderLeftColor;
1046 $('sidebanner2').style.backgroundColor = b;
1047 $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
1049 // console.log("A: "+a+" B: "+b);
1053 function langtolng(lang)
1061 function formtext_hilite(obj)
1063 obj.className = 'input_text';
1064 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1065 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1068 function formsub_hilite(obj)
1070 obj.className = 'input_sub';
1071 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1072 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1075 // return the value of the radio button that is checked
1076 // return an empty string if none are checked, or
1077 // there are no radio buttons
1078 function get_checked_value(radioObj) {
1081 var radioLength = radioObj.length;
1082 if(radioLength == undefined)
1083 if(radioObj.checked)
1084 return radioObj.value;
1087 for(var i = 0; i < radioLength; i++) {
1088 if(radioObj[i].checked) {
1089 return radioObj[i].value;
1095 // set the radio button with the given value as being checked
1096 // do nothing if there are no radio buttons
1097 // if the given value does not exist, all the radio buttons
1098 // are reset to unchecked
1099 function set_checked_value(radioObj, newValue) {
1102 var radioLength = radioObj.length;
1103 if(radioLength == undefined) {
1104 radioObj.checked = (radioObj.value == newValue.toString());
1107 for(var i = 0; i < radioLength; i++) {
1108 radioObj[i].checked = false;
1109 if(radioObj[i].value == newValue.toString()) {
1110 radioObj[i].checked = true;
1115 function url_append_arg(url, name, value)
1117 var pos, sep, pref, rest;
1119 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1120 pos = url.indexOf('&'+name+'=');
1123 if ((pos = url.indexOf('?')) != -1)
1128 return (url+sep+name+"="+encodeURIComponent(value));
1131 pref = url.substring(0, pos+1);
1132 rest = url.substring(pos+1);
1133 // alert("rest: "+rest+" pos: "+pos);
1134 if ((pos = rest.indexOf('&')) != -1) {
1135 rest = rest.substring(pos);
1140 return (pref+name+"="+encodeURIComponent(value)+rest);
1144 function url_append_args(url)
1149 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1150 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1156 function url_complete(parent, url)
1159 var host = "", path = "";
1162 p = parent.indexOf("://");
1164 rest = parent.substring(p+3);
1165 p2 = rest.indexOf("/");
1167 host = parent.substring(0, p+3+p2);
1168 rest = parent.substring(p+3+p2);
1180 p = rest.lastIndexOf("/");
1182 path = rest.substring(0, p+1);
1185 // alert("host: ["+host+"] path: ["+path+"]");
1186 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') {
1189 else if (url.substring(0,1) == '/') {
1193 return (host+path+url);