﻿// JScript File

function selecionaFoco(campo)
{ 
    campo.focus() 
    campo.select() 
} 

function textOn(txt)
{
    document.getElementById(txt).focus();
    document.getElementById(txt).select();
    document.getElementById(txt).className="input_ON";
}

// volta a cor do text ao perder o foco
function textNormal(txt)
{
    document.getElementById(txt).className="input";
}

function textOn_valores(txt)
{
    document.getElementById(txt).select();
    document.getElementById(txt).focus();
    document.getElementById(txt).className="input_ON_valores";
}

// volta a cor do text ao perder o foco
function textNormal_valores(txt)
{
    document.getElementById(txt).className="input_valores";
}

// formata campo totais estilo moeda
function formatNumero(campo) 
{
    var strCheck = '-0123456789';
    var key = '';
    if (strCheck.indexOf(key) != -1) 
    {
        fnLimpaPontos(campo);
        var num = campo.value;
        var tam= num.length

        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));
        }
        campo.value = num;
    }
}

//Função para limpar os ponto toda vez que o campo receber o foco.
function fnLimpaPontos(campo)
{
	if(campo.value!='')
	{
		for(i=0;i<campo.value.length;i++)
		{
			campo.value = campo.value.toString().replace('\.','');
		}
	}
}

function somenteNumero(e) 
{
    return true;
    //var key = '';
    //var strCheck = '-0123456789';
    //var whichCode = (window.Event) ? e.which : e.keyCode;
    //key = String.fromCharCode(whichCode);  // Valor para o código da Chave
    // se for tab então sai da rotina
    //if(whichCode==0){return true;}
    //if (strCheck.indexOf(key) == -1) return false;  // Chave inválida
}


