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);
277 server_request([arg0=arg1[, arg2=arg3[, ...]]])
279 function server_request()
281 var xhr_wr = createXMLHttpRequest();
284 if (arguments.length > 0) {
285 for (i = 0 ; i < arguments.length ; i+= 2) {
286 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
289 // alert("Args: "+arguments.length);
291 var is_conn = (sess == "not_connected" ? false : true);
293 // console.log("server_request:preresp: "+xhr_wr.responseText);
295 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
296 xhr_wr.onreadystatechange = function() { return; };
299 if (xhr_wr.responseText != null) {
300 // console.log("server_request:resp: "+xhr_wr.responseText);
301 return (xhr_wr.responseText);
307 /* Stat: CHAT and TABLE */
309 function chatt_checksend(obj,e)
315 if(window.event) { // IE
318 else if(e.which) { // Netscape/Firefox/Opera
321 // alert("OBJ: "+obj);
322 if (keynum == 13 && obj.value != "") { // Enter
323 act_chatt(obj.value);
327 function act_chatt(value)
329 send_mesg("chatt|"+encodeURIComponent(value));
333 obj.disabled = false;
345 function act_sitdown(table)
347 send_mesg("sitdown|"+table);
350 function act_wakeup()
355 function act_splash()
365 function act_passwdhowto()
367 send_mesg("passwdhowto");
370 function act_mesgtoadm()
372 send_mesg("mesgtoadm");
377 act_chatt('/tav '+$('txt_in').value);
378 $('txt_in').value = '';
386 function act_placing()
388 send_mesg("placing");
391 function act_roadmap()
393 send_mesg("roadmap");
396 function act_whysupport()
398 send_mesg("whysupport");
401 function act_lascio()
406 function safelascio()
409 // MLANG "Sei sicuro di volere lasciare questa mano?"
410 res = window.confirm(mlang_commons['gamleav'][g_lang]);
415 function act_logout(exitlock)
417 send_mesg("logout|"+exitlock);
420 function act_reloadroom()
422 window.onunload = null;
423 window.onbeforeunload = null;
424 document.location.assign("index.php");
427 function act_shutdown()
431 send_mesg("shutdown");
432 // while (xhr_wr.readyState != 4)
436 function postact_logout()
438 // alert("postact_logout");
443 // eraseCookie("sess");
444 document.location.assign("index.php");
448 function slowimg(img,x1,y1,deltat,free,action,srcend)
450 x1,y1 - destination coords
451 deltat - time for each frame (in msec)
452 free - when the release the local block for other operations (range: 0 - 1)
453 action - function to run when the image is moved
454 srcend - image to switch when the image is moved
457 function sleep(st, delay)
459 // alert("LOC_NEW PRE: "+st.st_loc_new);
463 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
467 function slowimg(img,x1,y1,deltat,free,action,srcend) {
470 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
471 this.x0 = parseInt(getStyle(this.img,"left", "left"));
472 // alert("img.x0 = "+this.x0);
473 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
474 this.y0 = parseInt(getStyle(this.img,"top", "top"));
477 this.deltat = deltat;
479 this.action = action;
480 this.srcend = srcend;
483 slowimg.prototype = {
502 setstart: function(x0,y0)
508 setaction: function(act)
514 settime: function(time)
516 this.time = (time < this.deltat ? this.deltat : time);
517 this.step_n = parseInt(this.time / this.deltat);
518 this.dx = (this.x1 - this.x0) / this.step_n;
519 this.dy = (this.y1 - this.y0) / this.step_n;
520 if (this.step_n * this.deltat == this.time) {
524 this.step_free = parseInt(this.step_n * this.free);
530 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
532 this.st.st_loc_new++;
534 this.img.style.visibility = "visible";
535 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
540 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
541 if (this.step_cur == 0) {
542 var date = new Date();
543 // $("logz").innerHTML = "Timestart: " + date + "<br>";
545 if (this.step_cur <= this.step_n) {
546 this.img.style.left = this.x0 + this.dx * this.step_cur;
547 this.img.style.top = this.y0 + this.dy * this.step_cur;
549 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
550 if (this.step_cur == this.step_free && this.st != null) {
551 if (this.st.st_loc < this.st.st_loc_new) {
552 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
559 this.img.style.left = this.x1;
560 this.img.style.top = this.y1;
561 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
562 var date = new Date();
563 // $("logz").innerHTML += "Timestop: " + date + "<br>";
565 if (this.action != null) {
569 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
574 if (this.srcend != null) {
575 this.img.src = this.srcend;
581 function div_show(div)
583 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
584 div.style.visibility = "visible";
587 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
594 this.ancestor = document.body;
596 this.st.st_loc_new++;
598 clo = document.createElement("input");
600 clo.className = "button";
601 clo.style.bottom = "4px";
603 if (block_time > 0) {
604 clo.value = "leggere, prego.";
609 clo.onclick = this.input_hide;
612 clodiv = document.createElement("div");
613 clodiv.className = "notify_clo";
615 this.clodiv = clodiv;
617 clodiv.appendChild(clo);
619 cont = document.createElement("div");
621 cont.style.borderBottomStyle = "solid";
622 cont.style.borderBottomWidth = "1px";
623 cont.style.borderBottomColor = "gray";
624 cont.style.height = (h - 30)+"px";
625 cont.style.overflow = "auto";
626 cont.innerHTML = text;
628 box = document.createElement("div");
630 box.className = "notify_opaque";
632 box.className = "notify";
634 box.style.zIndex = 200;
635 box.style.width = w+"px";
636 box.style.marginLeft = -parseInt(w/2)+"px";
637 box.style.height = h+"px";
638 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
639 box.appendChild(cont);
640 box.appendChild(clodiv);
641 box.style.visibility = "visible";
645 this.ancestor.appendChild(box);
647 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
649 if (block_time != 0) {
650 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);
660 notify_ex.prototype = {
672 if (this.st.st_loc < this.st.st_loc_new) {
679 clearTimeout(this.toutid);
680 this.ancestor.removeChild(this.notitag);
684 input_hide: function()
686 clearTimeout(this.obj.toutid);
687 this.obj.ancestor.removeChild(this.obj.notitag);
693 notify.prototype = notify_ex.prototype; // Define sub-class
694 notify.prototype.constructor = notify;
695 notify.baseConstructor = notify_ex;
696 notify.superClass = notify_ex.prototype;
698 function notify(st, text, tout, butt, w, h)
700 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
705 return document.getElementById(id);
712 this.st_loc_new = -1;
713 this.comms = new Array;
723 sleep: function(delay) {
727 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
733 if (this.sleep_hdl != null) {
734 clearTimeout(this.sleep_hdl);
735 this.sleep_hdl = null;
740 function remark_step()
742 var ct = $("remark").l_remct;
748 $("remark").className = "remark"+ct;
749 $("remark").l_remct = ct;
750 setTimeout(remark_step,500);
753 $("remark").className = "remark0";
760 if ($("remark").l_remct == 0) {
761 $("remark").l_remct = 1;
762 setTimeout(remark_step,500);
766 function remark_off()
768 $("remark").l_remct = 0;
769 $("remark").className = "remark0";
773 function italizer(ga)
777 return "<i>"+ga[1]+"</i>";
783 function exitlock_show(num, islock)
787 num = (num < 3 ? num : 3);
788 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
789 // alert("EXITLOCK: "+$("exitlock").src);
790 $("exitlock").style.visibility = "visible";
795 // exitlock_show(0, true);
798 var chatt_lines = new Array();
799 var chatt_lines_n = 0;
801 var CHATT_MAXLINES = 40;
803 function user_decorator(user)
807 if ((flags & 0x03) != 0)
808 name = "<span class='au" + (flags & 0x03) + "'>"+user[1]+"</span>";
815 function user_dec_and_state(el)
820 content = user_decorator(el);
821 content += state_add(el[0]);
828 function chatt_sub(dt,data,str)
830 var must_scroll = false;
834 var bolder = [ (data[0] | 1), data[1] ];
835 name = user_decorator(bolder);
837 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
840 // alert("ARRIVA NAME: "+ name + " STR:"+str);
841 if (chatt_lines_n == CHATT_MAXLINES) {
842 $("txt").innerHTML = "";
843 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
844 chatt_lines[i] = chatt_lines[i+1];
845 $("txt").innerHTML += chatt_lines[i];
847 chatt_lines[i] = dt+name+": "+str+ "<br>";
848 $("txt").innerHTML += chatt_lines[i];
851 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
852 $("txt").innerHTML += chatt_lines[chatt_lines_n];
855 // $("txt").innerHTML;
859 $("txt").scrollTop = 10000000;
861 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
865 * GESTIONE DEI COOKIES
867 function createCookie(name,value,hours,path) {
869 var date = new Date();
870 date.setTime(date.getTime()+(hours*60*60*1000));
871 var expires = "; expires="+date.toGMTString();
873 else var expires = "";
874 document.cookie = name+"="+value+expires+"; path="+path;
877 function readCookie(name) {
878 var nameEQ = name + "=";
879 var ca = document.cookie.split(';');
880 for(var i=0;i < ca.length;i++) {
882 while (c.charAt(0)==' ') c = c.substring(1,c.length);
883 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
888 function eraseCookie(name) {
889 createCookie(name,"",-1);
892 function onbeforeunload_cb () {
896 function onunload_cb () {
898 if (typeof(hstm) != "undefined")
906 function room_checkspace(emme,tables,inpe)
909 for (i = 0 ; i < emme ; i++)
914 for (i = 0 ; i < 5 ; i++)
917 for (i = 0 ; i < tables ; i++) {
918 $("table"+i).innerHTML = alta;
920 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
923 stand = "<table class=\"table_standup\"><tbody><tr>";
924 for (i = 0 ; i < inpe ; i++) {
925 stand += "<td>"+nome+"</td>";
926 if ((i+1) % 4 == 0) {
927 stand += "</tr><tr>";
931 $("standup").innerHTML = stand;
933 // VERIFY: what is this button ?
935 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
938 function unescapeHTML(cont) {
939 var div = document.createElement('div');
943 div.innerHTML = cont;
944 if (div.childNodes[0]) {
945 if (div.childNodes.length > 1) {
946 if (div.childNodes.toArray)
949 var length = div.childNodes.length, results = new Array(length);
951 results[length] = div.childNodes[length];
953 for (i=0 ; i<results.length ; i++)
954 memo = memo + results[i].nodeValue;
960 return (div.childNodes[0].nodeValue);
968 function playsound(tag, sound) {
969 // g_withflash is a global var
971 $(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
972 'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
973 '<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
974 '<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
975 '<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
976 ' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
980 function topbanner_init()
982 setInterval(topbanner_cb, 666);
986 function topbanner_cb()
990 a = $('topbanner').style.backgroundColor;
991 b = $('topbanner').style.borderLeftColor;
993 $('topbanner').style.backgroundColor = b;
994 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
996 // console.log("A: "+a+" B: "+b);
999 function sidebanner_init()
1001 setInterval(sidebanner_cb, 666);
1004 function sidebanner2_init()
1006 setInterval(sidebanner2_cb, 666);
1009 function sidebanner_cb()
1013 a = $('sidebanner').style.backgroundColor;
1014 b = $('sidebanner').style.borderLeftColor;
1016 $('sidebanner').style.backgroundColor = b;
1017 $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
1019 // console.log("A: "+a+" B: "+b);
1022 function sidebanner2_cb()
1026 a = $('sidebanner2').style.backgroundColor;
1027 b = $('sidebanner2').style.borderLeftColor;
1029 $('sidebanner2').style.backgroundColor = b;
1030 $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
1032 // console.log("A: "+a+" B: "+b);
1036 function langtolng(lang)
1044 function formtext_hilite(obj)
1046 obj.className = 'input_text';
1047 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1048 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1051 function formsub_hilite(obj)
1053 obj.className = 'input_sub';
1054 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1055 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1058 // return the value of the radio button that is checked
1059 // return an empty string if none are checked, or
1060 // there are no radio buttons
1061 function get_checked_value(radioObj) {
1064 var radioLength = radioObj.length;
1065 if(radioLength == undefined)
1066 if(radioObj.checked)
1067 return radioObj.value;
1070 for(var i = 0; i < radioLength; i++) {
1071 if(radioObj[i].checked) {
1072 return radioObj[i].value;
1078 // set the radio button with the given value as being checked
1079 // do nothing if there are no radio buttons
1080 // if the given value does not exist, all the radio buttons
1081 // are reset to unchecked
1082 function set_checked_value(radioObj, newValue) {
1085 var radioLength = radioObj.length;
1086 if(radioLength == undefined) {
1087 radioObj.checked = (radioObj.value == newValue.toString());
1090 for(var i = 0; i < radioLength; i++) {
1091 radioObj[i].checked = false;
1092 if(radioObj[i].value == newValue.toString()) {
1093 radioObj[i].checked = true;
1098 function url_append_arg(url, name, value)
1100 var pos, sep, pref, rest;
1102 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1103 pos = url.indexOf('&'+name+'=');
1106 if ((pos = url.indexOf('?')) != -1)
1111 return (url+sep+name+"="+encodeURIComponent(value));
1114 pref = url.substring(0, pos+1);
1115 rest = url.substring(pos+1);
1116 // alert("rest: "+rest+" pos: "+pos);
1117 if ((pos = rest.indexOf('&')) != -1) {
1118 rest = rest.substring(pos);
1123 return (pref+name+"="+encodeURIComponent(value)+rest);
1127 function url_append_args(url)
1132 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1133 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1139 function url_complete(parent, url)
1142 var host = "", path = "";
1145 p = parent.indexOf("://");
1147 rest = parent.substring(p+3);
1148 p2 = rest.indexOf("/");
1150 host = parent.substring(0, p+3+p2);
1151 rest = parent.substring(p+3+p2);
1163 p = rest.lastIndexOf("/");
1165 path = rest.substring(0, p+1);
1168 // alert("host: ["+host+"] path: ["+path+"]");
1169 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') {
1172 else if (url.substring(0,1) == '/') {
1176 return (host+path+url);