// MARCARAS /////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////

// FILTRA AS TECLAS PRESSIONADAS
function filtra(obj, padrao){
	tk    = (ie4) ? event.keyCode : event.which;
	letra = String.fromCharCode(tk);
	
	for (x = 0; x < padrao.length; x++)
		if (padrao.slice(x, x + 1) == letra) return true;
	return true;
}

// FUNCOES PARA CONTROLE DE AVANCO EM CAMPOS DE TEXTO
function pula(origem, tamanho, destino) {
	if ((origem.value.length == tamanho)){
		destino.focus();
	}
}

function IsNumeric(inputVal,sErrorMsg) {
     if(isNaN(parseFloat(inputVal))) {
          if(sErrorMsg){
		  	alert(sErrorMsg)
		  }
          return false;
     }
     return true
}


function OnlyNumber(ev,comma){
	var Event		= ev;
	var AceptComma	= comma;
	var keyboardkey	= Event.keyCode;
	var Target		= ((typeof(ev.target)=='undefined') ? ev.srcElement : ev.target);
	var comma		= (AceptComma ? (keyboardkey == 110 || (!Event.shiftKey && keyboardkey==188)) : false);
	if(!Event.shiftKey && !Event.ctrlKey){		
		if(keyboardkey == 8 || keyboardkey == 9 || keyboardkey == 13 || keyboardkey > 32 && keyboardkey < 41 || keyboardkey > 44 && keyboardkey < 58 || keyboardkey > 95 && keyboardkey < 106 || comma){
			return true;
			Event.returnValue=true;
		}else{
			return false;
			Event.returnValue=false;
		}
	}else if( keyboardkey==16 || Event.shiftKey && ((keyboardkey > 33 && keyboardkey < 41) || keyboardkey==9 || comma) ){
		return true;
		Event.returnValue=true;
	}else if( keyboardkey==17 || Event.ctrlKey && (keyboardkey==65 || keyboardkey==67 || keyboardkey==84 || keyboardkey==86 || keyboardkey==88 || comma) ){
		if(keyboardkey==86){ // paste clipboard
			window.Target = Target;
			setTimeout("NumericValue(window.Target,"+AceptComma+")",10);
		}
		Event.returnValue=true;
		return true;
	}else{
		return false;
		Event.returnValue=false;
	}
}

function NumericValue(input,comma){
	var newValue = "";
	var char = "";
	for(i=0;i<input.value.length;i++){
		char = input.value.substr(i,1);
		if( IsNumeric(char) || (char=="," && comma) ){
			newValue = 	newValue + input.value.substr(i,1);
		}
	}
	input.value = newValue;	
}

function Filledfield(field,maxlength){
	if(field.value.length > 0 && field.value.length < maxlength){
		field.focus();
	}
}

function FormataDado(campo,tammax,pos,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length ;
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){ tam = tam - 1 ; }
			
	if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
	 		document.form[campo].value = vr ;}
		if ( tam > pos && tam <= tammax ){
			document.form[campo].value = vr.substr( 0, tam - pos ) + '-' + vr.substr( tam - pos, tam );}
	}
	//alert("campo: " + document.form[campo+1].name);
	if ( !teclapres.shiftKey && tecla == 9 && document.form[campo+1].name == "senhaConta" && document.applets['tclJava'] ){
		//alert("aki 1");
			document.applets['tclJava'].setFocus();
	}
}

function filtraCampo(campo){
	var s = "";
	var cp = "";
	vr = campo.value;
	tam = vr.length;
	for (i = 0; i < tam ; i++) {  
		if (vr.substring(i,i + 1) != "/" && vr.substring(i,i + 1) != "-" && vr.substring(i,i + 1) != "."  && vr.substring(i,i + 1) != "," ){
		 	s = s + vr.substring(i,i + 1);}
	}
	campo.value = s;
	return cp = campo.value
}

function formataValor(campo,dec,Event){
	if(Event.keyCode != 9 && Event.keyCode != 8 && Event.keyCode != 16 && Event.keyCode != 37 && Event.keyCode != 38 && Event.keyCode != 39 && Event.keyCode != 40 && Event.keyCode != 46){

		if(campo.value.length==0){
			campo.value = 0;
		}
		var zeros = "";
		for(var i = 0;i<dec;i++){zeros+="0"}
		var soNumeros = filtraCampo(campo);
		if((soNumeros.length > 3 && dec == 2) || (soNumeros.length > 4 && dec == 3)){
			campo.value = parseFloat(soNumeros);
		}else{
			campo.value = filtraCampo(campo);
		}	
		
		if(campo.value.length >= 14){
			campo.value = campo.value.substr(0,14);
			vr = campo.value;
		}else{
			vr = campo.value;
		}
		
		tam = campo.value.length;
		if(parseFloat(campo.value)==0&&tam>dec){			
			campo.value = "0"+zeros;
			vr = "0"+zeros;
		}

		if(tam <= dec){
			if(Event.type=="blur"){
				if(tam<dec){
					campo.value = parseFloat(vr)+","+zeros;
				}else if(soNumeros.length==dec){
					campo.value = vr.substr(0,1)+","+vr.substr(1,tam)+"0";
				}
			}else{
				campo.value = vr;
			}
		}else{
			if(dec==2){
				if ((tam > dec) && (tam <= 5)){
					campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ); 
				}
				if((tam >= 6) && (tam <= 8)){
					campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ); 
				}
				if ( (tam >= 9) && (tam <= 11)){
					campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam );
				}
				if ( (tam >= 12) && (tam <= 14) ){
					campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam );
				}
				if ( (tam >= 15) && (tam <= 17) ){
					campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam );
				}
			}else if(dec==3){
				if ((tam > dec) && (tam <= 6)){
					campo.value = vr.substr( 0, tam - 3 ) + "," + vr.substr( tam - dec, tam ); 
				}
				if((tam >= 7) && (tam <= 9)){
					campo.value = vr.substr( 0, tam - 6 ) + "." + vr.substr( tam - 6, 3 ) + "," + vr.substr( tam - dec, tam ); 
				}
			}
		}
	}
}

function SaltaCampo(campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		document.form[campo].value = vr.substr( 0, vr.length - 1 ); }
	else{
	 	vr = vr.replace( "-", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( ",", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	tam = vr.length;	
		
	 	if (tecla != 0 && tecla != 9 && tecla != 16 && tecla != 144 ){
		
			if ( tam == tammax ){
				if ( prox == "senhaConta" || (document.form.elements[prox] && document.form.elements[prox].name == "senhaConta"))
				{
					if ( document.applets['tclJava'] )
						document.applets['tclJava'].setFocus();
					else if ( document.form.senhaConta )
						document.form.senhaConta.focus();
				}
				else if ( document.form[prox] )
					document.form[prox].focus();
			}
		}
	}
}

function DisableEnterCampo(Campo,Event,Min,Max){
	if(Event.keyCode==13 && Campo.value.length>Min && Campo.value.length<Max){
		return false;	
	}
}

function FormataData(campo,teclapres,dataMax) {
	var tecla = teclapres.keyCode;
	if(tecla < 32 || tecla > 41){
		if(campo.value.length>10){
			vr = campo.value.substr(0,9);
		}else{
			vr = campo.value;
		}
		vr = vr.replace( ".", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		tam = vr.length + 1;
		if ( tecla != 9 && tecla != 8 ){
			if(dataMax){
				dataMax = dataMax.replace("/","");
				dataMax = dataMax.replace("/","");
				var diaAtual = dataMax.substr(0,2);
				var mesAtual = dataMax.substr(2,2);
				var anoAtual = dataMax.substr(4,4);
				if(tam > 2 && tam < 5){
					
					var dia = vr.substr( 0, tam - 2  );
					if(parseInt(dia) > 31){
						dia = 31;
					}else if(tam>3 && parseFloat(dia)==0){
						dia = "01";
					}
					
					var mes = vr.substr( tam - 2, tam );
					if(parseInt(mes) > 12){
						mes = 12;
					}else if(tam>5 && parseFloat(mes)==0){
						mes = "01";
					}
					
					campo.value = dia + '/' + mes;
				}else if( tam >= 5 ){
					var ano = vr.substr( 4, 4 );
					if(parseFloat(ano) > parseFloat(anoAtual) && ano.length > 3){
						ano = anoAtual;
					}else if(parseFloat(ano) < parseFloat(2000) && ano.length > 3){
						ano = 2000;
					}
					var mes = vr.substr( 2, 2 );
					if(parseFloat(mes) > 12 || ano >= anoAtual && parseFloat(mes) > parseFloat(mesAtual)){
						if(ano == anoAtual){
							if(mesAtual.length>1){
								mes = mesAtual;								
							}else{
								mes = "0"+mesAtual;
							}
						}else{
							mes = 12;
						}
					}else if(parseFloat(mes)==0){
						mes = "01";
					}
					var dia = vr.substr( 0, 2 );
					if(parseFloat(dia) > 31 || ano >= anoAtual && mes >= mesAtual && parseFloat(dia) > parseFloat(diaAtual)){
						if(ano == anoAtual){
							if(diaAtual.length>1){
								dia = diaAtual;
							}else{
								dia = "0"+diaAtual;
							}
						}else{
							dia = 31;
						}				
					}else if(parseFloat(dia)==0){
						dia = "01";
					}			
					campo.value = dia + '/' + mes + '/' + ano;
				}
			}else{
				if(tam > 2 && tam < 5){
					dia = vr.substr( 0, tam - 2  );
					if(parseInt(dia)>31){
						dia = 31;
					}else if(tam>3 && parseFloat(dia)==0){
						dia = "01";
					}
					mes = vr.substr( tam - 2, tam );
					if(parseInt(mes)>12){
						mes = 12;
					}else if(tam>5 && parseFloat(mes)==0){
						mes = "01";
					}
					campo.value = dia + '/' + mes;
				}else if( tam >= 5 ){
					dia = vr.substr( 0, 2 );
					if(parseInt(dia)>31){
						dia = 31;
					}else if(parseFloat(dia)==0){
						dia = "01";
					}
					mes = vr.substr( 2, 2 );
					if(parseInt(mes)>12){
						mes = 12;
					}else if(parseFloat(mes)==0){
						mes = "01";
					}
					ano = vr.substr( 4, 4 )
					if(parseFloat(ano) < parseFloat(2000) && ano.length > 3){
						ano = 2000;
					}
					campo.value = dia + '/' + mes + '/' + ano;
				}
			}
		}		
	}		
}

function FormataMesAno(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[Campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 7 )
			document.form[Campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, tam ); }
}

function FormataPercentual(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 3 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 3) && (tam <= 6) ){
	 		document.form[campo].value = vr.substr( 0, tam - 3 ) + ',' + vr.substr( tam - 3, tam ) ; }
	}		
	
}

function FormataCartaoCredito(campo, teclapres) {
    var tammax = 16;
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;

	if ( tecla == 8 || (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) )
	{
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( ",", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		tam = vr.length;

		if (tam < tammax && tecla != 8)
		   {tam = vr.length + 1 ; }

		if (tecla == 8 ) {tam = tam - 1 ; }

		if ( tam < 5 )
		   { document.form[campo].value = vr ; }
	 	if ( ( tam >  4 ) && ( tam < 9 ) )
		   { document.form[campo].value = vr.substr( 0, 4 ) + '.' + vr.substr( 4, tam-4 ) ; }
	 	if ( ( tam >  8 ) && ( tam < 13 ) )
		   { document.form[campo].value = vr.substr( 0, 4 ) + '.' + vr.substr( 4, 4 ) + '.' + vr.substr( 8, tam-4 ) ; }
	 	if ( tam > 12 )
		   { document.form[campo].value = vr.substr( 0, 4 ) + '.' + vr.substr( 4, 4 ) + '.' + vr.substr( 8, 4 ) + '.' + vr.substr( 12, tam-4 ); }
	}	
}

function float2moeda(num)  // transforma float em moeda
{


x = 0;

if(num<0) {
num = Math.abs(num);
x = 1;
} if(isNaN(num)) num = "0";
cents = Math.floor((num*100+0.5)%100);

num = Math.floor((num*100+0.5)/100).toString();

if(cents < 10) cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+'.'
+num.substring(num.length-(4*i+3)); 
ret = num + ',' + cents; 
if (x == 1) ret = ' - ' + ret;
return ret;

}

//Para definirmos a quantidade de casas decimais temos que usar de artimanhas
function roundNumber (rnum) 
{

	return Math.round(rnum*Math.pow(10,2))/Math.pow(10,2);

}

//Pega um valor formatado com virgula e separador de milha e o transforma em float
function moeda2float(moeda)
{

	moeda = moeda.replace(".","");
	
	moeda = moeda.replace(",",".");
	
	return parseFloat(moeda);

}

function FormataCgc(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 6) ){
	 		document.form[campo].value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 7) && (tam <= 9) ){
	 		document.form[campo].value = vr.substr( 0, tam - 6 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 10) && (tam <= 12) ){
	 		document.form[campo].value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 13) && (tam <= 14) ){
	 		document.form[campo].value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		document.form[campo].value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ;}
	}		
}

function FormataTelefone(campo,tammax) {
	var tecla = event.keyCode;
	
	vr = campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){
		tam = vr.length + 1 ; 
	}

	if (tecla == 8 ){
		tam = tam - 1;
	}
	if( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam < 2 ){ 
			campo.value = vr; 
		}
		if ((tam > 4)){
			campo.value = vr.substr( 0, tam - 4 ) + '-' + vr.substr( tam - 4, tam ); 
		}	
	}	
}

function FormataCPF(Campo, teclapres){
	if(teclapres.keyCode != 16 && teclapres.keyCode != 37 && teclapres.keyCode != 38 && teclapres.keyCode != 39 && teclapres.keyCode != 40){
		var tecla = teclapres.keyCode;
		
		var vr = new String(Campo.value);
		vr = vr.replace(".", "");
		vr = vr.replace(".", "");
		vr = vr.replace("-", "");
		vr = vr.replace("/", "");
	
		tam = vr.length + 1;
		
		if (tecla != 9 && tecla != 8){
			if (tam > 3 && tam < 7)
				Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
			if (tam >= 7 && tam <10)
				Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
			if (tam >= 10 && tam < 12)
				Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
		}
	}
}
/////////////////////////////////////////////////////////////////
function FormataCNPJ(Campo, teclapres){

	var tecla = teclapres.keyCode;

	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1 ;

	
	if (tecla != 9 && tecla != 8){
		if (tam > 2 && tam < 6)
			Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
		if (tam >= 6 && tam < 9)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
		if (tam >= 9 && tam < 13)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
		if (tam >= 13 && tam < 15)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
		}
}

function FormataDoc(campo,Event){
	if(Event.keyCode!=16 && Event.keyCode!=17 && !Event.shiftKey && !Event.ctrlKey){
		if(campo.value.length>14){
			FormataCNPJ(campo, Event);
		}else{
			FormataCPF(campo, Event);
		}
	}
}

function FormatarCEP(src, mask){
	var i = src.value.length;
	var saida = mask.substring(0,1);
	var texto = mask.substring(i)
	if (texto.substring(0,1) != saida){
		src.value += texto.substring(0,1);
	}
}

function FormatNumber(numero,decimais){ 
	if (isNaN(numero)) { return 0}; 
	if (numero=='') { return 0}; 

	var IsNegative=(parseInt(numero)<0);
	if(IsNegative)numero=-numero;
	var snum = new String(numero); 
	var sec = snum.split('.'); 
	var whole = parseInt(sec[0]); 
	var result = ''; 
	if(sec.length > 1){ 
		var dec = new String(sec[1]); 
		dec = parseInt(dec)/Math.pow(10,parseInt(dec.length-decimais-1));
		Math.round(dec);
		dec = parseInt(dec)/10;
	
		if(IsNegative){
			var x = 0-dec;
			x = Math.round(x);
			dec = - x;
		}else{
			dec = Math.round(dec);
		}
	
		/*
		* If the number was rounded up from 9 to 10, and it was for 1 'decimal'
		* then we need to add 1 to the 'whole' and set the dec to 0.
		*/
		if(decimais==1 && dec==10){
			whole+=1;
			dec="0";
		}
	
		dec = String(whole) + "." + String(dec); 
		var dot = dec.indexOf('.'); 
		
		if(dot == -1){ 
			dec += '.'; 
			dot = dec.indexOf('.'); 
		}
		
		var l=parseInt(dot)+parseInt(decimais);
		while(dec.length <= l) { dec += '0'; } 
		result = dec; 
	
	}else{ 
		var dot; 
		var dec = new String(whole); 
		dec += '.'; 
		dot = dec.indexOf('.'); 
		var l=parseInt(dot)+parseInt(decimais);
		
		while(dec.length <= l) { dec += '0'; } 
		
		result = dec; 
	} 
	if(IsNegative)result="-"+result;
	return result; 
}

function FormatNumberDec3(numero){
	var retorno = numero;
	if(numero.indexOf('.')!=-1){
		var dec = numero.split('.')[1];
		switch(dec.length){
			case 1:
				retorno = numero + "00";
			break;
			case 2:
				retorno = numero + "0";
			break
		}
	}else{
		retorno = parseInt(numero) + ".000";
	}
	return retorno;
}