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.',
45 function $(id) { return document.getElementById(id); }
47 function getStyle(x,IEstyleProp, MozStyleProp)
50 var y = x.currentStyle[IEstyleProp];
51 } else if (window.getComputedStyle) {
52 var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
57 /* replacement of setInterval on IE */
59 /*if not IE, do nothing*/
60 if(!document.uniqueID){return;};
62 /*Copy the default setInterval behavior*/
63 var nativeSetInterval = window.setInterval;
64 window.setInterval = function(fn,ms) {
66 if(arguments.length <= 2) {
67 return nativeSetInterval(fn,ms);
70 for(var i=2;i<arguments.length;i+=1) {
71 param[i-2] = arguments[i];
75 if(typeof(fn)=='function') {
77 return (function (fn,ms,param) {
78 var fo = function () {
79 fn.apply(window,param);
81 return nativeSetInterval(fo,ms);
84 else if(typeof(fn)=='string')
86 return nativeSetInterval(fn,ms);
90 throw Error('setInterval Error\nInvalid function type');
94 /*Copy the default setTimeout behavior*/
95 var nativeSetTimeout = window.setTimeout;
96 window.setTimeout = function(fn,ms) {
98 if(arguments.length <= 2) {
99 return nativeSetTimeout(fn,ms);
102 for(var i=2;i<arguments.length;i+=1) {
103 param[i-2] = arguments[i];
107 if(typeof(fn)=='function') {
109 return (function (fn,ms,param) {
110 var fo = function () {
111 fn.apply(window,param);
113 return nativeSetTimeout(fo,ms);
116 else if(typeof(fn)=='string')
118 return nativeSetTimeout(fn,ms);
122 throw Error('setTimeout Error\nInvalid function type');
128 function addEvent(obj,type,fn)
130 if (obj.addEventListener) {
131 obj.addEventListener( type, fn, false);
133 else if (obj.attachEvent) {
134 obj["e"+type+fn] = fn;
135 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
136 obj.attachEvent( "on"+type, obj[type+fn] );
139 throw new Error("Event registration not supported");
142 function removeEvent(obj,type,fn)
144 if (obj.removeEventListener) {
145 obj.removeEventListener( type, fn, false );
147 else if (obj.detachEvent) {
148 obj.detachEvent( "on"+type, obj[type+fn] );
150 obj["e"+type+fn] = null;
154 // var card_pos = RANGE 0 <= x < cards_ea_n
156 function show_bigpict(obj, act, x, y)
160 if (arguments.length > 4)
165 big = $(obj.id+"_big"+sfx);
167 big.style.left = obj.offsetLeft + x+"px";
168 big.style.top = obj.offsetTop + y+"px";
169 big.style.visibility = "visible";
172 big.style.visibility = "hidden";
176 function rnd_int(min, max) {
177 return Math.floor(Math.random() * (max - min + 1) + min);
180 function error_images()
182 // alert("GHESEMU!");
183 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
186 function abort_images()
188 // alert("ABORTAIMAGES");
189 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
192 function unload_images()
194 // alert("ABORTAIMAGES");
195 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
198 function reset_images()
200 // alert("ABORTAIMAGES");
201 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
204 function update_images()
206 // MLANG "Immagine caricate" + g_preload_imgsz_arr[g_imgct] + "%."
207 $("imgct").innerHTML = mlang_commons['imgload_a'][g_lang]+g_preload_imgsz_arr[g_imgct]+"%.";
208 if (g_imgct+1 < g_preload_img_arr.length) {
210 setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
212 // $("imgct").innerHTML += "U";
215 function preload_images(arr,idx)
219 // $("imgct").innerHTML = "Stiamo caricando "+arr[idx]+"%.<br>";
220 im.onload = update_images;
221 im.onerror = error_images;
222 im.onabort = abort_images;
223 im.onunload = unload_images;
224 im.onreset = reset_images;
226 // $("imgct").innerHTML += "P";
229 function safestatus(a)
237 function createXMLHttpRequest() {
238 if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
239 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
240 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
242 try { return new XMLHttpRequest(); } catch(e) {}
243 alert("XMLHttpRequest not supported");
247 function send_mesg(mesg)
249 var xhr_wr = createXMLHttpRequest();
250 var is_conn = (sess == "not_connected" ? false : true);
252 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
253 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
254 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
255 xhr_wr.onreadystatechange = function() { return; };
256 if (typeof(g_debug) == 'number' && g_debug > 0
257 && typeof(console) == 'object' && typeof(console.log) == 'function') {
258 var ldate = new Date();
259 console.log(ldate.getTime()+':MESG:'+mesg);
264 if (xhr_wr.responseText != null) {
265 eval(xhr_wr.responseText);
272 server_request([arg0=arg1[, arg2=arg3[, ...]]])
274 function server_request()
276 var xhr_wr = createXMLHttpRequest();
279 if (arguments.length > 0) {
280 for (i = 0 ; i < arguments.length ; i+= 2) {
281 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
284 // alert("Args: "+arguments.length);
286 var is_conn = (sess == "not_connected" ? false : true);
288 // console.log("server_request:preresp: "+xhr_wr.responseText);
290 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
291 xhr_wr.onreadystatechange = function() { return; };
294 if (xhr_wr.responseText != null) {
295 // console.log("server_request:resp: "+xhr_wr.responseText);
296 return (xhr_wr.responseText);
302 /* Stat: CHAT and TABLE */
304 function chatt_checksend(obj,e)
310 if(window.event) { // IE
313 else if(e.which) { // Netscape/Firefox/Opera
316 // alert("OBJ: "+obj);
317 if (keynum == 13 && obj.value != "") { // Enter
318 act_chatt(obj.value);
322 function act_chatt(value)
324 send_mesg("chatt|"+encodeURIComponent(value));
328 obj.disabled = false;
340 function act_sitdown(table)
342 send_mesg("sitdown|"+table);
345 function act_wakeup()
350 function act_splash()
360 function act_passwdhowto()
362 send_mesg("passwdhowto");
365 function act_mesgtoadm()
367 send_mesg("mesgtoadm");
372 act_chatt('/tav '+$('txt_in').value);
373 $('txt_in').value = '';
381 function act_placing()
383 send_mesg("placing");
386 function act_roadmap()
388 send_mesg("roadmap");
391 function act_whysupport()
393 send_mesg("whysupport");
396 function act_lascio()
401 function safelascio()
404 // MLANG "Sei sicuro di volere lasciare questa mano?"
405 res = window.confirm(mlang_commons['gamleav'][g_lang]);
410 function act_logout(exitlock)
412 send_mesg("logout|"+exitlock);
415 function act_reloadroom()
417 window.onunload = null;
418 window.onbeforeunload = null;
419 document.location.assign("index.php");
422 function act_shutdown()
426 send_mesg("shutdown");
427 // while (xhr_wr.readyState != 4)
431 function postact_logout()
433 // alert("postact_logout");
438 // eraseCookie("sess");
439 document.location.assign("index.php");
443 function slowimg(img,x1,y1,deltat,free,action,srcend)
445 x1,y1 - destination coords
446 deltat - time for each frame (in msec)
447 free - when the release the local block for other operations (range: 0 - 1)
448 action - function to run when the image is moved
449 srcend - image to switch when the image is moved
452 function sleep(st, delay)
454 // alert("LOC_NEW PRE: "+st.st_loc_new);
458 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
462 function slowimg(img,x1,y1,deltat,free,action,srcend) {
465 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
466 this.x0 = parseInt(getStyle(this.img,"left", "left"));
467 // alert("img.x0 = "+this.x0);
468 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
469 this.y0 = parseInt(getStyle(this.img,"top", "top"));
472 this.deltat = deltat;
474 this.action = action;
475 this.srcend = srcend;
478 slowimg.prototype = {
497 setstart: function(x0,y0)
503 setaction: function(act)
509 settime: function(time)
511 this.time = (time < this.deltat ? this.deltat : time);
512 this.step_n = parseInt(this.time / this.deltat);
513 this.dx = (this.x1 - this.x0) / this.step_n;
514 this.dy = (this.y1 - this.y0) / this.step_n;
515 if (this.step_n * this.deltat == this.time) {
519 this.step_free = parseInt(this.step_n * this.free);
525 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
527 this.st.st_loc_new++;
529 this.img.style.visibility = "visible";
530 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
535 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
536 if (this.step_cur == 0) {
537 var date = new Date();
538 // $("logz").innerHTML = "Timestart: " + date + "<br>";
540 if (this.step_cur <= this.step_n) {
541 this.img.style.left = this.x0 + this.dx * this.step_cur;
542 this.img.style.top = this.y0 + this.dy * this.step_cur;
544 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
545 if (this.step_cur == this.step_free && this.st != null) {
546 if (this.st.st_loc < this.st.st_loc_new) {
547 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
554 this.img.style.left = this.x1;
555 this.img.style.top = this.y1;
556 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
557 var date = new Date();
558 // $("logz").innerHTML += "Timestop: " + date + "<br>";
560 if (this.action != null) {
564 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
569 if (this.srcend != null) {
570 this.img.src = this.srcend;
576 function div_show(div)
578 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
579 div.style.visibility = "visible";
582 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
589 this.ancestor = document.body;
591 this.st.st_loc_new++;
593 clo = document.createElement("input");
595 clo.className = "button";
596 clo.style.bottom = "4px";
598 if (block_time > 0) {
599 clo.value = "leggere, prego.";
604 clo.onclick = this.input_hide;
607 clodiv = document.createElement("div");
608 clodiv.className = "notify_clo";
610 this.clodiv = clodiv;
612 clodiv.appendChild(clo);
614 cont = document.createElement("div");
616 cont.style.borderBottomStyle = "solid";
617 cont.style.borderBottomWidth = "1px";
618 cont.style.borderBottomColor = "gray";
619 cont.style.height = (h - 30)+"px";
620 cont.style.overflow = "auto";
621 cont.innerHTML = text;
623 box = document.createElement("div");
625 box.className = "notify_opaque";
627 box.className = "notify";
629 box.style.zIndex = 200;
630 box.style.width = w+"px";
631 box.style.marginLeft = -parseInt(w/2)+"px";
632 box.style.height = h+"px";
633 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
634 box.appendChild(cont);
635 box.appendChild(clodiv);
636 box.style.visibility = "visible";
640 this.ancestor.appendChild(box);
642 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
644 if (block_time != 0) {
645 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);
655 notify_ex.prototype = {
667 if (this.st.st_loc < this.st.st_loc_new) {
674 clearTimeout(this.toutid);
675 this.ancestor.removeChild(this.notitag);
679 input_hide: function()
681 clearTimeout(this.obj.toutid);
682 this.obj.ancestor.removeChild(this.obj.notitag);
688 notify.prototype = notify_ex.prototype; // Define sub-class
689 notify.prototype.constructor = notify;
690 notify.baseConstructor = notify_ex;
691 notify.superClass = notify_ex.prototype;
693 function notify(st, text, tout, butt, w, h)
695 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
700 return document.getElementById(id);
707 this.st_loc_new = -1;
708 this.comms = new Array;
718 sleep: function(delay) {
722 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
728 if (this.sleep_hdl != null) {
729 clearTimeout(this.sleep_hdl);
730 this.sleep_hdl = null;
735 function remark_step()
737 var ct = $("remark").l_remct;
743 $("remark").className = "remark"+ct;
744 $("remark").l_remct = ct;
745 setTimeout(remark_step,500);
748 $("remark").className = "remark0";
755 if ($("remark").l_remct == 0) {
756 $("remark").l_remct = 1;
757 setTimeout(remark_step,500);
761 function remark_off()
763 $("remark").l_remct = 0;
764 $("remark").className = "remark0";
768 function italizer(ga)
772 return "<i>"+ga[1]+"</i>";
778 function exitlock_show(num, islock)
782 num = (num < 3 ? num : 3);
783 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
784 // alert("EXITLOCK: "+$("exitlock").src);
785 $("exitlock").style.visibility = "visible";
790 // exitlock_show(0, true);
793 var chatt_lines = new Array();
794 var chatt_lines_n = 0;
796 var CHATT_MAXLINES = 40;
798 function user_decorator(user)
802 if ((flags & 0x03) != 0)
803 name = "<span class='au" + (flags & 0x03) + "'>"+user[1]+"</span>";
810 function user_dec_and_state(el)
815 content = user_decorator(el);
816 content += state_add(el[0]);
823 function chatt_sub(dt,data,str)
825 var must_scroll = false;
829 var bolder = [ (data[0] | 1), data[1] ];
830 name = user_decorator(bolder);
832 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
835 // alert("ARRIVA NAME: "+ name + " STR:"+str);
836 if (chatt_lines_n == CHATT_MAXLINES) {
837 $("txt").innerHTML = "";
838 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
839 chatt_lines[i] = chatt_lines[i+1];
840 $("txt").innerHTML += chatt_lines[i];
842 chatt_lines[i] = dt+name+": "+str+ "<br>";
843 $("txt").innerHTML += chatt_lines[i];
846 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
847 $("txt").innerHTML += chatt_lines[chatt_lines_n];
850 // $("txt").innerHTML;
854 $("txt").scrollTop = 10000000;
856 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
860 * GESTIONE DEI COOKIES
862 function createCookie(name,value,hours,path) {
864 var date = new Date();
865 date.setTime(date.getTime()+(hours*60*60*1000));
866 var expires = "; expires="+date.toGMTString();
868 else var expires = "";
869 document.cookie = name+"="+value+expires+"; path="+path;
872 function readCookie(name) {
873 var nameEQ = name + "=";
874 var ca = document.cookie.split(';');
875 for(var i=0;i < ca.length;i++) {
877 while (c.charAt(0)==' ') c = c.substring(1,c.length);
878 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
883 function eraseCookie(name) {
884 createCookie(name,"",-1);
887 function onbeforeunload_cb () {
891 function onunload_cb () {
893 if (typeof(hstm) != "undefined")
901 function room_checkspace(emme,tables,inpe)
904 for (i = 0 ; i < emme ; i++)
909 for (i = 0 ; i < 5 ; i++)
912 for (i = 0 ; i < tables ; i++) {
913 $("table"+i).innerHTML = alta;
915 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
918 stand = "<table class=\"table_standup\"><tbody><tr>";
919 for (i = 0 ; i < inpe ; i++) {
920 stand += "<td>"+nome+"</td>";
921 if ((i+1) % 4 == 0) {
922 stand += "</tr><tr>";
926 $("standup").innerHTML = stand;
928 // VERIFY: what is this button ?
930 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
933 function unescapeHTML(cont) {
934 var div = document.createElement('div');
938 div.innerHTML = cont;
939 if (div.childNodes[0]) {
940 if (div.childNodes.length > 1) {
941 if (div.childNodes.toArray)
944 var length = div.childNodes.length, results = new Array(length);
946 results[length] = div.childNodes[length];
948 for (i=0 ; i<results.length ; i++)
949 memo = memo + results[i].nodeValue;
955 return (div.childNodes[0].nodeValue);
963 function playsound(tag, sound) {
964 // g_withflash is a global var
966 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
967 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
968 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
969 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
970 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
971 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
975 function topbanner_init()
977 setInterval(topbanner_cb, 666);
981 function topbanner_cb()
985 a = $('topbanner').style.backgroundColor;
986 b = $('topbanner').style.borderLeftColor;
988 $('topbanner').style.backgroundColor = b;
989 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
991 // console.log("A: "+a+" B: "+b);
994 function sidebanner_init()
996 setInterval(sidebanner_cb, 666);
999 function sidebanner2_init()
1001 setInterval(sidebanner2_cb, 666);
1004 function sidebanner_cb()
1008 a = $('sidebanner').style.backgroundColor;
1009 b = $('sidebanner').style.borderLeftColor;
1011 $('sidebanner').style.backgroundColor = b;
1012 $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
1014 // console.log("A: "+a+" B: "+b);
1017 function sidebanner2_cb()
1021 a = $('sidebanner2').style.backgroundColor;
1022 b = $('sidebanner2').style.borderLeftColor;
1024 $('sidebanner2').style.backgroundColor = b;
1025 $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
1027 // console.log("A: "+a+" B: "+b);
1031 function langtolng(lang)
1039 function formtext_hilite(obj)
1041 obj.className = 'input_text';
1042 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1043 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1046 function formsub_hilite(obj)
1048 obj.className = 'input_sub';
1049 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1050 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1053 // return the value of the radio button that is checked
1054 // return an empty string if none are checked, or
1055 // there are no radio buttons
1056 function get_checked_value(radioObj) {
1059 var radioLength = radioObj.length;
1060 if(radioLength == undefined)
1061 if(radioObj.checked)
1062 return radioObj.value;
1065 for(var i = 0; i < radioLength; i++) {
1066 if(radioObj[i].checked) {
1067 return radioObj[i].value;
1073 // set the radio button with the given value as being checked
1074 // do nothing if there are no radio buttons
1075 // if the given value does not exist, all the radio buttons
1076 // are reset to unchecked
1077 function set_checked_value(radioObj, newValue) {
1080 var radioLength = radioObj.length;
1081 if(radioLength == undefined) {
1082 radioObj.checked = (radioObj.value == newValue.toString());
1085 for(var i = 0; i < radioLength; i++) {
1086 radioObj[i].checked = false;
1087 if(radioObj[i].value == newValue.toString()) {
1088 radioObj[i].checked = true;
1093 function url_append_arg(url, name, value)
1095 var pos, sep, pref, rest;
1097 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1098 pos = url.indexOf('&'+name+'=');
1101 if ((pos = url.indexOf('?')) != -1)
1106 return (url+sep+name+"="+encodeURIComponent(value));
1109 pref = url.substring(0, pos+1);
1110 rest = url.substring(pos+1);
1111 // alert("rest: "+rest+" pos: "+pos);
1112 if ((pos = rest.indexOf('&')) != -1) {
1113 rest = rest.substring(pos);
1118 return (pref+name+"="+encodeURIComponent(value)+rest);
1122 function url_append_args(url)
1127 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1128 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1134 function url_complete(parent, url)
1137 var host = "", path = "";
1140 p = parent.indexOf("://");
1142 rest = parent.substring(p+3);
1143 p2 = rest.indexOf("/");
1145 host = parent.substring(0, p+3+p2);
1146 rest = parent.substring(p+3+p2);
1158 p = rest.lastIndexOf("/");
1160 path = rest.substring(0, p+1);
1163 // alert("host: ["+host+"] path: ["+path+"]");
1164 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') {
1167 else if (url.substring(0,1) == '/') {
1171 return (host+path+url);