function OnlyNumber()
{	
	var tecla = window.event.keyCode;
	if (!((tecla == 8) || (tecla == 9) || (((tecla - 48) >= 0) && ((tecla - 48) <= 9))))
		window.event.keyCode = 0;
}

function OnlyNumberAndDotComa()
{	
	var tecla = window.event.keyCode;
	if (!((tecla == 8) || (tecla == 9) || (((tecla - 48) >= 0) && ((tecla - 48) <= 9)) || (tecla == 46) || (tecla == 44)))
		window.event.keyCode = 0;
}

function OnlyNumberAndComa()
{	
	var tecla = window.event.keyCode;
	if (!((tecla == 8) || (tecla == 9) || (((tecla - 48) >= 0) && ((tecla - 48) <= 9)) || (tecla == 44)))
		window.event.keyCode = 0;
}

function OnlyNumberAndDot()
{	
	var tecla = window.event.keyCode;
	if (!((tecla == 8) || (tecla == 9) || (((tecla - 48) >= 0) && ((tecla - 48) <= 9)) || (tecla == 46)))
		window.event.keyCode = 0;
}

function RoundNumero(Numero)
{
	// SE QUITAN LOS PUNTOS
	var punto = Numero.indexOf('.');
	while (punto != -1)
	{
		Numero = Numero.substring(0, punto) + Numero.substring(punto + 1, Numero.length);
		punto = Numero.indexOf('.');
	}
	// SE REEMPLAZAN LAS COMAS POR PUNTOS
	var re = /,/g;
	Numero = Numero.replace(re, ".")
	if (isNaN(Numero))
		return 0;
	// SE REDONDEA
	return (Math.round(Numero));
}

//**********************************
// DEVUELVE UN NUMERO FORMATEADO
function GetNumFormateado(numero,milessep,comasep)
{
	numero=numero+"";
	// SE QUITAN LOS PUNTOS

	var punto = numero.indexOf(milessep);
	while (punto != -1)
	{
		numero = numero.substring(0, punto) + numero.substring(punto + 1, numero.length);
		punto = numero.indexOf(milessep);
	}

	// SE LE QUITAN LAS COMAS
	var aux=numero;
	punto = aux.indexOf(comasep);
	while (punto != -1)
	{
		aux = aux.substring(0, punto) + aux.substring(punto + 1, aux.length);
		punto = aux.indexOf(comasep);
	}
	// SE COMPRUEBA QUE SEA NUMERICO
	if (isNaN(aux))
		return "";
	
	var coma = numero.indexOf(comasep);
	if (coma == 0)
		return ('0' + numero);		

	var num = "";
	var decimal = "";	
	var coma = numero.indexOf(comasep);
	if (coma != -1)
	{		
		decimal = ',' + numero.substring(coma + 1, coma + 3);
		numero = numero.substring(0, coma);
	}
	else 
		decimal = '';
	if (numero != '')
	{
		var str = "";
		while (numero > 999)
		{
			n1 = Math.floor(numero/1000);
			n2 = numero - 1000 * n1;
			if (n2 < 10)
				 n2 = "00" + n2;
			else
			{
				if (n2 < 100)
				n2 = "0" + n2;
			}
			str = "." + n2 + str;
			numero = n1;		
		}
		str = numero + str;		
	}
	return (str + decimal);
}

function JSstrReplace(cadena, target, bomb)
{
	return cadena.replace(target, bomb);
}