/* GZIP by Raccoon Framework */ /** * @version 1.2 (29/Nov/2006/1757) * @author Alejandro -aztkgeek- Galindo * @copyright Copyright (C) 2006 Web Technologies Networks S.A. de C.V. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * Raccoon is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. * * @class RCN * Esta libreria se llama RCN por que es la abreviacion de Raccoon y su finalidad * es el de hacer mas facil y sencillo la programacion en JavaScript basandose en * el YUI, ya que YUI es excelente, pero es muy tedioso estar escribiendo los nombres * largos, o por ejemplo el hacer una conexion es mas sencillo con RCN.request * * @todo Hay que incluir el RUI en esta libreria y ya no darle continuidad al RUI * * @requires YUI.yahoo * @requires YUI.dom * @requires YUI.event * @requires YUI.connection */ function RCN_DEFINITION() { this.init(); this.config = { debug : false, requestPath : '', lang : 'es_MX' }; } RCN_DEFINITION.prototype = { /** * @constructor */ init : function() { }, /** * */ log : function(message) { if (RCN.config.debug) { if (navigator.appName.indexOf("Explorer") > -1) { if (typeof(RCN.console) === "undefined") { RCN.console = window.open("", "console", "width=600,height=300,scrollbars=yes,resizable=yes"); } if (RCN.console) { RCN.console.document.write(message + "
\n"); } } else { console.log(message); } } }, /** * Contraccion de YAHOO.util.Event.addListener */ listener : function(element, my_event, callback, scope, in_scope) { YAHOO.util.Event.addListener(element, my_event, callback, scope, in_scope); }, on : function(element, my_event, callback, scope, in_scope) { YAHOO.util.Event.addListener(element, my_event, callback, scope, in_scope); }, onReady : function(element, my_event, scope, override) { YAHOO.util.Event.onContentReady(element, my_event, scope, override); }, /** * Contraccion de YAHOO.util.Dom.get */ getBy : function(who) { return YAHOO.util.Dom.get(who); }, /** * Devuelve o establece el valor de un input a traves del id */ valueById : function(element, new_value) { if (!RCN.isUndefined(new_value)) { document.getElementById(element).value = new_value; return true; } else { return document.getElementById(element).value; } return false; }, /** * Convierte una cadena normal en utf8, util para cuando se envian * caracteres no ascii al servidor, como acentos, ñ * @param {Object} value_tmp */ encodeUTF8 : function(value_tmp) { var value_out = ""; for (var i = 0; i < value_tmp.length; i++) { if ( (value_tmp.charCodeAt(i) > 0 && value_tmp.charCodeAt(i) < 48) || (value_tmp.charCodeAt(i) > 57 && value_tmp.charCodeAt(i) < 65) || (value_tmp.charCodeAt(i) > 90 && value_tmp.charCodeAt(i) < 97) || (value_tmp.charCodeAt(i) > 122) ) { value_out += '\\u00' + RCN.dec2hex(value_tmp.charCodeAt(i)); } else { value_out += value_tmp[i]; } } RCN.log("Encode UTF8 Old: " + value_tmp + " New: " + value_out); return value_out; }, /** * Decimal a Hexadecimal * @param {Object} dec */ dec2hex : function(dec) { var Char_hexadecimales = "0123456789abcdef"; var low = dec % 16; var high = (dec - low)/16; var hex = "" + Char_hexadecimales.charAt(high) + Char_hexadecimales.charAt(low); return hex; }, /** * Contraccion de YAHOO.util.Dom.getElementsByClassName */ getByClass : function(class_name, tag_name, container) { return YAHOO.util.Dom.getElementsByClassName(class_name, tag_name, container); }, /** * Contraccion de YAHOO.util.Dom.setStyle o YAHOO.util.Dom.getStyle depende el contexto */ style : function(elementos, propiedad, valor) { if (!RCN.isUndefined(valor)) { YAHOO.util.Dom.setStyle(elementos, propiedad, valor); } else { return YAHOO.util.Dom.getStyle(elementos, propiedad); } return true; }, /** * Contraccion de YAHOO.util.Dom.setY o YAHOO.util.Dom.getY depende el contexto */ y : function(elemento, valor) { if (!RCN.isUndefined(valor)) { YAHOO.util.Dom.setY(elemento, valor); } else { return YAHOO.util.Dom.getY(elemento); } return true; }, /** * Contraccion de YAHOO.util.Dom.setX o YAHOO.util.Dom.getX depende el contexto */ x : function(elemento, valor) { if (!RCN.isUndefined(valor)) { YAHOO.util.Dom.setX(elemento, valor); } else { return YAHOO.util.Dom.getX(elemento); } return true; }, /** * Purga el contenido o los nodos hijos de un nodo, util para cuando un elmento * funje como contenedor y se necesita que se limpie cada ves que se usa */ clean : function(elemento) { elemento = RCN.getBy(elemento); while (elemento.firstChild) { RCN.purgeEvent(elemento.firstChild); elemento.removeChild(elemento.firstChild); } }, /** * @author Douglas Crockford (2006) * From: "The Theory of the DOM" * Recorre los hijos de un nodo de manera recursiva y cada vez que visita un nodo * ejecuta la funcion que se le paso por parametro */ walkDOM : function(node, func) { func(node); node = node.firstChild; while (node) { RCN.walkDOM(node, func); node = node.nextSibling; } }, /** * @author Douglas Crockford (2006) * From: "The Theory of the DOM" * Elimina los manejadores de eventos que tiene registrados un elemento, util a la * hora de borrar un elemento, ya que el no hacer esto conlleva a que se genere basura * en la memoria */ purgeEvent : function(node) { RCN.walkDOM(node, function (e) { for (var n in e) { if (typeof e[n] === 'function') { e[n] = null; } } }); }, /** * Alternativa al innerHTML */ innerXML : function(element_id, content_string) { var range = document.createRange(); var element = document.getElementById(element_id); range.setStartBefore(element); xml_fragment = range.createContextualFragment(content_string); RCN.clean(element); element.appendChild(xml_fragment); }, /** * Reemplaza un elemento sin necesidad de senalar el padre que lo contiene * util para los navegadores que se basan en el estandar, donde en algunas ocaciones el nodo padre * es un caracter de espacio */ replaceChild : function(new_child, old_child) { RCN.purgeEvent(old_child); old_child.parentNode.replaceChild(new_child, old_child); }, /** * Borra un elemento junto con sus manejadores de eventos */ removeChild : function(old_child) { RCN.purgeEvent(old_child); old_child.parentNode.removeChild(old_child); }, /** * Creacion de elementos en el DOM a traves de un objeto * Forma clasica para crear una imagen: *
	 *   var img = document.createElement("img");
	 *   img.setAttribute("src", "ruta de la imagen");
	 *   img.className = "nombre de la clase";
	 * 
* Nueva forma: *
	 *   var img = RCN.create({_type:'img', src:'ruta de la imagen', _class:'nombre de la clase'});
	 * 
*/ create : function(config) { var element = false; if (config._type) { element = document.createElement(config._type); for (var property in config) { if (RCN.isString(property)) { if (property != "_type" && property != "_class") { element.setAttribute(property, config[property]); } } if (RCN.isFunction(config[property])) { RCN.listener(element, property, config[property]); } } if (config._class) { element.className = config._class; } return element; } else { return element; } }, /** * Version corregida y aumentada del metodo create * @param {Object} schema */ append : function(schema, into) { var element = null; if (schema.text) { element = document.createTextNode(schema.text); } else if (schema.tag) { element = document.createElement(schema.tag); schema.tag = null; if (schema.className) { element.className = schema.className; schema.className = null; } if (schema.childs) { if (RCN.isArray(schema.childs)) { for (var child in schema.childs) { if (schema.childs[child].tag || schema.childs[child].text) { if (!RCN.isUndefined(into)) { RCN.append(schema.childs[child], element); } else { element.appendChild(RCN.append(schema.childs[child])); } } } } schema.childs = null; } for (var property in schema) { if (RCN.isString(schema[property])) { element.setAttribute(property, schema[property]); } if (RCN.isFunction(schema[property])) { RCN.listener(element, property, schema[property]); } } } if (!RCN.isUndefined(into)) { into.appendChild(element); } else { return element; } }, createText : function(string_to_create) { return document.createTextNode(string_to_create); }, /** * Recorre un arreglo y valida si tiene o no el elemento del parametro */ inArray : function(needle, haystack) { for (var i = 0; i < haystack.length; i++) { if (haystack[i] == needle) { return true; } } return false; }, /** * Copyright Crockford * http://javascript.crockford.com/remedial.html */ isAlien : function(a) { return RCN.isObject(a) && typeof a.constructor != 'function'; }, isArray : function(a) { return RCN.isObject(a) && a.constructor == Array; }, isBoolean : function(a) { return typeof a === 'boolean'; }, isEmpty : function(o) { var i, v; if (RCN.isObject(o)) { for (i in o) { v = o[i]; if (RCN.isUndefined(v) && RCN.isFunction(v)) { return false; } } } return true; }, isFunction : function(a) { return typeof a === 'function'; }, isNull : function(a) { return a === null; }, isSet : function(a) { return !RCN.isNull(a); }, isNumber : function(a) { return typeof a == 'number' && isFinite(a); }, isObject : function(a) { return (a && typeof a == 'object') || RCN.isFunction(a); }, isString : function(a) { return typeof a == 'string'; }, isUndefined : function(a) { return typeof a == 'undefined'; }, /** * http://www.quirksmode.org/js/cookies.html */ cookies : { create : function(name,value,days) { var expires = null; if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); expires = "; expires="+date.toGMTString(); } else { expires = ""; } document.cookie = name+"="+value+expires+"; path=/"; }, read : function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1,c.length); } if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length,c.length); } } return null; }, erase : function(name) { RCN.cookies.create(name,"",-1); } }, centerIntoBody : function(element) { RCN.on(window, "load", function() { scope.center(element); }, scope); RCN.on(window, "resize", function() { scope.center(element); }, scope); var scope = { center : function(element) { element = RCN.getBy(element); var sizes = RCN.getWindowDimentions(); sizes.left = (sizes.width / 2) - (element.clientWidth / 2); sizes.top = (sizes.height / 2) - (element.clientHeight / 2); RCN.style(element, "position", "absolute"); RCN.style(element, "left", sizes.left + "px"); RCN.style(element, "top", sizes.top + "px"); } }; }, toBodySize : function(element) { RCN.on(window, "load", function() { scope.resize(element); }, scope); RCN.on(window, "resize", function() { scope.resize(element); }, scope); var scope = { resize : function(element) { element = RCN.getBy(element); var sizes = RCN.getWindowDimentions(); RCN.style(element, "position", "absolute"); RCN.style(element, "width", sizes.width + "px"); RCN.style(element, "height", sizes.height + "px"); } }; }, getWindowDimentions : function() { var sizes = { width : 0, height : 0 }; if (window.innerWidth) { sizes.width = window.innerWidth; sizes.height= window.innerHeight; } else if (document.documentElement.clientWidth) { sizes.width = document.documentElement.clientWidth; sizes.height = document.documentElement.clientHeight; } return sizes; }, getRandom : function(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); }, token : function(to_set_token) { var token_value = ( (new Date()).valueOf() ); if (!RCN.isUndefined(to_set_token)) { token_value = to_set_token + "?token=" + token_value; } return token_value; }, /** * Version de Raccoon de la propuesta de JSONRequest * * Realiza una solicitud a un recurso remoto y el resultado lo intenta convertir a JSON * * Uso: *
	 *   RCN.request({
	 *     method : "GET",
	 *     recurso : "script.php",
	 *     variable : "valor de la variable", // Esta variable se pasa por query string
	 *     callbacks : {
	 *       success : function(o) {
	 *         // responseRaccoon es el objeto que contiene el resultado del servidor
	 *         RCN.log(o.responseRaccoon.toSource());
	 *       }
	 *     }
	 *   });
	 * 
* * Basado sobre YAHOO.util.Connect */ request : function(config) { if (!YAHOO.util.Connect) { RCN.include.js("yui.connection"); } var method = "GET"; var callbacks = {}; var resource = "manager.php"; var properties = ""; // Set the properties for (var property in config) { if (property != "toSource" && property != "callbacks" && property != "method" && property != "form" && property != "resource" && property != "extend" && property.length > 0 && !RCN.isFunction(property)) { if (properties.length > 0) { properties += "&"; } properties += property + "=" + config[property]; } } if (config.resource) { resource = config.resource; } // Set the method if (config.method) { method = config.method; } // Set the form if are assigned if (config.form) { var form = config.form; if (typeof(config.form) === "string") { form = document.getElementById(config.form); } var isUpload = false; if (config.formUpload) { isUpload = true; } YAHOO.util.Connect.setForm(form, isUpload); } // Callbacks if (config.callbacks) { for (var callback in config.callbacks) { if (typeof(config.callbacks[callback]) == "function") { callbacks[callback] = config.callbacks[callback]; } } } // Overwrite onSuccess var user_success = null; if (callbacks.success) { user_success = callbacks.success; } callbacks.success = function(o) { if (o.responseText.match("^RDATA")) { eval("var " + o.responseText + ";"); o.responseText = ""; o.responseRaccoon = RDATA; } else { var error_msg = o.status + ": " + o.statusText; RCN.log(error_msg); o.status = "NO"; o.error = o.responseText; } if (user_success) { user_success(o); } }; // Overwrite onUpload var user_upload = null; if (callbacks.upload) { user_upload = callbacks.upload; } callbacks.upload = function(o) { if (o.responseText.match("^RDATA")) { eval("var " + o.responseText + ";"); o.status = "OK"; o.responseText = ""; o.responseRaccoon = RDATA; } else if (o.responseText.match("Permission denied")) { o.status = "NO"; o.error = "Permission denied"; RCN.log("Permission denied"); } else { var error_msg = o.status + ": " + o.statusText; RCN.log(error_msg); o.status = "NO"; o.error = o.responseText; } if (user_upload) { user_upload(o); } }; // Overwrite onSuccess var user_failure = null; if (callbacks.failure) { user_failure = callbacks.failure; } callbacks.failure = function(o) { var error_msg = o.status + ": " + o.statusText + "\n" + o.responseText; RCN.log(error_msg); o.status = "NO"; o.error = o.status + ": " + o.statusText; if (user_failure) { user_failure(o); } }; resource = RCN.config.requestPath + RCN.token(resource) + "&" + properties + "&lang=" + RCN.config.lang; RCN.log(resource); YAHOO.util.Connect.asyncRequest(method, resource, callbacks); }, /** * Incluye un JS o un CSS en el documento en el que se esta trabajando, util para la fatiga * de los paths, ademas de que es util para cargar librerias sobre demanda, ya que se puede * cargar una libreria al ejecutarse alguna accion * * Uso: *
	 * RCN.include.js("archivo.js");
	 * 
* * Que equivale a: *
	 * 
	 * 
* * Basado en: * - http://www.phpied.com/javascript-include/ * - http://dhtmlnirvana.com/content/widgets/jsloader/index.html */ include : { /** * @private */ init : function() { RCN.include.config = { directory_separator : "/", included_files : [], path : "" }; var scripts = document.getElementsByTagName("script"); for (var x = 0; x < scripts.length; x++) { if ( RCN.isSet(scripts[x].getAttribute("src")) ) { if (scripts[x].getAttribute("src").indexOf("rcn.js") > -1) { RCN.include.config.path = scripts[x].getAttribute("src").replace("rcn.js", ""); break; } } } }, /** * Incluye un archivo JS */ js : function(filePath, relative) { if (!RCN.include.config) { RCN.include.init(); } RCN.include.file(filePath, relative, "js"); }, /** * Incluye un archivo CSS */ css : function(filePath, relative) { if (!RCN.include.config) { RCN.include.init(); } RCN.include.file(filePath, relative, "css"); }, /** * @private */ file : function(filePath, relative, extension) { var real_path = filePath.replace(/\./g, RCN.include.config.directory_separator); if (RCN.include.config.path.length > 0) { if (RCN.include.config.path.lastIndexOf("/") + 1 != RCN.include.config.path.length) { RCN.include.config.path += "/"; } } if (RCN.isString(relative)) { real_path = relative + real_path + "." + extension; } else if (relative !== undefined || relative === false) { real_path = real_path + "." + extension; } else { real_path = RCN.include.config.path + real_path + "." + extension; } RCN.include.once(real_path, extension); }, /** * @private */ once : function(script_filename, extension) { if (!RCN.inArray(script_filename, RCN.include.config.included_files)) { RCN.include.config.included_files[RCN.include.config.included_files.length] = script_filename; RCN.include.include_dom(script_filename, extension); } }, /** * @private */ include_dom : function(script_filename, extension) { var html_doc = document.getElementsByTagName('head').item(0); if (extension == "js") { var js_tag = document.createElement('script'); html_doc.appendChild(js_tag); var loader = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); loader.open('GET', script_filename, false); loader.send(null); js_tag.text = loader.responseText; RCN.log("RCN.include_dom.js : " + script_filename); } else { var link_tag = document.createElement('link'); link_tag.setAttribute('rel', 'stylesheet'); link_tag.setAttribute('type', 'text/css'); link_tag.setAttribute('href', script_filename); html_doc.appendChild(link_tag); RCN.log("RCN.include_dom.css : " + script_filename); } return false; } }, MD5 : { /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ /** * hex output format. 0 - lowercase; 1 - uppercase * @type int */ hexcase : 0, /** * base-64 pad character. "=" for strict RFC compliance * @type string */ b64pad : "", /** * bits per input character. 8 - ASCII; 16 - Unicode * @type int */ chrsz : 8, /* * These are the functions you'll usually want to call * They take string arguments and return either hex or base-64 encoded strings */ hex_md5 : function(s) { return this.binl2hex(this.core_md5(this.str2binl(s), s.length * this.chrsz)); }, b64_md5 : function(s) { return this.binl2b64(this.core_md5(this.sstr2binl(s), s.length * this.chrsz)); }, str_md5 : function(s) { return this.binl2str(this.core_md5(this.str2binl(s), s.length * this.chrsz)); }, hex_hmac_md5 : function(key, data) { return this.binl2hex(this.core_hmac_md5(key, data)); }, b64_hmac_md5 : function(key, data) { return this.binl2b64(this.core_hmac_md5(key, data)); }, str_hmac_md5 : function(key, data) { return this.binl2str(this.core_hmac_md5(key, data)); }, /** * Perform a simple self-test to see if the VM is working */ md5_vm_test : function () { return this.hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; }, /** * Calculate the MD5 of an array of little-endian words, and a bit length */ core_md5 : function(x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = this.md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = this.md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = this.md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = this.md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = this.md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = this.md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = this.md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = this.md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = this.md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = this.md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = this.md5_ff(c, d, a, b, x[i+10], 17, -42063); b = this.md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = this.md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = this.md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = this.md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = this.md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = this.md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = this.md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = this.md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = this.md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = this.md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = this.md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = this.md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = this.md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = this.md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = this.md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = this.md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = this.md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = this.md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = this.md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = this.md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = this.md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = this.md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = this.md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = this.md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = this.md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = this.md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = this.md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = this.md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = this.md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = this.md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = this.md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = this.md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = this.md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = this.md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = this.md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = this.md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = this.md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = this.md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = this.md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = this.md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = this.md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = this.md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = this.md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = this.md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = this.md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = this.md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = this.md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = this.md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = this.md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = this.md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = this.md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = this.md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = this.md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = this.safe_add(a, olda); b = this.safe_add(b, oldb); c = this.safe_add(c, oldc); d = this.safe_add(d, oldd); } return [a, b, c, d]; }, /* * These functions implement the four basic operations the algorithm uses. */ md5_cmn : function(q, a, b, x, s, t) { return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s),b); }, md5_ff : function(a, b, c, d, x, s, t) { return this.md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); }, md5_gg : function(a, b, c, d, x, s, t) { return this.md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); }, md5_hh : function(a, b, c, d, x, s, t) { return this.md5_cmn(b ^ c ^ d, a, b, x, s, t); }, md5_ii : function(a, b, c, d, x, s, t) { return this.md5_cmn(c ^ (b | (~d)), a, b, x, s, t); }, /** * Calculate the HMAC-MD5, of a key and some data */ core_hmac_md5 : function(key, data) { var bkey = this.str2binl(key); if(bkey.length > 16) { bkey = this.core_md5(bkey, key.length * this.chrsz); } var ipad = new Array(16), opad = new Array(16); for(var i = 0; i < 16; i++) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = this.core_md5(ipad.concat(this.str2binl(data)), 512 + data.length * this.chrsz); return this.core_md5(opad.concat(hash), 512 + 128); }, /** * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ safe_add : function(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); }, /** * Bitwise rotate a 32-bit number to the left. */ bit_rol : function(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); }, /** * Convert a string to an array of little-endian words * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. */ str2binl : function(str) { var bin = []; var mask = (1 << this.chrsz) - 1; for(var i = 0; i < str.length * this.chrsz; i += this.chrsz) { bin[i>>5] |= (str.charCodeAt(i / this.chrsz) & mask) << (i%32); } return bin; }, /** * Convert an array of little-endian words to a string */ binl2str : function(bin) { var str = ""; var mask = (1 << this.chrsz) - 1; for(var i = 0; i < bin.length * 32; i += this.chrsz) { str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); } return str; }, /** * Convert an array of little-endian words to a hex string. */ binl2hex : function(binarray) { var hex_tab = this.hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; }, /** * Convert an array of little-endian words to a base-64 string */ binl2b64 : function(binarray) { var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var str = ""; for(var i = 0; i < binarray.length * 4; i += 3) { var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); for(var j = 0; j < 4; j++) { if(i * 8 + j * 6 > binarray.length * 32) { str += this.b64pad; } else { str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); } } } return str; } } }; var RCN = new RCN_DEFINITION(); /** * Contraccion of RCN.getBy */ function $(element) { return RCN.getBy(element); } /** * Agregamos el metodo toSource a los navegadores que no lo tienen * * @author holidays-l * http://www14.plala.or.jp/operairc/misc/jsToSource.html */ if (!{}.toSource) { Object.prototype.toSource = function() { var con = this.constructor; var res = null; if(con == String) { return '"' + encodeURI(this) + '"'; } else if(con == Number) { return this; } else if(con == Array) { res = '['; for(var h=0,len=this.length;h