	var win;

	function keyDownValor(objcampo,nDec) {

		var tecla = event.keyCode;
	    var vr = '';	
	    var posvirg = 0;
	    var tam; 
	    var i;
	    var bKey = false;
	    var a = Array( 8, 9, 16, 17, 35, 37, 39, 36, 45, 46, 111);

	    //8-backspace; 
	    //46-delete ; 
	    //9-tab ; 
	    //16-shift; 37-left; 39-right; 36-home; 35-end; 17-ctrl; 45-ins; 144; 13-enter
	    var ponto   = /\./;
	    var browser;

	    //verifica browser
	    var tipo_browser;
	    if ( (window.navigator.appName == 'Netscape') || (tecla == 16) )
			return false

	    for( i = 0 ; i < a.length ; i++ ) {
			if( tecla == a[i] ) { bKey = true }
	    }

	    if ( !bKey ) {
			if ( tecla == 110 || tecla == 188 || tecla == 190 || ( tecla >= 48 && tecla <= 57 ) || ( tecla >= 96 && tecla <= 105 ) ) {
				vr = objcampo.value;
				posvirg = vr.indexOf(',');
				if (tecla == 110 || tecla == 188 || tecla == 190) {
					if ( !nDec || nDec == 0 ) {
						event.returnValue = false;
					}
					if ( posvirg == -1 ) {
						objcampo.value = objcampo.value + ',';
					}
					event.returnValue = false;
				}
			}
			else {
				event.returnValue = false
				return false;
			}
		}
	}

	function formatNumber(num, carac_dec) {

		if ( carac_dec == '.' ) {  
			num = num.toString().replace( ',', '' );
	    }
		else {   
		    num = num.toString().replace('.','');
			num = num.toString().replace(',','.');
	    }

	    if(isNaN(num))
			num = "0";

	    num = Math.floor(num*100+0.50000000001);
	    cents = num%100;
	    num = Math.floor(num/100).toString();

	    if(cents<10)
			cents = "0" + cents;
			
	    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {
			if (carac_dec == '.') 
				num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
			else
				num = num.substring(0,num.length-(4*i+3))+'.'+num.substring(num.length-(4*i+3));		
		}

	    var retorno;
	    retorno = num + carac_dec + cents;

	    if (retorno == '0,00' || retorno == '0.00')
	    	retorno = "";

	    return retorno;
	}


	function abrirPopUp(termo, msg) {
		var url;
		url = 'msg.asp?termo=' + termo + '&msg=' + msg;
		win = window.open(url,"Explicacao","height=200,width=300,resizable=yes,menubar=no,toolbar=no,scrollbars=yes,alwaysRaised=yes,top=200,left=250");
	}

	function fecharJanela() {
		if (win && win.open && !win.closed) {
			win.close();
		}
	}

	function validarTecla(campo,teclapres) {
		if ((isNaN(String.fromCharCode(teclapres.keyCode))) || (teclapres.keyCode == 32)) {
			if (teclapres.keyCode != 44 && teclapres.keyCode != 46) {
				teclapres.returnValue = false;
			}
			if (teclapres.keyCode==44) {
				if(campo.value.indexOf(',')>-1) {
					teclapres.returnValue = false;
				}
			}
		}
	}

	function verificarValor(campo) {
		var arrPartes;
		arrPartes = campo.value.split(',')
		if(arrPartes.length==2) {
			if(arrPartes[1].length>2) {
				arrPartes[1] = arrPartes[1].substring(0,2);
				campo.value = arrPartes[0] + ',' + arrPartes[1];
			}
		}
	}

	function retirarPontos(campo) {
		var valor;
		valor = campo.value;
		while (valor.indexOf('.')>-1)
			valor = valor.toString().replace('.','');
		return valor;
	}

