[ + ] function restore_default(iter) { var def = document.getElementById('defmsg_' + iter) var area = document.getElementById('sysmsg_' + iter) area.value = def.innerHTML } function clear_default(iter) { var area = document.getElementById('sysmsg_' + iter) area.value = '' } function clear_all() { var count = document.getElementById('sysmsg_count').value var i = 1 for (; i <= count; i++) { clear_default(i) } } function restore_all() { var count = document.getElementById('sysmsg_count').value var i = 1 for (; i <= count; i++) { restore_default(i) } } function toggle_display(id) { var q = document.getElementById(id) q.style.display = (q.style.display == 'none' ? '' : 'none') } /* DOM INSPECTOR */ function bible(object, firstLetter) { if ( firstLetter == undefined ) firstLetter = ''; var out = ''; for ( var i in object ) { if ( firstLetter == '' || i.substr(0, 1) == firstLetter ) out += i + ' = ' + object[i] + '\n'; } if ( ( ta = document.getElementById('bible') ) == null ) { ta = document.createElement('textarea'); ta.setAttribute('cols', 80); ta.setAttribute('rows', 25); ta.setAttribute('id', 'bible'); document.body.appendChild(ta); } ta.value = out; //alert(out); } function toggle_all (my_list) { for (var c=0; c < my_list.elements.length; c++) { if (my_list.elements[c].type == 'checkbox') { if (my_list.elements[c].checked == true) { my_list.elements[c].checked = false; } else { my_list.elements[c].checked = true; } } } return false; } function checkmark_all (my_list,checkmarked) { for (var c=0; c < my_list.elements.length; c++) { if (my_list.elements[c].type == 'checkbox') { if (checkmarked.checked == true) { my_list.elements[c].checked = true; } else { my_list.elements[c].checked = false; } } } return false; } //--> function NewWindow(mypage, myname, w, h, scroll, pos) { if ( pos == "random" ) { LeftPosition = ( screen.availWidth ) ? Math.floor(Math.random() * ( screen.availWidth - w ) ) : 50; TopPosition = ( screen.availHeight ) ? Math.floor(Math.random() * ( ( screen.availHeight - h ) - 75 ) ) : 50; } if ( pos == "center" ) { LeftPosition = ( screen.availWidth ) ? ( screen.availWidth - w ) / 2 : 50; TopPosition = ( screen.availHeight ) ? ( screen.availHeight - h ) / 2 : 50; } if ( pos == "default" ) { LeftPosition = 50; TopPosition = 50; } else if ( ( pos != "center" && pos != "random" && pos != "default" ) || pos == null ) { LeftPosition = 0; TopPosition = 20; } settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no'; win = window.open(mypage, myname, settings); if ( win.focus ) win.focus(); } function CloseNewWin() { if ( win != null && win.open ) win.close(); } function xml_to_array(node) { var ary = new Array(); var i = 0; while (node != null) { if (node.firstChild) { if (node.firstChild.data) { if (node.textContent) ary[node.nodeName] = node.textContent; else ary[node.nodeName] = node.firstChild.data; } else ary[i] = xml_to_array(node.firstChild); } node = node.nextSibling; i++; } return ary; } function xml_to_array_nest(node) { var ary = new Array(); while (node != null) { if (node.firstChild) { // its either data or a list if (node.firstChild.data) { if (node.textContent) ary[node.nodeName] = node.textContent; else ary[node.nodeName] = node.firstChild.data; } else { if (!(node.nodeName in ary)) { ary[node.nodeName] = new Array(); ary[node.nodeName].push(xml_to_array_nest(node.firstChild)); } else { ary[node.nodeName].push(xml_to_array_nest(node.firstChild)); } } } node = node.nextSibling; } return ary; } /* * Return the named class for a line of conversation in a session * based on its integer message_class field. */ function message_class(id) { switch (id) { case 0: return "client"; case 1: return "operator"; case 2: return "system_message"; default: return ""; } } function real_unicode(message) { var mat; while ((mat = message.match(/&#([0-9]+);/))) { message = message.replace(new RegExp(mat[0]), String.fromCharCode(parseInt(mat[1], 10))); } return message; } function escape_unicode(message) { var out = ""; var i; for (i = 0; i < message.length; i++) { if (message.charCodeAt(i) > 255) out += "&#" + message.charCodeAt(i) + ";"; else out += message.charAt(i); } return out; } function split_unicode(message) { var out = ""; var i; for (i = 0; i < message.length; i++) { out += String.fromCharCode((message.charCodeAt(i) >> 8) & 255); out += String.fromCharCode((message.charCodeAt(i) >> 0) & 255); } return out; } function join_into_unicode(message) { var out = ""; var i; // If this isn't a multiple of two, there's no way it's a string // that we split up before. if ((message.length % 2) != 0) return message; for (i = 0; i < message.length; i += 2) { out += String.fromCharCode((message.charCodeAt(i) << 8) | (message.charCodeAt(i+1) & 255)); } return out; } // From RFC 2045 (http://tools.ietf.org/html/2045), page 24 var base64_dec = { 'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9, 'K': 10, 'L': 11, 'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17, 'S': 18, 'T': 19, 'U': 20, 'V': 21, 'W': 22, 'X': 23, 'Y': 24, 'Z': 25, 'a': 26, 'b': 27, 'c': 28, 'd': 29, 'e': 30, 'f': 31, 'g': 32, 'h': 33, 'i': 34, 'j': 35, 'k': 36, 'l': 37, 'm': 38, 'n': 39, 'o': 40, 'p': 41, 'q': 42, 'r': 43, 's': 44, 't': 45, 'u': 46, 'v': 47, 'w': 48, 'x': 49, 'y': 50, 'z': 51, '0': 52, '1': 53, '2': 54, '3': 55, '4': 56, '5': 57, '6': 58, '7': 59, '8': 60, '9': 61, '-': 62, '!': 63, '=': 0 }; var base64_enc = { 0: 'A', 1: 'B', 2: 'C', 3: 'D', 4: 'E', 5: 'F', 6: 'G', 7: 'H', 8: 'I', 9: 'J', 10: 'K', 11: 'L', 12: 'M', 13: 'N', 14: 'O', 15: 'P', 16: 'Q', 17: 'R', 18: 'S', 19: 'T', 20: 'U', 21: 'V', 22: 'W', 23: 'X', 24: 'Y', 25: 'Z', 26: 'a', 27: 'b', 28: 'c', 29: 'd', 30: 'e', 31: 'f', 32: 'g', 33: 'h', 34: 'i', 35: 'j', 36: 'k', 37: 'l', 38: 'm', 39: 'n', 40: 'o', 41: 'p', 42: 'q', 43: 'r', 44: 's', 45: 't', 46: 'u', 47: 'v', 48: 'w', 49: 'x', 50: 'y', 51: 'z', 52: '0', 53: '1', 54: '2', 55: '3', 56: '4', 57: '5', 58: '6', 59: '7', 60: '8', 61: '9', 62: '-', 63: '!' }; function base64_elshift(m, i, sh) { return (m.charCodeAt(i) << sh) & 63; } function base64_ershift(m, i, sh) { return (m.charCodeAt(i) >> sh) & 63; } // Base-64 encode a string, essentially by taking a 3-character block // and turning it into a 4-character block using the base-64 alphabet. // If less than 3 characters exist in the last block, the equal sign is // used as padding (2 equal signs if only 1 character, 1 equal sign if 2 // characters). function base64_encode(message) { var out = ""; var buf0; var buf1; var buf2; var buf3; var i; message = escape_unicode(message); for (i = 0; i < message.length; i += 3) { buf0 = base64_enc[base64_ershift(message, i+0, 2)]; buf2 = "_"; buf3 = "_"; if ((i+1) < message.length) buf1 = base64_enc[base64_elshift(message, i+0, 4) | base64_ershift(message, i+1, 4)]; else buf1 = base64_enc[base64_elshift(message, i+0, 4)]; if ((i+2) < message.length) { buf2 = base64_enc[base64_elshift(message, i+1, 2) | base64_ershift(message, i+2, 6)]; buf3 = base64_enc[base64_elshift(message, i+2, 0)]; } else if ((i+1) < message.length) buf2 = base64_enc[base64_elshift(message, i+1, 2)]; out += buf0 + buf1 + buf2 + buf3; } return out; } function base64_dlshift(c, sh) { return (base64_dec[c] << sh) & 255; } function base64_drshift(c, sh) { return (base64_dec[c] >> sh) & 255; } function base64_decode(message) { var out = ""; var i; // All base-64 blocks are multiples of four characters. Try it: // encode a one-letter string. You'll get four characters // in return. If that's not the case with this message, then it's // not really base-64 encoded (or not encoded correctly). if ((message.length % 4) != 0) return message; // Each block of four encoded characters can be decoded to, at most, // three unencoded ones. (Which makes sense: 4 * 6bits = 24bits, // and 3 * 8bits = 24bits.) The bits in base-64 are encoded // left-to-right, that is, starting with the high-order bit and // moving to the low-order bit. Each number we consider has a bit // mask of 255 applied, so only (low-order) 8 bits are considered at // any given moment. // The equal sign is considered "padding" in an encoded string, but // they also represent the end marker. A block of four bytes with // two equal signs on the end is a signal that only one character is // encoded; with one equal sign, two characters encoded. No equal // sign is necessary if the initial string's length was a multiple // of 3. for (i = 0; i < message.length; i += 4) { out += String.fromCharCode(base64_dlshift(message.charAt(i+0), 2) | base64_drshift(message.charAt(i+1), 4)); if (message.charAt(i+2) == '_') break; out += String.fromCharCode(base64_dlshift(message.charAt(i+1), 4) | base64_drshift(message.charAt(i+2), 2)); if (message.charAt(i+3) == '_') break; out += String.fromCharCode(base64_dlshift(message.charAt(i+2), 6) | base64_drshift(message.charAt(i+3), 0)); } return out; } /* cpaint escapes ampersands, angle brackets, and all non-printables... */ function remove_unicode(message) { if (message == "" || message == null || message == undefined || message == 0) return ""; message = base64_decode(message); message = message.replace(/\\u0026/g, '&'); message = message.replace(/\\u003c\?/g, '<?'); /* */ message = message.replace(/\\u003c[ \t\r\n]*script/gi, '<script'); message = message.replace(/\\u003c[ \t\r\n]*\/[ \t\r\n]*script/gi, '</script'); message = message.replace(/\\u003c/g, '<'); message = message.replace(/\\u003e/g, '>'); message = message.replace(/\\u000a/g, ' '); message = message.replace(/(.*)/, '$2'); return message; } /* * This returns the actual data contained in the given named tag. * If there are several tags with that name, only the first one will * have its data returned. */ function cpaint_node(res, name) { var col; col = res.getElementsByTagName(name); if (col.length < 1 || col[0].firstChild == null) return ""; else { if (col[0].textContent) return col[0].textContent; else return col[0].firstChild.data; } } /* * Cross-browser attempt at supporting the regular function, * document.getElementById(). That function is a DOM-2 level function, * which is something that IE -- even at version 6 -- does not yet fully * support. */ function get_id(id) { if (document.getElementById) return document.getElementById(id); else return document.all[id]; /* probably IE */ } /* * Apparently, IE does not support the (somewhat useful) indexOf method, * which returns the index of a given value in an array. So we've got * to reinvent the wheel here. * * NOTE: this function won't work for an array where the index could be * a string (or for an object with properties, which is essentially the * same thing). In fact, it's probably not a good idea even for an * array where string and numeric indices are mixed. */ function index_of(ary, val) { var i; for (i = 0; i < ary.length; i++) { if (ary[i] == val) return i; } return -1; } function run_command(type, param) { switch (type) { case 'push_url': window.open(param, "_blank"); break; default: break; } } // b64.js var ac_b64_dec = { 'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9, 'K': 10, 'L': 11, 'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17, 'S': 18, 'T': 19, 'U': 20, 'V': 21, 'W': 22, 'X': 23, 'Y': 24, 'Z': 25, 'a': 26, 'b': 27, 'c': 28, 'd': 29, 'e': 30, 'f': 31, 'g': 32, 'h': 33, 'i': 34, 'j': 35, 'k': 36, 'l': 37, 'm': 38, 'n': 39, 'o': 40, 'p': 41, 'q': 42, 'r': 43, 's': 44, 't': 45, 'u': 46, 'v': 47, 'w': 48, 'x': 49, 'y': 50, 'z': 51, '0': 52, '1': 53, '2': 54, '3': 55, '4': 56, '5': 57, '6': 58, '7': 59, '8': 60, '9': 61, '-': 62, '!': 63, '=': 0 }; var ac_b64_enc = { 0: 'A', 1: 'B', 2: 'C', 3: 'D', 4: 'E', 5: 'F', 6: 'G', 7: 'H', 8: 'I', 9: 'J', 10: 'K', 11: 'L', 12: 'M', 13: 'N', 14: 'O', 15: 'P', 16: 'Q', 17: 'R', 18: 'S', 19: 'T', 20: 'U', 21: 'V', 22: 'W', 23: 'X', 24: 'Y', 25: 'Z', 26: 'a', 27: 'b', 28: 'c', 29: 'd', 30: 'e', 31: 'f', 32: 'g', 33: 'h', 34: 'i', 35: 'j', 36: 'k', 37: 'l', 38: 'm', 39: 'n', 40: 'o', 41: 'p', 42: 'q', 43: 'r', 44: 's', 45: 't', 46: 'u', 47: 'v', 48: 'w', 49: 'x', 50: 'y', 51: 'z', 52: '0', 53: '1', 54: '2', 55: '3', 56: '4', 57: '5', 58: '6', 59: '7', 60: '8', 61: '9', 62: '-', 63: '!' }; function ac_b64_elshift(m, i, sh) { return (m.charCodeAt(i) << sh) & 63; } function ac_b64_ershift(m, i, sh) { return (m.charCodeAt(i) >> sh) & 63; } // Base-64 encode a string, essentially by taking a 3-character block // and turning it into a 4-character block using the base-64 alphabet. // If less than 3 characters exist in the last block, the equal sign is // used as padding (2 equal signs if only 1 character, 1 equal sign if 2 // characters). function ac_b64_encode(message) { var out = ""; var buf0; var buf1; var buf2; var buf3; var i; for (i = 0; i < message.length; i += 3) { buf0 = ac_b64_enc[ac_b64_ershift(message, i+0, 2)]; buf2 = "_"; buf3 = "_"; if ((i+1) < message.length) buf1 = ac_b64_enc[ac_b64_elshift(message, i+0, 4) | ac_b64_ershift(message, i+1, 4)]; else buf1 = ac_b64_enc[ac_b64_elshift(message, i+0, 4)]; if ((i+2) < message.length) { buf2 = ac_b64_enc[ac_b64_elshift(message, i+1, 2) | ac_b64_ershift(message, i+2, 6)]; buf3 = ac_b64_enc[ac_b64_elshift(message, i+2, 0)]; } else if ((i+1) < message.length) buf2 = ac_b64_enc[ac_b64_elshift(message, i+1, 2)]; out += buf0 + buf1 + buf2 + buf3; } return out; } function ac_b64_dlshift(c, sh) { return (ac_b64_dec[c] << sh) & 255; } function ac_b64_drshift(c, sh) { return (ac_b64_dec[c] >> sh) & 255; } function ac_b64_decode(message) { var out = ""; var i; // All base-64 blocks are multiples of four characters. Try it: // encode a one-letter string. You'll get four characters // in return. If that's not the case with this message, then it's // not really base-64 encoded (or not encoded correctly). if ((message.length % 4) != 0) return message; // Each block of four encoded characters can be decoded to, at most, // three unencoded ones. (Which makes sense: 4 * 6bits = 24bits, // and 3 * 8bits = 24bits.) The bits in base-64 are encoded // left-to-right, that is, starting with the high-order bit and // moving to the low-order bit. Each number we consider has a bit // mask of 255 applied, so only (low-order) 8 bits are considered at // any given moment. // The equal sign is considered "padding" in an encoded string, but // they also represent the end marker. A block of four bytes with // two equal signs on the end is a signal that only one character is // encoded; with one equal sign, two characters encoded. No equal // sign is necessary if the initial string's length was a multiple // of 3. for (i = 0; i < message.length; i += 4) { out += String.fromCharCode(ac_b64_dlshift(message.charAt(i+0), 2) | ac_b64_drshift(message.charAt(i+1), 4)); if (message.charAt(i+2) == '_') break; out += String.fromCharCode(ac_b64_dlshift(message.charAt(i+1), 4) | ac_b64_drshift(message.charAt(i+2), 2)); if (message.charAt(i+3) == '_') break; out += String.fromCharCode(ac_b64_dlshift(message.charAt(i+2), 6) | ac_b64_drshift(message.charAt(i+3), 0)); } return out; } // str.js function ac_str_trim(str) { return str.replace(/^\s*(\S+)\s*$/, "$1"); } function ac_str_shorten(text, chars) { if ( !chars || chars == 0 ) return text; var textLength = text.length; text += ' '; text = text.substr(0, chars); var lastSpacePos = text.lastIndexOf(' '); if ( lastSpacePos != -1 ) text = text.substr(0, lastSpacePos); if ( textLength > text.length ) text += '...'; return text; } function ac_str_array(str) { var ary = new Array(); for (var i = 0; i < str.length; i++) { if (str[i] == '&') { var tmp = ""; while (i < str.length) { tmp += str[i++]; if (str[i-1] == ';') break; } ary.push(tmp); } else { ary.push(str[i]); } } return ary; } function ac_array_has(ary, val) { for (var i = 0; i < ary.length; i++) { if (ary[i] == val) return true; } return false; } function ac_array_extract(str) { var ary = new Array(); var tmp = str.split("||"); for (var i = 0; i < tmp.length; i++) { var ent = tmp[i].split("=", 2); ary[ent[0]] = ent[1]; } return ary; } function ac_str_array_len(ary) { for (var i = 0, c = 0; i < ary.length; i++) c += ary[i].length; return c; } function ac_str_array_substr(ary, off, len) { var tmp = ""; for (var i = off; i < ary.length; i++) { if (i >= len) break; tmp += ary[i]; } return tmp; } function ac_str_url(rel) { var ary = rel.split("/"); var url = window.location.href.replace(/\/[^\/]*$/, ""); for (var i = 0; i < ary.length; i++) { if (ary[i] == "..") url = url.replace(/\/[^\/]*$/, ""); else url += "/" + ary[i]; } return url; } function ac_ary_last(ary, begin) { var nary = new Array(); for (var i = begin, j = 0; i < ary.length; i++, j++) { nary[j] = ary[i]; } return nary; } function ac_str_rand_password(len) { var out = ""; while (len--) { out += ac_str_rand_passchar(); } return out; } function ac_str_rand_passchar() { var floor = Math.floor(Math.random() * 10.0); var chr; if (floor > 6) { chr = Math.floor(Math.random() * 10.0); chr = chr.toString(); } else { var off = Math.floor(Math.random() * 100.0) % 26; chr = "a".charCodeAt(0) + off; chr = String.fromCharCode(chr); } return chr; } function ac_sprintf(fmt, args) { var out; var argi; out = ""; argi = 0; for (var i = 0; i < fmt.length; i++) { var fmtc = fmt.charAt(i); switch (fmtc) { case "\\": i++; break; case "%": if (argi < args.length) { fmtc = fmt.charAt(i+1); out += ac_sprintf_spec(fmtc, args[argi]); i++; argi++; } else { out += fmtc; } break; default: out += fmtc; break; } } return out; } function ac_sprintf_spec(ch, arg) { switch (ch) { case "d": case "f": return arg.toString(); case "s": default: return arg; } return ""; } // This code is in the public domain. Feel free to link back to http://jan.moesen.nu/ function sprintf() { if (!arguments || arguments.length < 1 || !RegExp) { return; } var str = arguments[0]; var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; // ' var a = b = [], numSubstitutions = 0, numMatches = 0; while (a = re.exec(str)) { var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; var pPrecision = a[5], pType = a[6], rightPart = a[7]; //alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision); numMatches++; if (pType == '%') { subst = '%'; } else { numSubstitutions++; if (numSubstitutions >= arguments.length) { alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).'); } var param = arguments[numSubstitutions]; var pad = ''; if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1); else if (pPad) pad = pPad; var justifyRight = true; if (pJustify && pJustify === "-") justifyRight = false; var minLength = -1; if (pMinLength) minLength = parseInt(pMinLength); var precision = -1; if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1)); var subst = param; if (pType == 'b') subst = parseInt(param).toString(2); else if (pType == 'c') subst = String.fromCharCode(parseInt(param)); else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0; else if (pType == 'u') subst = Math.abs(param); else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); else if (pType == 'o') subst = parseInt(param).toString(8); else if (pType == 's') subst = param; else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); } str = leftpart + subst + rightPart; } return str; } /* * This is the function that actually highlights a text string by * adding HTML tags before and after all occurrences of the search * term. You can pass your own tags if you'd like, or if the * highlightStartTag or highlightEndTag parameters are omitted or * are empty strings then the default tags will be used. */ function ac_str_highlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) { // the highlightStartTag and highlightEndTag parameters are optional if ((!highlightStartTag) || (!highlightEndTag)) { highlightStartTag = ""; highlightEndTag = ""; } // find all occurences of the search term in the given text, // and add some "highlight" tags to them (we're not using a // regular expression search, because we want to filter out // matches that occur within HTML tags and script blocks, so // we have to do a little extra validation) var newText = ""; var i = -1; var lcSearchTerm = searchTerm.toLowerCase(); var lcBodyText = bodyText.toLowerCase(); while (bodyText.length > 0) { i = lcBodyText.indexOf(lcSearchTerm, i+1); if (i < 0) { newText += bodyText; bodyText = ""; } else { // skip anything inside an HTML tag if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) { if ( // skip anything inside a