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 dec2hex(d, padding)
59 var hex = Number(d).toString(16);
60 padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding;
62 while (hex.length < padding) {
69 function getStyle(x,IEstyleProp, MozStyleProp)
72 var y = x.currentStyle[IEstyleProp];
73 } else if (window.getComputedStyle) {
74 var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
79 /* replacement of setInterval on IE */
81 /*if not IE, do nothing*/
82 if(!document.uniqueID){return;};
84 /*Copy the default setInterval behavior*/
85 var nativeSetInterval = window.setInterval;
86 window.setInterval = function(fn,ms) {
88 if(arguments.length <= 2) {
89 return nativeSetInterval(fn,ms);
92 for(var i=2;i<arguments.length;i+=1) {
93 param[i-2] = arguments[i];
97 if(typeof(fn)=='function') {
99 return (function (fn,ms,param) {
100 var fo = function () {
101 fn.apply(window,param);
103 return nativeSetInterval(fo,ms);
106 else if(typeof(fn)=='string')
108 return nativeSetInterval(fn,ms);
112 throw Error('setInterval Error\nInvalid function type');
116 /*Copy the default setTimeout behavior*/
117 var nativeSetTimeout = window.setTimeout;
118 window.setTimeout = function(fn,ms) {
120 if(arguments.length <= 2) {
121 return nativeSetTimeout(fn,ms);
124 for(var i=2;i<arguments.length;i+=1) {
125 param[i-2] = arguments[i];
129 if(typeof(fn)=='function') {
131 return (function (fn,ms,param) {
132 var fo = function () {
133 fn.apply(window,param);
135 return nativeSetTimeout(fo,ms);
138 else if(typeof(fn)=='string')
140 return nativeSetTimeout(fn,ms);
144 throw Error('setTimeout Error\nInvalid function type');
150 function addEvent(obj,type,fn)
152 if (obj.addEventListener) {
153 obj.addEventListener( type, fn, false);
155 else if (obj.attachEvent) {
156 obj["e"+type+fn] = fn;
157 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
158 obj.attachEvent( "on"+type, obj[type+fn] );
161 throw new Error("Event registration not supported");
164 function removeEvent(obj,type,fn)
166 if (obj.removeEventListener) {
167 obj.removeEventListener( type, fn, false );
169 else if (obj.detachEvent) {
170 obj.detachEvent( "on"+type, obj[type+fn] );
172 obj["e"+type+fn] = null;
176 // var card_pos = RANGE 0 <= x < cards_ea_n
178 function show_bigpict(obj, act, x, y)
182 if (arguments.length > 4)
187 big = $(obj.id+"_big"+sfx);
189 big.style.left = obj.offsetLeft + x+"px";
190 big.style.top = obj.offsetTop + y+"px";
191 big.style.visibility = "visible";
194 big.style.visibility = "hidden";
198 function rnd_int(min, max) {
199 return Math.floor(Math.random() * (max - min + 1) + min);
202 function error_images()
204 // alert("GHESEMU!");
205 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
208 function abort_images()
210 // alert("ABORTAIMAGES");
211 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
214 function unload_images()
216 // alert("ABORTAIMAGES");
217 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
220 function reset_images()
222 // alert("ABORTAIMAGES");
223 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
226 function update_images()
228 // MLANG "Immagine caricate" + g_preload_imgsz_arr[g_imgct] + "%."
229 $("imgct").innerHTML = mlang_commons['imgload_a'][g_lang]+g_preload_imgsz_arr[g_imgct]+"%.";
230 if (g_imgct+1 < g_preload_img_arr.length) {
232 setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
234 // $("imgct").innerHTML += "U";
237 function preload_images(arr,idx)
241 // $("imgct").innerHTML = "Stiamo caricando "+arr[idx]+"%.<br>";
242 im.onload = update_images;
243 im.onerror = error_images;
244 im.onabort = abort_images;
245 im.onunload = unload_images;
246 im.onreset = reset_images;
248 // $("imgct").innerHTML += "P";
251 function safestatus(a)
259 function createXMLHttpRequest() {
260 if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
261 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
262 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
264 try { return new XMLHttpRequest(); } catch(e) {}
265 alert("XMLHttpRequest not supported");
269 function send_mesg(mesg)
271 var xhr_wr = createXMLHttpRequest();
272 var is_conn = (sess == "not_connected" ? false : true);
274 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
275 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
276 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
277 xhr_wr.onreadystatechange = function() { return; };
278 if (typeof(g_debug) == 'number' && g_debug > 0
279 && typeof(console) == 'object' && typeof(console.log) == 'function') {
280 var ldate = new Date();
281 console.log(ldate.getTime()+':MESG:'+mesg);
286 if (xhr_wr.responseText != null) {
287 eval(xhr_wr.responseText);
293 sync request to server
294 server_request([arg0=arg1[, arg2=arg3[, ...]]])
295 if var name == '__POST__' than all other vars will be managed as POST content
296 and the call will be a POST
298 function server_request()
300 var xhr_wr = createXMLHttpRequest();
301 var i, collect = "", post_collect = null, is_post = false;
303 if (arguments.length > 0) {
304 for (i = 0 ; i < arguments.length ; i+= 2) {
305 if (arguments[i] == "__POST__") {
312 post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
314 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
317 // alert("Args: "+arguments.length);
319 var is_conn = (sess == "not_connected" ? false : true);
321 // console.log("server_request:preresp: "+xhr_wr.responseText);
324 xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
325 xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
328 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
330 xhr_wr.onreadystatechange = function() { return; };
331 xhr_wr.send(post_collect);
333 if (xhr_wr.responseText != null) {
334 // console.log("server_request:resp: "+xhr_wr.responseText);
335 return (xhr_wr.responseText);
341 /* Stat: CHAT and TABLE */
343 function chatt_checksend(obj,e)
349 if(window.event) { // IE
352 else if(e.which) { // Netscape/Firefox/Opera
355 // alert("OBJ: "+obj);
356 if (keynum == 13 && obj.value != "") { // Enter
357 act_chatt(obj.value);
361 function act_chatt(value)
363 send_mesg("chatt|"+encodeURIComponent(value));
367 obj.disabled = false;
379 function act_sitdown(table)
381 send_mesg("sitdown|"+table);
384 function act_wakeup()
389 function act_splash()
399 function act_passwdhowto()
401 send_mesg("passwdhowto");
404 function act_mesgtoadm()
406 send_mesg("mesgtoadm");
411 act_chatt('/tav '+$('txt_in').value);
412 $('txt_in').value = '';
420 function act_placing()
422 send_mesg("placing");
425 function act_roadmap()
427 send_mesg("roadmap");
430 function act_whysupport()
432 send_mesg("whysupport");
435 function act_lascio()
440 function safelascio()
443 // MLANG "Sei sicuro di volere lasciare questa mano?"
444 res = window.confirm(mlang_commons['gamleav'][g_lang]);
449 function act_logout(exitlock)
451 send_mesg("logout|"+exitlock);
454 function act_reloadroom()
456 window.onunload = null;
457 window.onbeforeunload = null;
458 document.location.assign("index.php");
461 function act_shutdown()
465 send_mesg("shutdown");
466 // while (xhr_wr.readyState != 4)
470 function postact_logout()
472 // alert("postact_logout");
477 // eraseCookie("sess");
478 document.location.assign("index.php");
482 function slowimg(img,x1,y1,deltat,free,action,srcend)
484 x1,y1 - destination coords
485 deltat - time for each frame (in msec)
486 free - when the release the local block for other operations (range: 0 - 1)
487 action - function to run when the image is moved
488 srcend - image to switch when the image is moved
491 function sleep(st, delay)
493 // alert("LOC_NEW PRE: "+st.st_loc_new);
497 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
501 function slowimg(img,x1,y1,deltat,free,action,srcend) {
504 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
505 this.x0 = parseInt(getStyle(this.img,"left", "left"));
506 // alert("img.x0 = "+this.x0);
507 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
508 this.y0 = parseInt(getStyle(this.img,"top", "top"));
511 this.deltat = deltat;
513 this.action = action;
514 this.srcend = srcend;
517 slowimg.prototype = {
536 setstart: function(x0,y0)
542 setaction: function(act)
548 settime: function(time)
550 this.time = (time < this.deltat ? this.deltat : time);
551 this.step_n = parseInt(this.time / this.deltat);
552 this.dx = (this.x1 - this.x0) / this.step_n;
553 this.dy = (this.y1 - this.y0) / this.step_n;
554 if (this.step_n * this.deltat == this.time) {
558 this.step_free = parseInt(this.step_n * this.free);
564 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
566 this.st.st_loc_new++;
568 this.img.style.visibility = "visible";
569 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
574 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
575 if (this.step_cur == 0) {
576 var date = new Date();
577 // $("logz").innerHTML = "Timestart: " + date + "<br>";
579 if (this.step_cur <= this.step_n) {
580 this.img.style.left = this.x0 + this.dx * this.step_cur;
581 this.img.style.top = this.y0 + this.dy * this.step_cur;
583 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
584 if (this.step_cur == this.step_free && this.st != null) {
585 if (this.st.st_loc < this.st.st_loc_new) {
586 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
593 this.img.style.left = this.x1;
594 this.img.style.top = this.y1;
595 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
596 var date = new Date();
597 // $("logz").innerHTML += "Timestop: " + date + "<br>";
599 if (this.action != null) {
603 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
608 if (this.srcend != null) {
609 this.img.src = this.srcend;
615 function div_show(div)
617 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
618 div.style.visibility = "visible";
621 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
628 this.ancestor = document.body;
630 this.st.st_loc_new++;
632 clo = document.createElement("input");
634 clo.className = "button";
635 clo.style.bottom = "4px";
637 if (block_time > 0) {
638 clo.value = "leggere, prego.";
643 clo.onclick = this.input_hide;
646 clodiv = document.createElement("div");
647 clodiv.className = "notify_clo";
649 this.clodiv = clodiv;
651 clodiv.appendChild(clo);
653 cont = document.createElement("div");
655 cont.style.borderBottomStyle = "solid";
656 cont.style.borderBottomWidth = "1px";
657 cont.style.borderBottomColor = "gray";
658 cont.style.height = (h - 30)+"px";
659 cont.style.overflow = "auto";
660 cont.innerHTML = text;
662 box = document.createElement("div");
664 box.className = "notify_opaque";
666 box.className = "notify";
668 box.style.zIndex = 200;
669 box.style.width = w+"px";
670 box.style.marginLeft = -parseInt(w/2)+"px";
671 box.style.height = h+"px";
672 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
673 box.appendChild(cont);
674 box.appendChild(clodiv);
675 box.style.visibility = "visible";
679 this.ancestor.appendChild(box);
681 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
683 if (block_time != 0) {
684 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);
694 notify_ex.prototype = {
706 if (this.st.st_loc < this.st.st_loc_new) {
713 clearTimeout(this.toutid);
714 this.ancestor.removeChild(this.notitag);
718 input_hide: function()
720 clearTimeout(this.obj.toutid);
721 this.obj.ancestor.removeChild(this.obj.notitag);
727 notify.prototype = notify_ex.prototype; // Define sub-class
728 notify.prototype.constructor = notify;
729 notify.baseConstructor = notify_ex;
730 notify.superClass = notify_ex.prototype;
732 function notify(st, text, tout, butt, w, h)
734 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
739 return document.getElementById(id);
746 this.st_loc_new = -1;
747 this.comms = new Array;
757 sleep: function(delay) {
761 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
767 if (this.sleep_hdl != null) {
768 clearTimeout(this.sleep_hdl);
769 this.sleep_hdl = null;
774 function remark_step()
776 var ct = $("remark").l_remct;
782 $("remark").className = "remark"+ct;
783 $("remark").l_remct = ct;
784 setTimeout(remark_step,500);
787 $("remark").className = "remark0";
794 if ($("remark").l_remct == 0) {
795 $("remark").l_remct = 1;
796 setTimeout(remark_step,500);
800 function remark_off()
802 $("remark").l_remct = 0;
803 $("remark").className = "remark0";
807 function italizer(ga)
811 return "<i>"+ga[1]+"</i>";
817 function exitlock_show(num, islock)
821 num = (num < 3 ? num : 3);
822 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
823 // alert("EXITLOCK: "+$("exitlock").src);
824 $("exitlock").style.visibility = "visible";
829 // exitlock_show(0, true);
832 var chatt_lines = new Array();
833 var chatt_lines_n = 0;
835 var CHATT_MAXLINES = 40;
837 function user_decorator(user)
840 var flags = user[BSK_USER_FLAGS];
841 var flags_vlt = user[BSK_USER_FLGVL];
842 if ((flags & 0x03) != 0)
843 name = "<span class='au" + (flags & 0x03) + "'>"+user[BSK_USER_NICK]+"</span>";
845 name = user[BSK_USER_NICK];
850 function user_dec_and_state(el)
855 content = user_decorator(el);
856 content += state_add(el[BSK_USER_FLAGS], el[BSK_USER_FLGVL],
857 (typeof(el[BSK_USER_SCOL]) != 'undefined' ? el[BSK_USER_SCOL] : null));
864 function chatt_sub(dt,data,str)
866 var must_scroll = false;
870 var bolder = [ (data[BSK_USER_FLAGS] | 1), data[BSK_USER_FLGVL], data[BSK_USER_NICK] ];
871 name = user_decorator(bolder);
873 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
876 // alert("ARRIVA NAME: "+ name + " STR:"+str);
877 if (chatt_lines_n == CHATT_MAXLINES) {
878 $("txt").innerHTML = "";
879 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
880 chatt_lines[i] = chatt_lines[i+1];
881 $("txt").innerHTML += chatt_lines[i];
883 chatt_lines[i] = dt+name+": "+str+ "<br>";
884 $("txt").innerHTML += chatt_lines[i];
887 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
888 $("txt").innerHTML += chatt_lines[chatt_lines_n];
891 // $("txt").innerHTML;
895 $("txt").scrollTop = 10000000;
897 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
901 * GESTIONE DEI COOKIES
903 function createCookie(name,value,hours,path) {
905 var date = new Date();
906 date.setTime(date.getTime()+(hours*60*60*1000));
907 var expires = "; expires="+date.toGMTString();
909 else var expires = "";
910 document.cookie = name+"="+value+expires+"; path="+path;
913 function readCookie(name) {
914 var nameEQ = name + "=";
915 var ca = document.cookie.split(';');
916 for(var i=0;i < ca.length;i++) {
918 while (c.charAt(0)==' ') c = c.substring(1,c.length);
919 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
924 function eraseCookie(name) {
925 createCookie(name,"",-1);
928 function onbeforeunload_cb () {
932 function onunload_cb () {
934 if (typeof(hstm) != "undefined")
942 function room_checkspace(emme,tables,inpe)
945 for (i = 0 ; i < emme ; i++)
950 for (i = 0 ; i < 5 ; i++)
953 for (i = 0 ; i < tables ; i++) {
954 $("table"+i).innerHTML = alta;
956 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
959 stand = "<table class=\"table_standup\"><tbody><tr>";
960 for (i = 0 ; i < inpe ; i++) {
961 stand += "<td>"+nome+"</td>";
962 if ((i+1) % 4 == 0) {
963 stand += "</tr><tr>";
967 $("standup").innerHTML = stand;
969 // VERIFY: what is this button ?
971 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
974 function unescapeHTML(cont) {
975 var div = document.createElement('div');
979 div.innerHTML = cont;
980 if (div.childNodes[0]) {
981 if (div.childNodes.length > 1) {
982 if (div.childNodes.toArray)
985 var length = div.childNodes.length, results = new Array(length);
987 results[length] = div.childNodes[length];
989 for (i=0 ; i<results.length ; i++)
990 memo = memo + results[i].nodeValue;
996 return (div.childNodes[0].nodeValue);
1004 function playsound(tag, sound) {
1005 // g_withflash is a global var
1007 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
1008 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
1009 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
1010 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
1011 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
1012 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
1016 function topbanner_init()
1018 setInterval(topbanner_cb, 666);
1022 function topbanner_cb()
1026 a = $('topbanner').style.backgroundColor;
1027 b = $('topbanner').style.borderLeftColor;
1029 $('topbanner').style.backgroundColor = b;
1030 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1032 // console.log("A: "+a+" B: "+b);
1035 function sidebanner_init()
1037 setInterval(sidebanner_cb, 666);
1040 function sidebanner2_init()
1042 setInterval(sidebanner2_cb, 666);
1045 function sidebanner_cb()
1049 a = $('sidebanner').style.backgroundColor;
1050 b = $('sidebanner').style.borderLeftColor;
1052 $('sidebanner').style.backgroundColor = b;
1053 $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
1055 // console.log("A: "+a+" B: "+b);
1058 function sidebanner2_cb()
1062 a = $('sidebanner2').style.backgroundColor;
1063 b = $('sidebanner2').style.borderLeftColor;
1065 $('sidebanner2').style.backgroundColor = b;
1066 $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
1068 // console.log("A: "+a+" B: "+b);
1072 function langtolng(lang)
1080 function formtext_hilite(obj)
1082 obj.className = 'input_text';
1083 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1084 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1087 function formsub_hilite(obj)
1089 obj.className = 'input_sub';
1090 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1091 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1094 // return the value of the radio button that is checked
1095 // return an empty string if none are checked, or
1096 // there are no radio buttons
1097 function get_checked_value(radioObj) {
1100 var radioLength = radioObj.length;
1101 if(radioLength == undefined)
1102 if(radioObj.checked)
1103 return radioObj.value;
1106 for(var i = 0; i < radioLength; i++) {
1107 if(radioObj[i].checked) {
1108 return radioObj[i].value;
1114 // set the radio button with the given value as being checked
1115 // do nothing if there are no radio buttons
1116 // if the given value does not exist, all the radio buttons
1117 // are reset to unchecked
1118 function set_checked_value(radioObj, newValue) {
1121 var radioLength = radioObj.length;
1122 if(radioLength == undefined) {
1123 radioObj.checked = (radioObj.value == newValue.toString());
1126 for(var i = 0; i < radioLength; i++) {
1127 radioObj[i].checked = false;
1128 if(radioObj[i].value == newValue.toString()) {
1129 radioObj[i].checked = true;
1134 function url_append_arg(url, name, value)
1136 var pos, sep, pref, rest;
1138 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1139 pos = url.indexOf('&'+name+'=');
1142 if ((pos = url.indexOf('?')) != -1)
1147 return (url+sep+name+"="+encodeURIComponent(value));
1150 pref = url.substring(0, pos+1);
1151 rest = url.substring(pos+1);
1152 // alert("rest: "+rest+" pos: "+pos);
1153 if ((pos = rest.indexOf('&')) != -1) {
1154 rest = rest.substring(pos);
1159 return (pref+name+"="+encodeURIComponent(value)+rest);
1163 function url_append_args(url)
1168 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1169 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1175 function url_complete(parent, url)
1178 var host = "", path = "";
1181 p = parent.indexOf("://");
1183 rest = parent.substring(p+3);
1184 p2 = rest.indexOf("/");
1186 host = parent.substring(0, p+3+p2);
1187 rest = parent.substring(p+3+p2);
1199 p = rest.lastIndexOf("/");
1201 path = rest.substring(0, p+1);
1204 // alert("host: ["+host+"] path: ["+path+"]");
1205 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') {
1208 else if (url.substring(0,1) == '/') {
1212 return (host+path+url);