// Formateo de tipos
	
	function formatearCampo(campo,tipo,numeroDecimales){
		valor = formatear(campo.value,tipo,numeroDecimales);
		if (valor != null){
			campo.value = valor;
		}else{
			campo.value = campo.value;
		}
	}

	function formatear(dato,tipo,numeroDecimales){
		if (isValid(dato,tipo)){
			if (tipo == TIPO_OBLIGATORIO || dato == ''){
				return dato;
			}else{
				dato = dato.trim();
			}
			if(tipo == TIPO_INTEGER){
				return formatearFloat(dato,0);
			}else if(tipo == TIPO_INTEGER_SIGNADO){
				return formatearFloatSignado(dato,0);
			}else if(tipo == TIPO_FLOAT){
				return formatearFloat(dato,numeroDecimales);
			}else if(tipo == TIPO_FLOAT_SIGNADO){
				return formatearFloatSignado(dato,numeroDecimales);
			}else if(tipo == TIPO_DIA || tipo == TIPO_MES){
				return formatearDiaMes(dato);
			}else if(tipo == TIPO_FECHA){
				return formatearFecha(dato);
			}else{
				return dato;
			}
		}
	}
	function formatearDiaMes(dato){
		datoAux = "00" + dato;
		return datoAux.substring(datoAux.length-2,datoAux.length);
	}
	function formatearFecha(dato){
		fechaAux = dato.replaceAll("/","");
		return fechaAux.substring(0,2) + "/" + fechaAux.substring(2,4) + "/" + fechaAux.substring(4,8);
	}
	
	function formatearInteger(dato){
		stringDato = "" + dato.replace(/[.]/g,"");
		stringFinal="";
		stringDato = "" + parseFloat(stringDato);
		for(i=0;i<stringDato.length;i++){
			if ( i%3 == 0 && i!=0){
				stringFinal = "." + stringFinal;
			}
			stringFinal = stringDato.charAt(stringDato.length-i-1) + stringFinal;
		}
		return stringFinal;
	}
	function formatearIntegerSignado(dato){
		if (dato.charAt(0) == '+'){
			return formatearInteger(dato.substring(1,dato.length));
		}else if(dato.charAt(0) == '-'){
			return dato.charAt(0) + formatearInteger(dato.substring(1,dato.length));
		}else{
			return formatearInteger(dato);
		}
	}

	function formatearFloat(dato,numeroDecimales){
		if(numeroDecimales == undefined){
			numeroDecimales=0;
		}
		stringDato = "" + dato.replace(/[.]/g,"");
		stringFinal="";
		//buscamos la coma para separar
			posicionComa = stringDato.indexOf(",");
			if (posicionComa != -1){
				parteEntera = stringDato.substring(0,posicionComa);
				aux = "00000000000000000000".substring(0,numeroDecimales);
				parteDecimal = stringDato.substring(posicionComa,stringDato.length) + aux;
				//formateamos la parte entera
					parteEntera = formatearInteger(parteEntera);
				if(numeroDecimales != 0){
					return parteEntera + parteDecimal.substring(0,numeroDecimales+1);
				}else{
					return parteEntera;
				}
			}else{
				if(numeroDecimales != 0){
					aux = "00000000000000000000".substring(0,numeroDecimales);
					return formatearInteger(stringDato) + "," + aux;
				}else{
					return formatearInteger(stringDato);
				}
			}
	}
	function formatearFloatSignado(dato,numeroDecimales){
		if (dato.charAt(0) == '+'){
			return formatearFloat(dato.substring(1,dato.length),numeroDecimales);
		}else if(dato.charAt(0) == '-'){
			return dato.charAt(0) + formatearFloat(dato.substring(1,dato.length),numeroDecimales);
		}else{
			return formatearFloat(dato,numeroDecimales);
		}
	}