	<!--
	// ==============================================================================
	// FUNCIONES EXPORTADAS
	// ==============================================================================
	// function FUNCIONES_AcortarFecha(strFECHA)
	// function resaltarItemMenu(src, color)
	// function normalItemMenu(src, blnForce, color)
	// function MarcarItemMenu(src)
	// function GotoURL(strURL, strParametros, destino)
	// function GotoURLVentanaCompleta(strURL, strParametros, destino)
	// function isEmailAddr(email)
	// function DoShowTooltip(layer, strCadena)
	// function VaciarListBox(control)
	// function QuitarValorListBox(Control)
	// function QuitarValorListBoxPorValor(Control, ID)
	// function AgregarValorListbox(control, ID, VALOR, blnPermitirRepeticion, blnAvisoDuplicado)
	// function DameControl(formulario, strNombreControl)
	// function FormatNumber(VALOR)
	// function damenumeroJScript(strNumero)
	// function round(num, dec, blnPuntosMil)
	// function puntosMil(cadena)
	// function replace(strCadena, strBuscada, strReemplazada)
	// function SeleccionPorValor(control, VALOR, ForceCheck)
	// function SeleccionPorValorV2(control, VALOR, ForceCheck)
	// function ObtenerObjetoPorValor(control, valor)
	// function SeleccionarTodo(control)
	// function SeleccionarNinguno(control)
	// function InvertirSeleccion(control)
	// function CancelarSeleccion(control)
	// function RetornaSeleccionados(control, separador)
	// function ContarSeleccionados(control)
	// function SeleccionAleatoria(control)
	// function AbrirVentana(strURL, strParametros, W, H)
	// function isEmailAddr(email)
	// function ObtenerTextoCombo(nombrecombo)

	// Copyright Best Business Service 2004.
	// Rev: 20021028
	// Add: 20021120
	// Add: 20021121
	// Add: 20021202
	// Add: 20040514

		function FUNCIONES_ResaltarBotonNaranja(strID, strPathDominio, blnEstadoTrueFalse)
		{
			if (blnEstadoTrueFalse)
			{
				document.getElementById("BTNLEFT" + strID.toString()).src= strPathDominio + "images/version7.1/botonnaranjaizquierda2.gif";
				document.getElementById("BTNCENTER" + strID.toString()).style.backgroundImage = "url('" + strPathDominio + "images/version7.1/botonnaranjacentro2.gif')";
				document.getElementById("BTNRIGHT" + strID.toString()).src= strPathDominio + "images/version7.1/botonnaranjaderecha2.gif";
			}
			else
			{
				document.getElementById("BTNLEFT" + strID.toString()).src= strPathDominio + "images/version7.1/botonnaranjaizquierda.gif";
				document.getElementById("BTNCENTER" + strID.toString()).style.backgroundImage = "url('" + strPathDominio + "images/version7.1/botonnaranjacentro.gif')";
				document.getElementById("BTNRIGHT" + strID.toString()).src= strPathDominio + "images/version7.1/botonnaranjaderecha.gif";
			}
		}

		function FUNCIONES_DateDiffDias(_FECHAINI, _FECHAFIN)
		{
			// The number of milliseconds in one day
			var ONE_DAY = 1000 * 60 * 60 * 24;

			// Convert both dates to milliseconds
			var date1_ms = _FECHAINI.getTime();
			var date2_ms = _FECHAFIN.getTime();

			// Calculate the difference in milliseconds
			var difference_ms = Math.abs(date1_ms - date2_ms);

			// Convert back to days and return
			return Math.round(difference_ms/ONE_DAY);
		}

		function FUNCIONES_FechaCMP2Object(FECHACMP)
		{
			_ano = Number(FECHACMP.substr(0,4));
			_mes = Number(FECHACMP.substr(4,2));
			_dia = Number(FECHACMP.substr(6,2));

			// Esto es porque Javascript los meses empiezan desde cero
			_mes = parseInt(_mes) - 1;		

			return(new Date(_ano,_mes,_dia));
		}

		function FUNCIONES_FechaObject2CMP(_objFecha)
		{
			_ano = _objFecha.getFullYear().toString();
			_mes = _objFecha.getMonth().toString();
			_dia = _objFecha.getDate().toString();

			// Esto es porque Javascript los meses empiezan desde cero
			_mes = parseInt(_mes) + 1;
			_mes = _mes.toString();

			if (_mes.length==1) _mes = "0" + _mes;
			if (_dia.length==1) _dia = "0" + _dia;

			return( _ano + _mes + _dia );

		}

		function FUNCIONES_FechaCMP2Cadena(FECHACMP)
		{
			// Formato entrada: aaaammdd
			// Formato salida: dd/mm/aaaa
			return( FECHACMP.substr(6,2) + "/" + FECHACMP.substr(4,2) + "/" + FECHACMP.substr(0,4))

		}

		function FUNCIONES_AcortarFecha(strFECHA)
		{
			// Formato entrada: dd/mm/aaaa
			// Formato salida:  dd/mm/aa
			return( strFECHA.substr(0,6) + strFECHA.substr(8,2) )
		}

		function FUNCIONES_HoraCMP2Hora(HORACMP)
		{
			_HORA = parseInt(HORACMP / 60);
			_MINUTO = HORACMP % 60;
			
			if(_HORA<10) _HORA = "0" + _HORA;
			if(_MINUTO<10) _MINUTO = "0" + _MINUTO;
			
			return(_HORA + ":" + _MINUTO);
		}

		var OLD_ColorItemMenu="";
		var OLD_CFontItemMenu="";
		var ItemSeleccionado="";
		var OLD_BordeItem;
		function resaltarItemMenu(src, color){
			if (ItemSeleccionado!=src)
			{
				if (color==null) color="#cccccc"
				OLD_ColorItemMenu=src.style.background;
				OLD_CFontItemMenu=src.style.color;
				OLD_BordeItem=src.style.border;
				src.style.background=color;
				src.style.color="000080";
				src.style.border="1px solid #000000";
			}
		}

		function normalItemMenu(src, blnForce, color){
			if (blnForce==null) blnForce=false
			if (src!=""){
				if (ItemSeleccionado!=src){
					if (color==null) color="#f9f9ff";
					src.style.color=OLD_CFontItemMenu;
					src.style.background=OLD_ColorItemMenu;
					//src.style.border="1px solid " + color;
					src.style.border=OLD_BordeItem;
				}
			}
		}

		var OLD_ColorElementoMarcado;
		var OLD_ColorTextoElementoMarcado;
		var OLD_BordeMarcado;
		function MarcarItemMenu(src){
			if (ItemSeleccionado!=src){
				if (ItemSeleccionado!=""){
					ItemSeleccionado.style.color=OLD_CFontItemMenu;
					ItemSeleccionado.style.background=OLD_ColorElementoMarcado;
					ItemSeleccionado.style.border=OLD_BordeItem;
				}
				OLD_ColorElementoMarcado=OLD_ColorItemMenu;
				OLD_ColorTextoElementoMarcado=OLD_CFontItemMenu;
				OLD_BordeMarcado = OLD_BordeItem;
				src.style.border="1px solid #0000ff";
				ItemSeleccionado=src;
			}
		}



		function GotoURL(strURL, strParametros, destino){
			if (destino==null)
			{
				W=screen.width - 10;
				H=screen.Height - 110;
				if (strParametros == null) strParametros='width=' + W + ',height=' + H + ',scrollbars=1,resizable=1,toolbar=1,status=1,menubar=0, top=0, left=0, alwaysRaised=yes';
				window.open(strURL,'',strParametros);
			}
			else
			{
				try
				{
					BESLOADING_Mostrar();
				}
				catch(err){}
				destino.location.replace(strURL);
			}
		}
		
		function GotoURLVentanaCompleta(strURL, strParametros, destino){
			if (destino==null)
			{
				//W=screen.width - 10;
				//H=screen.Height - 110;
				//if (strParametros == null) strParametros='width=' + W + ',height=' + H + ',scrollbars=1,resizable=1,toolbar=1,status=1,menubar=0, top=0, left=0, alwaysRaised=yes';
				//window.open(strURL,'',strParametros);
				window.open(strURL);
			}
			else
			{
				try
				{
					BESLOADING_Mostrar();
				}
				catch(err){}
				destino.location.replace(strURL);
			}
		}		

	        function isEmailAddr(email)
	        {
	                var result = false;
	                var theStr = new String(email);
	                var index = theStr.indexOf("@");

	                if (index > 0)
	                {
	                    var pindex = theStr.indexOf(".",index);

	                    if ((pindex > index+1) && (theStr.length > pindex+1))
		                result = true;
	                }

	                return result;
	        }


		function DoShowTooltip(layer, strCadena){
			if (strCadena!="" && strCadena!=null)
			{
				if (layer.style.display!="")
				{
					document.all[layer.id].innerHTML=strCadena;
					layer.style.display="";
				}
				x = event.x + document.body.scrollLeft;
				y = event.y + document.body.scrollTop;

				// Si se sale fuera de la pantalla por la derecha...
				// Ojo que el ancho del layer está definido en el DIV!!!
				if ((document.body.clientWidth - x) < parseInt(layer.style.width))
				{
					layer.style.top = y;
					layer.style.left = document.body.clientWidth - parseInt(layer.style.width) - 10
				}
				else
				{
					layer.style.top = y;
					layer.style.left = x + 10;
				}
			}
		}

		function VaciarListBox(control){
			if (typeof(control)=="object") control = (control.name)
			for (intIndice=document["frmDatos"][control].length-1; intIndice >=0; intIndice--){
				document["frmDatos"][control][intIndice]=null;
			}
		}

		function QuitarValorListBox(control){

			if (typeof(control)=="object") control = (control.name)

			for (intIndice=document["frmDatos"][control].length-1; intIndice >=0; intIndice--){
				if (document["frmDatos"][control][intIndice].selected){
					document["frmDatos"][control][intIndice]=null;
				}
			}
			intIndice = document["frmDatos"][control].length;
			if (intIndice > 0) document["frmDatos"][control][intIndice-1].selected=true
		}

		function QuitarValorListBoxPorValor(control, ID){
			if (typeof(control)=="object") control = (control.name)
			for (intIndiceAVL=0; intIndiceAVL < document["frmDatos"][control].length; intIndiceAVL++){
				IDACTUAL= document["frmDatos"][control][intIndiceAVL].value;
				if (IDACTUAL==ID){
					document["frmDatos"][control][intIndiceAVL]=null;
				}
			}
		}

		function AgregarValorListbox(control, ID, VALOR, blnPermitirRepeticion, blnAvisoDuplicado){
			if (typeof(control)=="object") control = (control.name)
			blnAgregar=true;
			if (!blnPermitirRepeticion)
			{
				blnExiste=false;
				for (intIndiceAVL=0; intIndiceAVL < document["frmDatos"][control].length; intIndiceAVL++){
					IDACTUAL = document["frmDatos"][control][intIndiceAVL].value;
					if (!blnExiste) blnExiste=(IDACTUAL==ID)
					if (blnExiste){
						if (blnAvisoDuplicado!=null && blnAvisoDuplicado==true)
						{
							alert("El elemento '" + VALOR + "' ya existe en la lista.\nNo se permite agregar elementos repetidos.");
						}
						blnAgregar=false;
						break;
					}
				}
			}

			if (blnAgregar){
				ELEMENTO = new Option(VALOR, ID, false, false);
				intTotal = document["frmDatos"][control].length;
				document["frmDatos"][control][intTotal] = ELEMENTO;
				return(true);
			}
			else
				return(false);
		}

		// ----------------------------------------------------------------
		// RETORNA EL CONTROL (OBJETO) A PARTIR DEL NOMBRE (STRING)
		// ----------------------------------------------------------------
		function DameControl(formulario, strNombreControl){
			return(document.getElementById(strNombreControl))
		}




		function damenumeroJScript(strNumero){
			// ----------------------------------------------------------
			// ENTRA UN NUMERO FORMATEADO 1.234,56 y sale 1234.56
			// RETORNA UN NUMERO EVALUABLE MATEMATICAMENTE POR JAVASCRIPT
			// ----------------------------------------------------------
			strNumero = strNumero.toString();
			strNumero = replace(strNumero,"\\.","");
			strNumero = replace(strNumero,",",".");
			return(Number(strNumero));
		}



		function round(strNumero, decimales, blnPuntosMil){
			if (decimales==null) valor=(Math.round(strNumero))
			if (decimales==1)  valor=(Math.round(strNumero * 10)/10)
			if (decimales==2)  valor=(Math.round(strNumero * 100)/100)
			if (decimales==3)  valor=(Math.round(strNumero * 1000)/1000)
			if (decimales==4)  valor=(Math.round(strNumero * 10000)/10000)
			if (decimales==5)  valor=(Math.round(strNumero * 100000)/100000)
			if (decimales==6)  valor=(Math.round(strNumero * 1000000)/1000000)
			if (decimales==7)  valor=(Math.round(strNumero * 10000000)/10000000)
			if (decimales==8)  valor=(Math.round(strNumero * 100000000)/100000000)
			if (decimales==9)  valor=(Math.round(strNumero * 1000000000)/1000000000)
			if (decimales==10) valor=(Math.round(strNumero * 10000000000)/10000000000)

			if (blnPuntosMil)
				return(formatNumber(valor,"#.###,####"));
			else{
				valor = valor.toString();
				valor = replace(valor,"\\.",",");
				return(valor);
			}
		}



		// -----------------------------------------------------------------------------
		// FUNCIÓN QUE PONE LOS PUNTOS SOBRE UNIDADES MIL, LA ENTRADA HA DE SER UN VALOR
		// NUMERICO VALIDO DE JAVASCRIPT (12345.67) Y LA SALIDA ES (12.345,67)
		// -----------------------------------------------------------------------------
		   // CONSTANTS
		  var separator = ",";  // use comma as 000's separator
		  var decpoint = ".";  // use period as decimal point
		  var percent = "%";
		  var currency = "$";  // use dollar sign for currency

		  function formatNumber(number, format, print) {  // use: formatNumber(number, "format")
		    if (print) document.write("formatNumber(" + number + ", \"" + format + "\")<br>");

		    if (number - 0 != number) return null;  // if number is NaN return null
		    var useSeparator = format.indexOf(separator) != -1;  // use separators in number
		    var usePercent = format.indexOf(percent) != -1;  // convert output to percentage
		    var useCurrency = format.indexOf(currency) != -1;  // use currency format
		    var isNegative = (number < 0);
		    number = Math.abs (number);
		    if (usePercent) number *= 100;
		    format = strip(format, separator + percent + currency);  // remove key characters
		    number = "" + number;  // convert number input to string

		     // split input value into LHS and RHS using decpoint as divider
		    var dec = number.indexOf(decpoint) != -1;
		    var nleftEnd = (dec) ? number.substring(0, number.indexOf(".")) : number;
		    var nrightEnd = (dec) ? number.substring(number.indexOf(".") + 1) : "";

		     // split format string into LHS and RHS using decpoint as divider
		    dec = format.indexOf(decpoint) != -1;
		    var sleftEnd = (dec) ? format.substring(0, format.indexOf(".")) : format;
		    var srightEnd = (dec) ? format.substring(format.indexOf(".") + 1) : "";

		     // adjust decimal places by cropping or adding zeros to LHS of number
		    if (srightEnd.length < nrightEnd.length) {
		      var nextChar = nrightEnd.charAt(srightEnd.length) - 0;
		      nrightEnd = nrightEnd.substring(0, srightEnd.length);
		      if (nextChar >= 5) nrightEnd = "" + ((nrightEnd - 0) + 1);  // round up

		 // patch provided by Patti Marcoux 1999/08/06
		      while (srightEnd.length > nrightEnd.length) {
		        nrightEnd = "0" + nrightEnd;
		      }

		      if (srightEnd.length < nrightEnd.length) {
		        nrightEnd = nrightEnd.substring(1);
		        nleftEnd = (nleftEnd - 0) + 1;
		      }
		    } else {
		      for (var i=nrightEnd.length; srightEnd.length > nrightEnd.length; i++) {
		        if (srightEnd.charAt(i) == "0") nrightEnd += "0";  // append zero to RHS of number
		        else break;
		      }
		    }

		     // adjust leading zeros
		    sleftEnd = strip(sleftEnd, "#");  // remove hashes from LHS of format
		    while (sleftEnd.length > nleftEnd.length) {
		      nleftEnd = "0" + nleftEnd;  // prepend zero to LHS of number
		    }

		    if (useSeparator) nleftEnd = separate(nleftEnd, separator);  // add separator
		    var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : "");  // combine parts
		    output = ((useCurrency) ? currency : "") + output + ((usePercent) ? percent : "");
		    if (isNegative) {
		      // patch suggested by Tom Denn 25/4/2001
		      output = (useCurrency) ? "(" + output + ")" : "-" + output;
		    }
		    output=replace(output,",","|")
		    output=replace(output,"\\.",",")
		    output=replace(output,"\\|",".")
		    return output;
		  }

		  function strip(input, chars) {  // strip all characters in 'chars' from input
		    var output = "";  // initialise output string
		    for (var i=0; i < input.length; i++)
		      if (chars.indexOf(input.charAt(i)) == -1)
		        output += input.charAt(i);
		    return output;
		  }

		  function separate(input, separator) {  // format input using 'separator' to mark 000's
		    input = "" + input;
		    var output = "";  // initialise output string
		    for (var i=0; i < input.length; i++) {
		      if (i != 0 && (input.length - i) % 3 == 0) output += separator;
		      output += input.charAt(i);
		    }
		    return output;
		  }





		// ------------------------------
		// FUNCIÓN REPLACE ESTILO VSCRIPT
		// ------------------------------
		function replace(strCadena, strBuscada, strReemplazada){
			strBusca = new RegExp (strBuscada,"gi");
			strResultado=strCadena.replace(strBusca,strReemplazada);
			return(strResultado);
		}



		// -------------------------------------------
		// SELECCION POR VALOR
		// -------------------------------------------
		function SeleccionPorValor(control, VALOR, forcecheck)
		{
			if (forcecheck==null) forcecheck=false
			if (control != null){
				if (typeof(control)=="object"){
					if (control.length==null)
						control = (control.name)
					else
						control = (control[0].name)
				}
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;
					if (isNaN(intTope))
					{
						if (forcecheck)
						{
							if (document["frmDatos"][control].value==VALOR) document["frmDatos"][control].checked = true
						}
						else
						{
							if (document["frmDatos"][control].value==VALOR) document["frmDatos"][control].checked = ! document["frmDatos"][control].checked;
						}
					}
					else
					{
						for (intIndiceSeleccionPorValor=0; intIndiceSeleccionPorValor <=intTope; intIndiceSeleccionPorValor++)
						{
							if (forcecheck)
							{
								if (document["frmDatos"][control][intIndiceSeleccionPorValor].value==VALOR) document["frmDatos"][control][intIndiceSeleccionPorValor].checked = true
							}
							else
							{
								if (document["frmDatos"][control][intIndiceSeleccionPorValor].value==VALOR) document["frmDatos"][control][intIndiceSeleccionPorValor].checked = ! document["frmDatos"][control][intIndiceSeleccionPorValor].checked ;
							}
						}
					}
				}
			}
		}

		// -------------------------------------------
		// DESELECCION POR VALOR
		// -------------------------------------------
		function DeseleccionPorValor(control, VALOR, forcecheck)
		{
			if (forcecheck==null) forcecheck=false
			if (control != null){
				if (typeof(control)=="object"){
					if (control.length==null)
						control = (control.name)
					else
						control = (control[0].name)
				}
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;
					if (isNaN(intTope)){
						if (forcecheck)
						{
							if (document["frmDatos"][control].value==VALOR) document["frmDatos"][control].checked = false
						}
						else
						{
							if (document["frmDatos"][control].value==VALOR) document["frmDatos"][control].checked = ! document["frmDatos"][control].checked;
						}
					}
					else
					{
						for (intIndiceSeleccionPorValor=0; intIndiceSeleccionPorValor <=intTope; intIndiceSeleccionPorValor++){
							if (forcecheck)
							{
								if (document["frmDatos"][control][intIndiceSeleccionPorValor].value==VALOR) document["frmDatos"][control][intIndiceSeleccionPorValor].checked = false
							}
							else
							{
								if (document["frmDatos"][control][intIndiceSeleccionPorValor].value==VALOR) document["frmDatos"][control][intIndiceSeleccionPorValor].checked = ! document["frmDatos"][control][intIndiceSeleccionPorValor].checked ;
							}
						}
					}
				}
			}
		}

		// -------------------------------------------
		// SELECCION POR TAG
		// -------------------------------------------
		function SeleccionPorTag(control, VALOR, forcecheck)
		{
			if (forcecheck==null) forcecheck=false
			if (control != null){
				if (typeof(control)=="object"){
					if (control.length==null)
						control = (control.name)
					else
						control = (control[0].name)
				}
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;
					if (isNaN(intTope))
					{
						if (forcecheck)
						{
							if (document["frmDatos"][control].tag==VALOR) document["frmDatos"][control].checked = true
						}
						else
						{
							if (document["frmDatos"][control].tag==VALOR) document["frmDatos"][control].checked = ! document["frmDatos"][control].checked;
						}
					}
					else
					{
						for (intIndiceSeleccionPorValor=0; intIndiceSeleccionPorValor <=intTope; intIndiceSeleccionPorValor++)
						{
							if (forcecheck)
							{
								if (document["frmDatos"][control][intIndiceSeleccionPorValor].tag==VALOR) document["frmDatos"][control][intIndiceSeleccionPorValor].checked = true
							}
							else
							{
								if (document["frmDatos"][control][intIndiceSeleccionPorValor].tag==VALOR) document["frmDatos"][control][intIndiceSeleccionPorValor].checked = ! document["frmDatos"][control][intIndiceSeleccionPorValor].checked ;
							}
						}
					}
				}
			}
		}

		// -------------------------------------------
		// DESELECCION POR TAG
		// -------------------------------------------
		function DeseleccionPorTag(control, VALOR, forcecheck)
		{
			if (forcecheck==null) forcecheck=false
			if (control != null){
				if (typeof(control)=="object"){
					if (control.length==null)
						control = (control.name)
					else
						control = (control[0].name)
				}
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;
					if (isNaN(intTope)){
						if (forcecheck)
						{
							if (document["frmDatos"][control].tag==VALOR) document["frmDatos"][control].checked = false
						}
						else
						{
							if (document["frmDatos"][control].tag==VALOR) document["frmDatos"][control].checked = ! document["frmDatos"][control].checked;
						}
					}
					else
					{
						for (intIndiceSeleccionPorValor=0; intIndiceSeleccionPorValor <=intTope; intIndiceSeleccionPorValor++){
							if (forcecheck)
							{
								if (document["frmDatos"][control][intIndiceSeleccionPorValor].tag==VALOR) document["frmDatos"][control][intIndiceSeleccionPorValor].checked = false
							}
							else
							{
								if (document["frmDatos"][control][intIndiceSeleccionPorValor].tag==VALOR) document["frmDatos"][control][intIndiceSeleccionPorValor].checked = ! document["frmDatos"][control][intIndiceSeleccionPorValor].checked ;
							}
						}
					}
				}
			}
		}

		function ObtenerObjetoPorValor(control, valor)
		{
			if (control != null)
			{
				if (typeof(control)=="object")
				{
					if (control.length==null)
						control = (control.name)
					else
						control = (control[0].name)
				}

				intTope = document["frmDatos"][control].length - 1;
				if (isNaN(intTope)){
					return(document["frmDatos"][control])
				}else{
					for (intIndiceSeleccionPorValor=0; intIndiceSeleccionPorValor <=intTope; intIndiceSeleccionPorValor++){
						if (document["frmDatos"][control][intIndiceSeleccionPorValor].value==valor)  return (document["frmDatos"][control][intIndiceSeleccionPorValor])
					}
				}
			}

		}

		// -------------------------------------------
		// CHEQUEA TODOS LOS ELEMENTOS DE "CONTROL"
		// -------------------------------------------
		function SeleccionarTodo(control)
		{
			if (typeof(control)=="object")
			{
				if (control.length==null)
					control = (control.name)
				else
					control = (control[0].name)
			}

			if (control != "")
			{
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;

					if (isNaN(intTope))
					{
						if (! document["frmDatos"][control].disabled) document["frmDatos"][control].checked = true;
					}
					else
					{
						for (intIndiceSeleccionarTodo=0; intIndiceSeleccionarTodo <=intTope; intIndiceSeleccionarTodo++)
						{
							if (! document["frmDatos"][control][intIndiceSeleccionarTodo].disabled)
							{
								document["frmDatos"][control][intIndiceSeleccionarTodo].checked = true;
							}
						}
					}
				}
			}
		}


		// -------------------------------------------
		// DESCHEQUEA TODOS LOS ELEMENTOS DE "CONTROL"
		// -------------------------------------------
		function SeleccionarNinguno(control){
			if (typeof(control)=="object")
			{
				if (control.length==null)
				{
					control = (control.name)
				}
				else
				{
					control = (control[0].name)
				}
			}

			if (control != "")
			{
				arrElements = document.getElementsByName(control);
				intTope = arrElements.length - 1;
				if (isNaN(intTope) || intTope == 0){
					document.getElementById(control).checked = false;
				}
				else
				{
					for (intIndiceSeleccionarNinguno=0; intIndiceSeleccionarNinguno <=intTope; intIndiceSeleccionarNinguno++)
					{
						arrElements[intIndiceSeleccionarNinguno].checked = false;
					}
				}
			}
		}

		// -------------------------------------------
		// DESHABILITA TODOS LOS ELEMENTOS DE "CONTROL"
		// -------------------------------------------
		function DeshabilitarTodos(control)
		{
			if (typeof(control)=="object")
			{
				if (control.length==null)
					control = (control.name)
				else
					control = (control[0].name)
			}

			if (control != "")
			{
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;
					
					if (isNaN(intTope))
					{
						document["frmDatos"][control].disabled = true;
					}
					else
					{
						for (intIndiceSeleccionarNinguno=0; intIndiceSeleccionarNinguno <=intTope; intIndiceSeleccionarNinguno++)
						{
							document["frmDatos"][control][intIndiceSeleccionarNinguno].disabled = true;
						}
					}
				}
			}
		}

		// -------------------------------------------
		// DESHABILITA TODOS LOS ELEMENTOS DE "CONTROL"
		// -------------------------------------------
		function HabilitarTodos(control)
		{
			if (typeof(control)=="object")
			{
				if (control.length==null)
					control = (control.name)
				else
					control = (control[0].name)
			}

			if (control != "")
			{
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;
					
					if (isNaN(intTope))
					{
						document["frmDatos"][control].disabled = false;
					}
					else
					{
						for (intIndiceSeleccionarNinguno=0; intIndiceSeleccionarNinguno <=intTope; intIndiceSeleccionarNinguno++)
						{
							document["frmDatos"][control][intIndiceSeleccionarNinguno].disabled = false;
						}
					}
				}
			}
		}

		// -------------------------------------------
		// HABILITAR POR VALOR
		// -------------------------------------------
		function HabilitarPorValor(control, VALOR)
		{
			if (control != null)
			{
				if (typeof(control)=="object")
				{
					if (control.length==null)
						control = (control.name);
					else
						control = (control[0].name);
				}
				
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;

					if (isNaN(intTope))
					{
						if (document["frmDatos"][control].value==VALOR) 
							document["frmDatos"][control].disabled = false;
					}
					else
					{
						for (intIndiceSeleccionPorValor=0; intIndiceSeleccionPorValor <=intTope; intIndiceSeleccionPorValor++)
						{
							if (document["frmDatos"][control][intIndiceSeleccionPorValor].value==VALOR) 
								document["frmDatos"][control][intIndiceSeleccionPorValor].disabled = false;
						}
					}
				}
			}
		}

		// -------------------------------------------
		// DESHABILITAR POR VALOR
		// -------------------------------------------
		function DeshabilitarPorValor(control, VALOR)
		{
			if (control != null)
			{
				if (typeof(control)=="object")
				{
					if (control.length==null)
						control = (control.name);
					else
						control = (control[0].name);
				}
				
				if (document["frmDatos"][control])
				{
					intTope = document["frmDatos"][control].length - 1;

					if (isNaN(intTope))
					{
						if (document["frmDatos"][control].value==VALOR) 
							document["frmDatos"][control].disabled = true;
					}
					else
					{
						for (intIndiceSeleccionPorValor=0; intIndiceSeleccionPorValor <=intTope; intIndiceSeleccionPorValor++)
						{
							if (document["frmDatos"][control][intIndiceSeleccionPorValor].value==VALOR) 
								document["frmDatos"][control][intIndiceSeleccionPorValor].disabled = true;
						}
					}
				}
			}
		}

		// -------------------------------------------------
		// INVIERTE EL CHEQUEO DE LOS ELEMENTOS DE "CONTROL"
		// -------------------------------------------------
		function InvertirSeleccion(control){
			if (typeof(control)=="object"){
				if (control.length==null)
					control = (control.name)
				else
					control = (control[0].name)
			}
			if (control != ""){
				intTope = document["frmDatos"][control].length - 1;
				if (isNaN(intTope)){
					document["frmDatos"][control].checked = ! document["frmDatos"][control].checked;
				}
				else
				{
					for (intIndiceInvertirSeleccion=0; intIndiceInvertirSeleccion <=intTope; intIndiceInvertirSeleccion++){
						document["frmDatos"][control][intIndiceInvertirSeleccion].checked = ! document["frmDatos"][control][intIndiceInvertirSeleccion].checked;
					}
				}
			}
		}


		// -------------------------------------------------
		// DESCHEQUEA TODOS LOS ELEMENTOS DE "CONTROL"
		// -------------------------------------------------
		function CancelarSeleccion(control){
			SeleccionarNinguno(control)
		}



		// -----------------------------------------------------------------------------------
		// RETORNA EN FORMA DE LISTA SEPARADA POR COMAS LOS ELEMENTOS SELECCIONADOS (EL VALUE)
		// -----------------------------------------------------------------------------------
		function RetornaSeleccionados(control, separador){
			if (separador==null || separador == undefined) separador=",";
			LSTIDResultante="";
			if (typeof(control)=="object"){
				if (control.length==null)
					control = (control.name)
				else
					control = (control[0].name)
			}

			//if (document["frmDatos"][control] != null){
			if (document.getElementsByName(control) != null){
				//intTope = document["frmDatos"][control].length - 1;
				intTope = document.getElementsByName(control).length - 1;
				if (isNaN(intTope)){
					//if (document["frmDatos"][control].checked == true) LSTIDResultante = document["frmDatos"][control].value;
					if (document.getElementsByName(control).checked == true) LSTIDResultante = document.getElementsByName(control).value;
				}
				else
				{
					for (intIndiceRetornarSeleccionados=0; intIndiceRetornarSeleccionados <=intTope; intIndiceRetornarSeleccionados++){
						//if (document["frmDatos"][control][intIndiceRetornarSeleccionados].checked == true){
						if (document.getElementsByName(control)[intIndiceRetornarSeleccionados].checked == true){
							if (LSTIDResultante=="")
								//LSTIDResultante = document["frmDatos"][control][intIndiceRetornarSeleccionados].value;
								LSTIDResultante = document.getElementsByName(control)[intIndiceRetornarSeleccionados].value;
							else
								//LSTIDResultante = LSTIDResultante + separador + document["frmDatos"][control][intIndiceRetornarSeleccionados].value
								LSTIDResultante = LSTIDResultante + separador + document.getElementsByName(control)[intIndiceRetornarSeleccionados].value
						}
					}
				}
			}
			return(LSTIDResultante);
		}


		// -------------------------------------------------
		// RETORNA EL VALOR DE TAG DE LOS ELEMENTOS SELECCIONADOS (CHECKS O RADIOS)
		// -------------------------------------------------
		function RetornaSeleccionadosTag(control, separador){
			if (separador==null) separador=",";
			LSTIDResultante="";
			if (typeof(control)=="object"){
				if (control.length==null)
					control = (control.name)
				else
					control = (control[0].name)
			}

			if (document["frmDatos"][control] != null){
				intTope = document["frmDatos"][control].length - 1;
				if (isNaN(intTope)){
					if (document["frmDatos"][control].checked == true) LSTIDResultante = document["frmDatos"][control].tag;
				}
				else
				{
					for (intIndiceRetornarSeleccionadosTag=0; intIndiceRetornarSeleccionadosTag <=intTope; intIndiceRetornarSeleccionadosTag++){
						if (document["frmDatos"][control][intIndiceRetornarSeleccionadosTag].checked == true){
							if (LSTIDResultante=="")
								LSTIDResultante = document["frmDatos"][control][intIndiceRetornarSeleccionadosTag].tag;
							else
								LSTIDResultante = LSTIDResultante + separador + document["frmDatos"][control][intIndiceRetornarSeleccionadosTag].tag
						}
					}
				}
			}
			return(LSTIDResultante);
		}


		// -------------------------------------------
		// CUENTA EL NUMERO DE ELEMENTOS SELECCIONADOS
		// -------------------------------------------
		function ContarSeleccionados(control){
			var intContados = 0;
			if (typeof(control) == "object")
			{
				if (control.length == null)
				{
					control = (control.name)
				}
				else
				{
					control = (control[0].name)
				}
			}

			if (document.getElementsByName(control) != null){
				intTope = document.getElementsByName(control).length - 1;
				if (isNaN(intTope))
				{
					if (document.getElementsByName(control).checked == true)
					{
						intContados = 1;
					}
				}
				else
				{
					for (intIndiceContarSeleccionados=0; intIndiceContarSeleccionados <=intTope; intIndiceContarSeleccionados++)
					{
						if (document.getElementsByName(control)[intIndiceContarSeleccionados].checked == true)
						{
							intContados++;
						}
					}
				}
			}
			return intContados;
		}


		// RETORNA N ELEMENTOS SELECCIONADOS
		function SeleccionAleatoria(control){

			if (control!=null)
			{
				MAXPREGUNTAS = control.length;
				if (MAXPREGUNTAS==null) MAXPREGUNTAS=1;
				strCUANTOS=prompt("¿Cuantos quieres seleccionar aleatoriamente?\nRecuerda que solo hay " + MAXPREGUNTAS + " elementos disponibles en total.","");
				if (strCUANTOS!="" & strCUANTOS!=null && strCUANTOS!=0){
					if (parseInt(strCUANTOS) <= parseInt(MAXPREGUNTAS)){

						while (ContarSeleccionados(control) < strCUANTOS)
						{
							intNumero=Math.random();
							intContador=(intNumero * (MAXPREGUNTAS-1));
							intTope=control.length - 1;
							if (isNaN(intTope)){
								control.checked = true;
							}
							else
							{
								control(intContador).checked=true;
							}

						}

						alert("Se ha seleccionado: " + ContarSeleccionados(control) + " elementos.")
					}
					else
						alert("Valor incorrecto.")
				}
			}
		}

		// CHEQUEA UN ELEMENTO DEL CONTROL "control", blnforce indica si fuerza a estar chequeado
		function CheckItem(control, valor, blnForce){
			if (control!=null)
			{
				if (control.length != null)
				{
					for (intIndiceCheckItem=0; intIndiceCheckItem <= control.length-1; intIndiceCheckItem++)
					{
						if (control[intIndiceCheckItem].value == valor)
						{
							if (blnForce)
							{
								control[intIndiceCheckItem].checked=true;
							}
							else
							{
								control[intIndiceCheckItem].checked = (!control[intIndiceCheckItem].checked);
							}
							break;
						}
					}
				}
				else
				{
					if (blnForce)
					{
						control.checked = true;
					}
					else
					{
						control.checked = (!control.checked);
					}
				}
			}
		}




		// -------------------------------------------
		// Abre ls URL con ventana tipo ZOOM
		// -------------------------------------------
		function AbrirVentana(strURL, strParametros, W, H)
		{
			popup = window.open('/Dummie.htm','',strParametros);
			zoom(strURL, popup, W, H)
		}

		function zoom(strURL, popup, W, H){
			CX = (screen.availwidth/2) - (W/2);
			CY = (screen.availHeight/2) - (H/2);
			popup.moveTo(CX,CY);
			popup.resizeTo(W, H);
			popup.location.replace(strURL)
			WActual=100;
			HActual=100;
		}


		// COMPRUEBA QUE SEA VALIDO UN EMAIL DADO
	        function isEmailAddr(email)
	        {
	                var result = false;
	                var theStr = new String(email);
	                var index = theStr.indexOf("@");

	                if (index > 0)
	                {
	                    var pindex = theStr.indexOf(".",index);

	                    if ((pindex > index+1) && (theStr.length > pindex+1))
		                result = true;
	                }

	                return result;
	        }

                // This script and many more are available free online at
                // The JavaScript Source!! http://javascript.internet.com

                function textCounter(field, countfield, maxlimit)
                {
                        if (field.value.length > maxlimit)      // if too long...trim it!
                                field.value = field.value.substring(0, maxlimit);
                        else                                    // otherwise, update 'characters left' counter
                                countfield.value = maxlimit - field.value.length;
                }

		// RETORNA EL TEXTO DEL COMBO INDICADO SEGUN SELECCION ACTUAL
		function ObtenerTextoCombo(nombrecombo){
			if(document.getElementById(nombrecombo).selectedIndex != -1){
				return(document.getElementById(nombrecombo).item(document.getElementById(nombrecombo).selectedIndex).text);
			}
		}

		function FUNCIONES_PosicionEnArray(ValorBuscar, ArrayBuscado)
		{
			var intReturn = -1;
			if (ArrayBuscado.constructor == Array)
			{
				iTotal = ArrayBuscado.length;
				for (iCount = 0; iCount < iTotal; iCount++)
				{
					if (ArrayBuscado[iCount] == ValorBuscar)
					{
						intReturn = iCount;
						break;
					}
					else
					{
						intReturn = -1;
					}
				}
			}
			else
			{
				window.alert("Se debe especificar el array en el que buscar.");
				blnReturn = false;
			}
			return intReturn;
		}

		// Prototipos de funciones muy utiles sacados de la web:
		// http://www.anieto2k.com/2007/03/09/10-utilidades-javascript-que-deberias-conocer/
		
		//	htmlEntities()
		//	---------------------------------------------------------------------------
		//	Versión en javascript de esta función de PHP con el mismo nombre, que te convierte los 
		//	tags HTML a carácteres carácteres imprimibles.
		//
		//	Uso:
		//	var tmp = '<html><head></head>';
		//	var safe= tmp.htmlEntities(); // Returns &lt;html&gt;&lt;head&gt;&lt;/head&gt;
	
		String.prototype.htmlEntities = function () 
		{
//		   return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');


//function htmlentities (string, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: nobbler
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlentities('Kevin & van Zonneveld');
    // *     returns 1: 'Kevin &amp; van Zonneveld'
    // *     example 2: htmlentities("foo'bar","ENT_QUOTES");
    // *     returns 2: 'foo&#039;bar'
 
    var quote_style="ENT_QUOTES";
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = this.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
//}




		};
	
		//	stripTags()
		//	---------------------------------------------------------------------------
		//	Nos elimina las etiquetas HTML de nuestros textos.
		//
		//	Uso:
		//	var tmp = '<a href="htpp://somespammer.com">Some Link</a>';
		//	var safe= tmp.stripTags(); // Returns Some Link;
		
		String.prototype.stripTags = function () {
		   return this.replace(/<([^>]+)>/g,'');
		}

		//	stripTags()
		//	---------------------------------------------------------------------------
		//	Nos elimina las etiquetas HTML de nuestros textos.
		//
		//	Uso:
		//	var tmp = '<a href="htpp://somespammer.com">Some Link</a>';
		//	var safe= tmp.stripTags(); // Returns Some Link;

		String.prototype.html_entity_decode = function ()
		{
			// Convert all HTML entities to their applicable characters 
			//
			// version: 901.714
			// discuss at: http://phpjs.org/functions/html_entity_decode
			// +   original by: john (http://www.jd-tech.net)
			// +      input by: ger
			// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
			// +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
			// +   bugfixed by: Onno Marsman
			// +   improved by: marc andreu
			// +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
			// -    depends on: get_html_translation_table
			// *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
			// *     returns 1: 'Kevin & van Zonneveld'
			// *     example 2: html_entity_decode('&amp;lt;');
			// *     returns 2: '&lt;'
			var quote_style = "ENT_QUOTES";
			var histogram = {}, symbol = '', tmp_str = '', entity = '';
			tmp_str = this.toString();

			if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) 
			{
				return false;
			}

			// &amp; must be the last character when decoding!
			delete(histogram['&']);
			histogram['&'] = '&amp;';

			for (symbol in histogram) 
			{
				entity = histogram[symbol];
				tmp_str = tmp_str.split(entity).join(symbol);
			}
     
			return tmp_str;
		}

		function get_html_translation_table(table, quote_style) 
		{
		    // http://kevin.vanzonneveld.net
		    // +   original by: Philip Peterson
		    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   bugfixed by: noname
		    // +   bugfixed by: Alex
		    // +   bugfixed by: Marco
		    // +   bugfixed by: madipta
		    // %          note: It has been decided that we're not going to add global
		    // %          note: dependencies to php.js. Meaning the constants are not
		    // %          note: real constants, but strings instead. integers are also supported if someone
		    // %          note: chooses to create the constants themselves.
		    // %          note: Table from http://www.the-art-of-web.com/html/character-codes/
		    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
		    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
		    
		    var entities = {}, histogram = {}, decimal = 0, symbol = '';
		    var constMappingTable = {}, constMappingQuoteStyle = {};
		    var useTable = {}, useQuoteStyle = {};
		    
		    useTable      = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS');
		    useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT');
		    
		    // Translate arguments
		    constMappingTable[0]      = 'HTML_SPECIALCHARS';
		    constMappingTable[1]      = 'HTML_ENTITIES';
		    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
		    constMappingQuoteStyle[2] = 'ENT_COMPAT';
		    constMappingQuoteStyle[3] = 'ENT_QUOTES';
		    
		    // Map numbers to strings for compatibilty with PHP constants
		    if (!isNaN(useTable)) {
		        useTable = constMappingTable[useTable];
		    }
		    if (!isNaN(useQuoteStyle)) {
		        useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
		    }
		 
		    if (useTable == 'HTML_SPECIALCHARS') {
		        // ascii decimals for better compatibility
		        entities['38'] = '&amp;';
		        if (useQuoteStyle != 'ENT_NOQUOTES') {
		            entities['34'] = '&quot;';
		        }
		        if (useQuoteStyle == 'ENT_QUOTES') {
		            entities['39'] = '&#039;';
		        }
		        entities['60'] = '&lt;';
		        entities['62'] = '&gt;';
		    } else if (useTable == 'HTML_ENTITIES') {
		        // ascii decimals for better compatibility
		      entities['38']  = '&amp;';
		        if (useQuoteStyle != 'ENT_NOQUOTES') {
		            entities['34'] = '&quot;';
		        }
		        if (useQuoteStyle == 'ENT_QUOTES') {
		            entities['39'] = '&#039;';
		        }
		      entities['60']  = '&lt;';
		      entities['62']  = '&gt;';
		      entities['160'] = '&nbsp;';
		      entities['161'] = '&iexcl;';
		      entities['162'] = '&cent;';
		      entities['163'] = '&pound;';
		      entities['164'] = '&curren;';
		      entities['165'] = '&yen;';
		      entities['166'] = '&brvbar;';
		      entities['167'] = '&sect;';
		      entities['168'] = '&uml;';
		      entities['169'] = '&copy;';
		      entities['170'] = '&ordf;';
		      entities['171'] = '&laquo;';
		      entities['172'] = '&not;';
		      entities['173'] = '&shy;';
		      entities['174'] = '&reg;';
		      entities['175'] = '&macr;';
		      entities['176'] = '&deg;';
		      entities['177'] = '&plusmn;';
		      entities['178'] = '&sup2;';
		      entities['179'] = '&sup3;';
		      entities['180'] = '&acute;';
		      entities['181'] = '&micro;';
		      entities['182'] = '&para;';
		      entities['183'] = '&middot;';
		      entities['184'] = '&cedil;';
		      entities['185'] = '&sup1;';
		      entities['186'] = '&ordm;';
		      entities['187'] = '&raquo;';
		      entities['188'] = '&frac14;';
		      entities['189'] = '&frac12;';
		      entities['190'] = '&frac34;';
		      entities['191'] = '&iquest;';
		      entities['192'] = '&Agrave;';
		      entities['193'] = '&Aacute;';
		      entities['194'] = '&Acirc;';
		      entities['195'] = '&Atilde;';
		      entities['196'] = '&Auml;';
		      entities['197'] = '&Aring;';
		      entities['198'] = '&AElig;';
		      entities['199'] = '&Ccedil;';
		      entities['200'] = '&Egrave;';
		      entities['201'] = '&Eacute;';
		      entities['202'] = '&Ecirc;';
		      entities['203'] = '&Euml;';
		      entities['204'] = '&Igrave;';
		      entities['205'] = '&Iacute;';
		      entities['206'] = '&Icirc;';
		      entities['207'] = '&Iuml;';
		      entities['208'] = '&ETH;';
		      entities['209'] = '&Ntilde;';
		      entities['210'] = '&Ograve;';
		      entities['211'] = '&Oacute;';
		      entities['212'] = '&Ocirc;';
		      entities['213'] = '&Otilde;';
		      entities['214'] = '&Ouml;';
		      entities['215'] = '&times;';
		      entities['216'] = '&Oslash;';
		      entities['217'] = '&Ugrave;';
		      entities['218'] = '&Uacute;';
		      entities['219'] = '&Ucirc;';
		      entities['220'] = '&Uuml;';
		      entities['221'] = '&Yacute;';
		      entities['222'] = '&THORN;';
		      entities['223'] = '&szlig;';
		      entities['224'] = '&agrave;';
		      entities['225'] = '&aacute;';
		      entities['226'] = '&acirc;';
		      entities['227'] = '&atilde;';
		      entities['228'] = '&auml;';
		      entities['229'] = '&aring;';
		      entities['230'] = '&aelig;';
		      entities['231'] = '&ccedil;';
		      entities['232'] = '&egrave;';
		      entities['233'] = '&eacute;';
		      entities['234'] = '&ecirc;';
		      entities['235'] = '&euml;';
		      entities['236'] = '&igrave;';
		      entities['237'] = '&iacute;';
		      entities['238'] = '&icirc;';
		      entities['239'] = '&iuml;';
		      entities['240'] = '&eth;';
		      entities['241'] = '&ntilde;';
		      entities['242'] = '&ograve;';
		      entities['243'] = '&oacute;';
		      entities['244'] = '&ocirc;';
		      entities['245'] = '&otilde;';
		      entities['246'] = '&ouml;';
		      entities['247'] = '&divide;';
		      entities['248'] = '&oslash;';
		      entities['249'] = '&ugrave;';
		      entities['250'] = '&uacute;';
		      entities['251'] = '&ucirc;';
		      entities['252'] = '&uuml;';
		      entities['253'] = '&yacute;';
		      entities['254'] = '&thorn;';
		      entities['255'] = '&yuml;';
		    } else {
		        throw Error("Table: "+useTable+' not supported');
		        return false;
		    }
		    
		    // ascii decimals to real symbols
		    for (decimal in entities) {
		        symbol = String.fromCharCode(decimal);
		        histogram[symbol] = entities[decimal];
		    }
		    
		    return histogram;
		}

		//	Trim() 
		//	---------------------------------------------------------------------------
		//	Trim es una función que nos permite eliminar los carácteres en blanco al principio y fin de una cadena.
		//
		//	Uso:
		//	var test = "   Test   ";
		//	var test1 = test.ltrim();   // returns "Test   "
		//	var test2 = test.rtrim();   // returns "   Test"
		//	var test3 = test.trim();    // returns "Test"

		String.prototype.trim = function() { //Trim ambas direcciones
		   return this.replace(/^\s+|\s+$/g,"");
		}
		
		String.prototype.leftTrim = function() { //Trim izquierda
		   return this.replace(/^\s+/g,"");
		}
		
		String.prototype.rightTrim = function() { //Trim Derecha
		   return this.replace(/\s+$/g,"");
		}

		//	sortNum()
		//	---------------------------------------------------------------------------
		//	sortNum() es una función que nos permite ordenar un array de forma numérica.
		//
		//	Uso:
		//	var tmp = [5,9,12,18,56,1,10,42,30,7,97,53,33,35,27];
		//	tmp=tmp.sortNum(); // returns 1,5,7,9,10,12,18,27,30,33,35,42,53,56,97 
		
		Array.prototype.sortNum = function() {
		   return this.sort( function (a,b) { return a-b; } );
		}

		//	formatNumber()
		//	---------------------------------------------------------------------------
		//	formatNumber() nos permite formatear la salida de un número al formato que queramos.
		//
		//	Uso:
		//	var test1 = formatNumber('5123456789.25'); // returns 5,123,456,789.25
		//	var test2 = formatNumber(1234.15,'$');     // returns $1,234.15
		//	var test3 = unformatNumber('$1,234.15');   // returns 1234.15
		
		function formatNumber(num,prefix){
		   prefix = prefix || '';
		   num += '';
		   var splitStr = num.split('.');
		   var splitLeft = splitStr[0];
		   var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : '';
		   var regx = /(\d+)(\d{3})/;
		   while (regx.test(splitLeft)) {
		      splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
		   }
		   return prefix + splitLeft + splitRight;
		}
		
		function unformatNumber(num) {
		   return num.replace(/([^0-9\.\-])/g,'')*1;
		}

		//	Array.find()
		//	---------------------------------------------------------------------------
		//	find() como una extensión del objeto array, nos permite realizar una busqueda en nuestros arrays.
		//
		//	Uso:
		//	var tmp = [5,9,12,18,56,1,10,42,'blue',30, 7,97,53,33,30,35,27,30,'35','Ball','bubble'];
		//             0/1/2 /3 /4 /5/6 /7 /8     /9 /10/11/12/13/14/15/16/17/18  /19    /20
		//	var thirty=tmp.find(30);         	 // Returns 9, 14, 17
		//	var thirtyfive=tmp.find('35');       // Returns 18
		//	var thirtyfive=tmp.find(35);         // Returns 15
		//	var haveBlue=tmp.find('blue');       // Returns 8
		//	var notFound=tmp.find('not there!'); // Returns false
		//	var regexp1=tmp.find(/^b/);          // returns 8,20    (first letter starts with b)
		//	var regexp1=tmp.find(/^b/i);         // returns 8,19,20 (same as above but ignore case) 
		
		Array.prototype.find = function(searchStr) {
		  var returnArray = false;
		  for (i=0; i<this.length; i++) {
		    if (typeof(searchStr) == 'function') {
		      if (searchStr.test(this[i])) {
		        if (!returnArray) { returnArray = [] }
		        returnArray.push(i);
		      }
		    } else {
		      if (this[i]===searchStr) {
		        if (!returnArray) { returnArray = [] }
		        returnArray.push(i);
		      }
		    }
		  }
		  return returnArray;
		}

		//	isArray()
		//	---------------------------------------------------------------------------
		//	Nos devuelve true si se trata de un array.
		//
		//	Uso:
		//	var tmp = [5,9,12,18,'blue',30,7,97,53,33,30,35,27,30];
		//	var tmp2 = {0:5,1:9,2:12}
		//	test1 = isArray(tmp);    // returns true
		//	test2 = isArray(tmp2);   // returns false;
		
		function isArray(testObject) {
		    return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';
		}
		
		//	map()
		//	---------------------------------------------------------------------------
		//	Map() es una función que nos permite hacer pasar una función determinada a todos los elementos de un array().
		//
		//	var tmp = ['now', 'is', '   the   ', 'time    ', '    for ',  ' all', ' good ', '   men   '];
		//	var test = tmp.map(trim);  // returns now,is,the,time,for,all,good,men
		 
		Array.prototype.map = function(f)
		{
			var returnArray=[];
			
			for (i=0; i<this.length; i++) 
			{
				returnArray.push(f(this[i]));
			}
		
			return returnArray;
		}

		//	getCSSRule(), killCSSRule(), addCSSRule()
		//	---------------------------------------------------------------------------
		//	Se trata de un paquete de funciones que nos ayudan a manejar las hojas de estilos css de una forma más cómoda. 
		//
		//	Uso: 
		// 		devuelve el objeto para la clase "fancyStyle"
		//		fancyStyleObject=getCSSRule('fancyStyle');
		//
		//		aplica la propiedad underline a la decoración del texto del objeto anterior
		//		fancyStyleObject.style.textDecoration='underline'
		//
		//		Elimina la clase "fancyStyle" eliminado los estilos aplicados al objeto.
		//		killCSSRule('fancyStyle');
		//
		//		Crea un nueva regla stylesheet para los parrafos.
		//		newStyle=addCSSRule('p');
		//
		//		Cambia todos los parrafos anteriores al color azul.
		//		newStyle.style.color='blue';
		//
		//		Creamos una nueva CSS class llamada fancyStyle.
		//		newStyle=addCSSRule('.fancyStyle');
		//
		//		Aplicamos un fondo verde a todos los elementos con la clase fancyStyle.
		//		newStyle.backgroundColor='green';
		
		function getCSSRule(ruleName, deleteFlag) 
		{
			if (document.styleSheets) 
			{
				for (var i=0; i<document.styleSheets.length; i++) 
				{
					var styleSheet=document.styleSheets[i];
					var ii=0;
					var cssRule=false;
					
					do 
					{
						if (styleSheet.cssRules) 
						{
							cssRule = styleSheet.cssRules[ii];
						}
						else
						{
							cssRule = styleSheet.rules[ii];
						}
						
						if (cssRule)  
						{
							if (cssRule.selectorText==ruleName) 
							{
								if (deleteFlag=='delete') 
								{
									if (styleSheet.cssRules) 
									{
										styleSheet.deleteRule(ii);
									}
									else
									{
										styleSheet.removeRule(ii);
									}
									
									return true;
								}
								else
								{
									return cssRule;
								}
							}
						}
						
						ii++;
					}
					while (cssRule)
				}
			}
		
			return false;
		}
		
		function killCSSRule(ruleName) 
		{
			return getCSSRule(ruleName,'delete');
		}
		
		function addCSSRule(ruleName) 
		{
			if (document.styleSheets) 
			{
		    	if (!getCSSRule(ruleName)) 
		    	{
					if (document.styleSheets[0].addRule) 
					{
						document.styleSheets[0].addRule(ruleName, null,0);
					}
					else
					{
						document.styleSheets[0].insertRule(ruleName+' { }', 0);
					}
				}
			}
			return getCSSRule(ruleName);
		}

	//-->
