	function Habilitar(b, objeto)
	{
		objeto.disabled = !b.checked;
	}

	function EsVacio(Campo, Caja, Valor)
	{
		OK = true;
		
		if (Valor == "") 
		{
			alert("No se permite dejar el campo "+Campo+" vacio");
			Caja.setfocus;
			Caja.select();
			OK = false;
		}
		else
		    OK = true;

		return OK;
	}

	function EsRadioVacio(Campo, Caja, Valor)
	{
		var Indice = 0;
		
		OK = false;
		while (Caja[Indice] != undefined)
		{
			if (Caja[Indice].checked) OK = true;
			Indice++;
		}
		
		if (OK == false) alert("Se debe marcar al menos una opción de "+Campo);
		
		return OK;

	}

	function AValor(Cadena)
	{
		var Nueva = '';
		var strCheck = '0123456789-.';
		
		for (i = 0; i <= Cadena.length; i++)
		{
			C = Cadena.charAt(i);
			if (strCheck.indexOf(C) != -1) Nueva = Nueva + C;
		}
		
		return Nueva;
	}	

	function DelimitaString(fld, Max)
	{
		var key = '';
		len = fld.length;
		
		if (len >= Max) return false;
		
		return true;
	}	
	
	function SoloDigitos(e) 
	{
		var strCheck = '0123456789';
		var whichCode = (window.Event) ? e.which : e.keyCode;
		if (whichCode == 13) return true;  // Enter
		key = String.fromCharCode(whichCode);  // Get key value from key code
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key

		return true;
	}

	function DigitosDecimales(e) 
	{
		var strCheck = '0123456789.-';
		var whichCode = (window.Event) ? e.which : e.keyCode;
		if (whichCode == 13) return true;  // Enter
		key = String.fromCharCode(whichCode);  // Get key value from key code
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key

		return true;
	}

	function Enviar(f, Boton, ID)
	{
		var Accion = document.getElementById("POOKY_ACCION");
		
		Accion.value = Boton
		f.Boton.value = Boton;
		f.id.value = ID;		

		f.submit();
	}

	function CadenaMoneda(Cadena)
	{
		return (Cadena);
	}

	function MonedaCadena(Cadena)
	{
		Original =  Cadena;
		Entera = parseInt(Cadena);
		MiCadena = '' + Entera;
		Decimal = parseFloat(Cadena) - parseInt(Cadena);
		Decimal = 100 * Decimal;
		Decimal = Math.ceil(Decimal);
		
		Tam = MiCadena.length;
		CadenaInversa = '';
		C = 1;
		for (i = 0; i < Tam; i++)
		{
			if (C == 4) { CadenaInversa = CadenaInversa + '.'; C = 1; }
			CadenaInversa = CadenaInversa + MiCadena.charAt(Tam -  i - 1);			
			C++;
		}

		CadenaReversa = '';
		Tam = CadenaInversa.length;
		for (i = 0; i < Tam; i++)
		{
			CadenaReversa = CadenaReversa + CadenaInversa.charAt(Tam -  i - 1);			
		}

		if (Decimal > 0) CadenaReversa +=  ',' +  Decimal;

		return (CadenaReversa);
	}

	function NormalizaString(Cadena)
	{
		return Cadena.substring(0, 254);
	}

	function EsDigito(C)
	{
		if (C < "0" || C > "9") 
			return false;
		else 
		    return true;
	}

	function EsEntero(Campo, Caja, Vacio)
	{
		Cadena = Caja.value;
		if (Cadena == "" && Vacio == false) 
		{
			alert("Campo Vacio");
			Caja.focus();
			Caja.select();
			return false;
		}

		for (var i = 0; i < Cadena.length; i++) 
		{
			C = Cadena.charAt(i);
			if (!EsDigito(C)) 
			{
				if (i == 0 && (C == "+" || C == "-"))
				{
					// El primer caracter puede ser un menos
				}
				else
				{
					alert("El valor de " + Campo + " (" + Cadena + "), no es un dato adecuado, debe ser numérico.");
					Caja.focus();
					Caja.select();
					return false;
				}
	        }
	    }
	    return true;
	}

	function EsDecimal(Campo, Caja, Vacio)
	{
		Cadena = Caja.value;
		PuntoYaVisto = false;
		if (Cadena == "" && Vacio == false) 
		{
			alert("Campo Vacio");
			Caja.focus();
			Caja.select();
			return false;
		}

		for (var i = 0; i < Cadena.length; i++) 
		{
			C = Cadena.charAt(i);
			if (!EsDigito(C)) 
			{
				if (i == 0 && (C == "+" || C == "-" || C == "."))
				{
					// El primer caracter puede ser un menos
					if (C == ".") PuntoYaVisto = true;
				}
				else
				{
					if (C == "." && !PuntoYaVisto)
					{
						PuntoYaVisto = true;
					}
					else
					{
						alert("El valor de "+ Campo + " (" + Cadena + "), no es un dato adecuado, debe ser decimal.");
						Caja.focus();
						Caja.select();
						return false;
					}
				}
	        }
	    }
	    return true;
	}

