function passacampos_01()
	{
		if (eval('document.valida.tp_doc.value == ""'))
		{
		    alert("Tipo: Preenchimento obrigatório");
			eval('document.valida.tp_doc.focus()');
			return false;
		}
		
		if (eval('document.valida.parcela.value == ""'))
		{
		    alert("Parcela: Preenchimento obrigatório");
			eval('document.valida.parcela.focus()');
			return false;
		}
		if (eval('document.valida.quantidade.value == ""'))
		{
		    alert("Quantidade: Preenchimento obrigatório");
			eval('document.valida.quantidade.focus()');
			return false;
		}
	 	else
		{
			var campo01  = document.valida.quantidade.value
			var campo02  = document.valida.valor.value
			var campo03  = document.valida.vencimento.value
			var campo04  = document.valida.cod_lancamento.value
			var campo05  = document.valida.pessoa.value
			javascript:popupscroll(eval(' "lanca_documentos.asp?modelo_documento=duplicata&form=valida&campo01=&campo02=valor&parcela='+campo01+'&valor='+campo02+'&vencimento='+campo03+'&cod_lancamento='+campo04+'&pessoa='+campo05+' "'),'janelapopup','700','350')
		}
	}
	
// pega o inten selecionado no select

function meu_itenselecionado(formulario,campo,valorselect,iten)
	{ 
	    var texto ;
		var indice = eval('document.' + formulario + '.' + campo + '.selectedIndex');
		var valor  = eval('document.' + formulario + '.' + campo + '.options[indice].value');
	    texto = valor 
		if (texto==valorselect)
			{
			eval( iten + '.style.display=\'\'');
			}
		
		else{
			eval( iten + '.style.display=\'none\'');
			}
	} 

	
//mostra titular da conta bancaria
function titular_conta(formulario,campo,valorselect,it01,it02,it03,it04)
{
	var indice = eval('document.' + formulario + '.' + campo + '.selectedIndex');
	var valor  = eval('document.' + formulario + '.' + campo + '.options[indice].value');
	if (valor=='CH')
			{
			valida_debito.pessoa.value=it01
			valida_debito.banco.value=it02
			valida_debito.agencia.value=it03
			valida_debito.conta.value=it04
			}
	else
	{
			valida_debito.pessoa.value=""
			valida_debito.banco.value=""
			valida_debito.agencia.value=""
			valida_debito.conta.value=""
	}		
}
//limpa campos
function limpa_ds_plano_contas(form){	
	ds_campo    = form.des_planocontas.value;
	
	if ( ds_campo == "Dividido" ){
 		 form.des_planocontas.value = "Dividido";
		 form.arquivo.value = ";;;";
     }
	else
	{
		 form.des_planocontas.value = "";
		 form.arquivo.value = ";;;";
	}
	}
	
	function limpa_ds_plano_negocios(form){	
	ds_campo    = form.des_plano_negocios.value;
	
	if ( ds_campo == "Dividido" ){
 		 form.des_plano_negocios.value = "Dividido";
		 form.plano_negocios.value = ";;;;;";
     }
	else
	{
		 form.des_plano_negocios.value = "";
		 form.plano_negocios.value = ";;;;;";
	}
	}

// Aba em js

function ativaAba(codAba)
{
	if(codAba==0){	aba01.style.backgroundColor = "#F0F2F6";	maba01.style.backgroundColor = "#F0F2F6"; 	aba01.style.borderBottomWidth = 0;	maba01.style.borderBottomWidth = 0; aba01.style.fontWeight = "bold"; lay01.style.visibility = "visible"; }
	if(codAba==1){	aba02.style.backgroundColor = "#F0F2F6";	maba02.style.backgroundColor = "#F0F2F6";	aba02.style.borderBottomWidth = 0;	maba02.style.borderBottomWidth = 0;	aba02.style.fontWeight = "bold"; lay02.style.visibility = "visible";}
	if(codAba==2){	aba03.style.backgroundColor = "#F0F2F6";	maba03.style.backgroundColor = "#F0F2F6";	aba03.style.borderBottomWidth = 0;	maba03.style.borderBottomWidth = 0;	aba03.style.fontWeight = "bold"; lay03.style.visibility = "visible";}
	if(codAba==3){	aba04.style.backgroundColor = "#F0F2F6";	maba04.style.backgroundColor = "#F0F2F6";	aba04.style.borderBottomWidth = 0;	maba04.style.borderBottomWidth = 0;	aba04.style.fontWeight = "bold"; lay04.style.visibility = "visible";}
	if(codAba==4){	aba05.style.backgroundColor = "#F0F2F6";	maba05.style.backgroundColor = "#F0F2F6";	aba05.style.borderBottomWidth = 0;	maba05.style.borderBottomWidth = 0;	aba05.style.fontWeight = "bold"; lay05.style.visibility = "visible";}
}

function alternaAba(codAba)
{
	destivaAbas();	ativaAba(codAba);
}

function destivaAbas()
{
	aba01.style.backgroundColor = "#FFFFFF";	maba01.style.backgroundColor = "#FFFFFF";	aba01.style.borderBottomWidth = 1;	maba01.style.borderBottomWidth = 1;	aba01.style.fontWeight = "normal"; lay01.style.visibility = "hidden";
	aba02.style.backgroundColor = "#FFFFFF";	maba02.style.backgroundColor = "#FFFFFF";	aba02.style.borderBottomWidth = 1;	maba02.style.borderBottomWidth = 1;	aba02.style.fontWeight = "normal"; lay02.style.visibility = "hidden";
	aba03.style.backgroundColor = "#FFFFFF";	maba03.style.backgroundColor = "#FFFFFF";	aba03.style.borderBottomWidth = 1;	maba03.style.borderBottomWidth = 1;	aba03.style.fontWeight = "normal"; lay03.style.visibility = "hidden";
	aba04.style.backgroundColor = "#FFFFFF";	maba04.style.backgroundColor = "#FFFFFF";	aba04.style.borderBottomWidth = 1;	maba04.style.borderBottomWidth = 1;	aba04.style.fontWeight = "normal"; lay04.style.visibility = "hidden";
	aba05.style.backgroundColor = "#FFFFFF";	maba05.style.backgroundColor = "#FFFFFF";	aba05.style.borderBottomWidth = 1;	maba05.style.borderBottomWidth = 1;	aba05.style.fontWeight = "normal"; lay05.style.visibility = "hidden";
}

// fim Aba


function completatel(campo)
{     
if ((event.keyCode >=48) && (event.keyCode <=57)) {
	if (campo.value.length == 2)
		campo.value=campo.value+'-';
}		
else 
	return false;
}

//27.374.206/0001-38

function completaCNPJ(campo)
{     
if ((event.keyCode >=48) && (event.keyCode <=57)) {
	if (campo.value.length == 2)
		campo.value=campo.value+'.';
	if (campo.value.length == 6)
		campo.value=campo.value+'.';
	if (campo.value.length == 10)
		campo.value=campo.value+'/';
	if (campo.value.length == 15)
		campo.value=campo.value+'-';	
}	
else 
	return false;
}


function completaCEP(campo)
{     
if ((event.keyCode >=48) && (event.keyCode <=57)) {
	if (campo.value.length == 5)
		campo.value=campo.value+'-';
}		
else 
	return false;
}

//valida form

function VerifyField(form_name,field_name,field_app)
{
  if (eval('document.' + form_name + '.' + field_name + '.value == ""')) {
    alert(field_app + ": Preenchimento obrigatório");
	return false;
  }
  else {
    return true;
  }
}

function VerifyForm(form_name)
{

  eval("req_fields = document." + form_name + ".req_fields.value.split(',')");

  verify = true;
  
  for (i in req_fields) {
    ds_rf = req_fields[i].split(':');
    if (!VerifyField(form_name,ds_rf[0],ds_rf[1]) && verify) {
      if (ds_rf[2] != null) {
	    self.scrollTo(0,ds_rf[2]);
	  }   
      eval('document.' + form_name + '.' + ds_rf[0] + '.focus()');
	  return (false);
    }
  }

  //para subimitar um form apartir da barrinha fora do formulário e quando todos os campos obrigatorios estiverem preenchidos
  //valida.submit();
  // fim do submit
  
  return (verify);

}

//
function veeenha()
{
pos=document.body.scrollTop+0;
if (pos < 0) pos = 0;
commcenter.style.top=pos;
}
//

/*/Funçoes para reajustar o valor final de acordo com alteração em: Valor Lote, Parcela, Sinal


function calculo(form) {
a=eval(form.percent_adm.value)
b=100-a
form.percent_parceiro.value=b
}

if (campo.value.length == 2)
		campo.value=campo.value+'/';
	if (campo.value.length == 5)
		campo.value=campo.value+'/';

*/

function formatCurrency( num ) {
        var k, isNegative = false;
        num = num.toString().replace(/\\$|\\,/g,'');
        if( isNaN( num ) ) {
          num = "0";
        }
        if ( num < 0 ) {
          num = Math.abs( num );
          isNegative = true;
        }
        cents = Math.floor( ( num * 100 + 0.5 ) % 100 );
        num = Math.floor( ( num * 100 + 0.5 ) / 100 ).toString();
        if ( cents < 10 ) {
          cents = "0" + cents;
        }
        for ( k = 0; k < Math.floor( ( num.length - ( 1 + k ) ) / 3 ); k++) {
          num = num.substring( 0 ,num.length - ( 4 * k + 3 ) ) + '.' + num.substring( num.length - ( 4 * k + 3 ) );
        }

        var result = num + ',' + cents;
        if ( isNegative ) {
          result = "-" + result;
        }
        return result;
      }

function reajuste_sinal(form)
{	

  	//preco_lote  = form.preco_lote.value;
	//preco_lote  = preco_lote.replace( ".", "" );
	//preco_lote  = preco_lote.replace( ",", "" );
	//sinal   = form.sinal.value;
	//sinal 	= sinal.replace( ".", "" );
	//sinal  	= sinal.replace( ",", "" );	
	//parcelas   = form.financiamento.value;
	
	preco_lote  = form.preco_lote.value;
	preco_lote = preco_lote.replace('.','')
	preco_lote = preco_lote.replace(',','.')
	sinal   = form.sinal.value;
	sinal 	   = sinal.replace('.','')
	sinal 	   = sinal.replace(',','.')

	parcelas   = form.financiamento.value;
	
	total_operacao = eval(eval(preco_lote) - eval(sinal)) / eval(parcelas)
	form.valor_parc.value = formatCurrency(Math.round(total_operacao));
}

//fim


//
function mostra(item)
{
if
	(item.style.display=='none'){
	item.style.display='';
	}
else{
	item.style.display='none'
	}
}

//confirma Aditivo
	function confirmaaditivo()
	{ 
	if (confirm("Você tem certeza que deseja Aditivar esse Contrato.")) { 
	return true;
	self.location.href = "javascript:history.back()";
	} else { 
	return false; 
	} 
	} 
//

// testa_participacoes
	function testaparticipacoes()
	{ 
	if (confirm("Existem participações cadastradas alterando uma pessoa você irá EXCLUÍ-LAS deseja continuar?")) { 
	return true;
	self.location.href = "javascript:history.back()";
	} else { 
	return false; 
	} 
	}

//confirma excluir
	function confirmadel()
	{ 
	if (confirm("Você tem certeza que deseja excluir esse Registro.")) { 
	return true;
	self.location.href = "javascript:history.back()";
	} else { 
	return false; 
	} 
	} 
//
function buy(popup_url,name) {
window.open(popup_url,name,'resizable=yes,menubar=no,location=no,toolbar=no,status=no,scrollbars=no,directories=no,top=2000,left=0');
}

// janelas

//<a href="javascript:popupscroll('link','sobe','470','330')">

function popup(popup_url,name,width,height,ph,pw) {
size = 'width=' + width + ',height=' + height;
window.open(popup_url,name,'resizable=yes,menubar=no,location=no,toolbar=no,status=no,scrollbars=no,directories=no,top=' + ph + ',left=' + pw + ','+size);
}

function popupscroll(popup_url,name,width,height) {
size = 'width=' + width + ',height=' + height;
var pw = Math.floor((screen.width-width)/2); 
var ph = Math.floor((screen.height-height)/2); 
window.open(popup_url,name,'resizable=yes,menubar=no,location=no,toolbar=no,status=yes,scrollbars=yes,directories=no,top=' + ph + ',left=' + pw +','+size);
}

function popupfull(popup_url,name) {
window.open(popup_url,name,'resizable=yes,menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,directories=no,fullscreen=yes');
}

function fullnavigation(popup_url,name) {
window.open(popup_url,name,'channelmode,resizable=no,fullscreen=yes');
}

function abrir()
{
window.open("input_file.asp?action=edit_news.asp", "Promo", "width=450,height=300,top=0,left=0,scrollbars=yes")
}

//fim janelas


//verifica datas


function verificaData(campo)
{
if (campo.value == "")
	alert('A data não deve ficar vazia!');

}

//==================================================================================================				

function verifFaixaMax(campo)
{
//Verifica se a data e maior que a data maxima...
//Se o ano e' maior
if (campo.value.substring(6,10) > campo.dtmax.substring(6,10)) {
	return false;
}
else {
	//Se o ano e' igual
	if (campo.value.substring(6,10) == campo.dtmax.substring(6,10)) {
		//Verificacao do mes
		// Se o mes e' maior...
		if (campo.value.substring(3,5) > campo.dtmax.substring(3,5)) {
			return false;
		}
		else {
			//Se o mes e' igual...
			if (campo.value.substring(3,5) == campo.dtmax.substring(3,5)) {
				//Verificacao do dia
				// Se o dia e' maior...
				if (campo.value.substring(2,0) > campo.dtmax.substring(2,0)) {
					//alert('o dia e maior...');
					return false;
				}
			}
		}
	}
}

return true;
} // Fim da funcao verifFaixaMax	

//==================================================================================================				

function verifFaixaMin(campo)
{
//Verifica se a data e menor que a data minima...
//Se o ano e' menor
if (campo.value.substring(6,10) < campo.dtmin.substring(6,10)) {
	return false;
}
else {
	//Se o ano e' igual
	if (campo.value.substring(6,10) == campo.dtmin.substring(6,10)) {
		//Verificacao do mes
		// Se o mes e' menor...
		if (campo.value.substring(3,5) < campo.dtmin.substring(3,5)) {
			//alert('o mes e menor...');
			return false;
		}
		else {
			//Se o mes e' igual...
			if (campo.value.substring(3,5) == campo.dtmin.substring(3,5)) {
				//Verificacao do dia
				// Se o dia e' menor...
				if (campo.value.substring(2,0) < campo.dtmax.substring(2,0)) {
					//alert('o dia e menor...');
					return false;
				}
			}
		}
	}
}

return true;
} // Fim da funcao verifFaixaMin	

//==================================================================================================				

function validaData(dataparam)
{	
var resto=(dataparam.substring(6,10) % 4);
// Se o ano for bisexto...
if (dataparam.length < 10) {
	return false;
}
	// Verifica se é um mes de 31 dias
	if ((dataparam.substring(3,5) == 1) || (dataparam.substring(3,5) == 3) || (dataparam.substring(3,5) == 5) || (dataparam.substring(3,5) == 7) || (dataparam.substring(3,5) == 8) || (dataparam.substring(3,5) == 10) ||  (dataparam.substring(3,5) == 12)) {
	if (dataparam.substring(2,0) > 31) { // Verifica os dias do mes de 31 dias
		return false;
	}
}	
else if (dataparam.substring(3,5) == 2) { // Verifica se é fevereiro
	if (resto==0) { // verifica se o ano é bisexto
		if (dataparam.substring(2,0) > 29) { // Verifica os dias do mes de fevereiro
			alert('No ano informado, fevereiro só tem 28 dias!')
			return false;
		}
	}
	else { // se nao e bisexto...
		if (dataparam.substring(2,0) > 28) { // Verifica os dias do mes de fevereiro
			alert('No ano informado, fevereiro só tem 28 dias!')
			return false;
		}
        	}
}
// Verifica se é um mes de 30 dias
else if ((dataparam.substring(3,5) == 4) || (dataparam.substring(3,5) == 6) || (dataparam.substring(3,5) == 9) || (dataparam.substring(3,5) == 11)) {
	if (dataparam.substring(2,0) > 30) { // Verifica os dias do mes de 30 dias
		return false;
	}
}
// Certifica-se de que o mes esta entre 01 e 12...
else if ((dataparam.substring(3,5) > 12) || (dataparam.substring(3,5) < 1)) {
	return false;
}
// Nao permite o ano 0000
if (dataparam.substring(6,10) == 0) {
	return false;
}
// Confirma a validade da data
return true;
} // Fim da funcao

//==================================================================================================				

function completaData(campo)
{     
if ((event.keyCode >=48) && (event.keyCode <=57)) {
	if (campo.value.length == 2)
		campo.value=campo.value+'/';
	if (campo.value.length == 5)
		campo.value=campo.value+'/';
}		
else 
	return false;
}

//==================================================================================================				
//fim verifica datas

//<!--script acende tabela-->

	function on(src,corover) {
	if (!src.contains(event.fromElement))
	 {	
  	src.style.cursor = 'hand';
  	src.bgColor = corover;
	 }
	}
	function off(src,corout) {
	if (!src.contains(event.toElement))
	 {
	  src.style.cursor = 'default';
	  src.bgColor = corout;
	 }
	}
	function mclick(src)
	{
	 if(event.srcElement.tagName=='TD')
	 {
	  src.children.tags('a')[0].click();
	 }
	}
//<!--fim script acende tabela-->


// dhtml exibe menus 

var ie=(document.all);
var ns=(document.layers);
var aberto="back";

function apagar(){
	if(ns){
		document.layers[aberto].visibility = "hide";
		document.back.visibility = "hide";
		aberto="back";
	}
	if(ie){
		document.all[aberto].style.visibility = "hidden";
		back.style.visibility = "hidden";
		aberto="back";
	}
}

function sh_hd(param){
	if(ns){
		if(param == aberto){
			document.layers[param].visibility = "hide";
			aberto = "back";
		}
		else{
			document.layers[aberto].visibility = "hide";
			document.layers[param].visibility = "show";
			document.back.visibility = "show";
			aberto = param;
		}
	}
	if(ie){
		if(param == aberto){
			document.all[param].style.visibility = "hidden";
			aberto = "back";
		}
		else{
			document.all[aberto].style.visibility = "hidden";
			document.all[param].style.visibility = "visible";
			back.style.visibility = "visible";
			aberto = param;
		}
	}
}

function window_op(url,w,h){
    var l = ((screen.availWidth)/2) - (w/2);
    var t = ((screen.availHeight)/2) - ((h/2)+20);
	var pag = 'J' + url;
	var url2 = url + ".htm";
    var windprop = "toolbar=0,directories=0,menubar=0,status=0,resizable=0,location=0,scrollbars=0,copyhistory=0" + ",left=" + l + ",top=" + t + ",width=" + w  + ",height=" + h;
    window.open(url2,pag,windprop); 
}

function fechar(param){
	setTimeout("self.close()",20);
	var loc = param + ".htm";
	window.opener.top.location.href=loc;
}

function voltar(){
	setTimeout("self.close()",20);
	window.opener.focus();
}
//fim dhtml exibe menus 

//preços
			function FormataValor(campo,tammax,teclapres) {
				var tecla = teclapres.keyCode;
				//Exibe o cod do caracter
				//alert(tecla);
				vr = 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 <= 2 ){ 
				 		campo.value = vr ; }
				 	if ( (tam > 2) && (tam <= 5) ){
				 		campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
				 	if ( (tam >= 6) && (tam <= 8) ){
				 		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, 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 - 2, 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 - 2, 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 ) ;}
				}		
				
			}
			
			function AllowDigits(evento) {
			  if (navigator.appName == "Microsoft Internet Explorer") {
			    keyASCII = evento.keyCode;
				//alert(keyASCII)
			  }
			  else {
			    keyASCII = evento.which;
			  }	
			
		  	//if ( (keyASCII < 48) || (keyASCII > 57))
			if ( (keyASCII < 44) || (keyASCII > 57))
		    	
				evento.returnValue = false;
		  	
			else
		    return true;
			  
			}

			
function FormataCPF(pForm,pCampo,pTamMax,pPos1,pPos2,pPosTraco,pTeclaPres){
 var wTecla, wVr, wTam;
 
       // alert(pForm[pCampo].value);
  
 wTecla = pTeclaPres.keyCode;
 wVr = pForm[pCampo].value;
 wVr = wVr.toString().replace( "-", "" );
 wVr = wVr.toString().replace( ".", "" );
 wVr = wVr.toString().replace( ".", "" );
 wVr = wVr.toString().replace( "/", "" );
 wTam = wVr.length ;

 if (wTam < pTamMax && wTecla != 8) { 
    wTam = wVr.length + 1 ; 
 }

 if (wTecla == 8 ) { 
    wTam = wTam - 1 ; 
 }
   
 if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 ){
  if ( wTam <= 2 ){
    pForm[pCampo].value = wVr ;
  }
  if (wTam > pPosTraco && wTam <= pTamMax) {
        wVr = wVr.substr(0, wTam - pPosTraco) + '-' + wVr.substr(wTam - pPosTraco, wTam);
  }
  if ( wTam == pTamMax){
        wVr = wVr.substr( 0, wTam - pPos1 ) + '.' + wVr.substr(wTam - pPos1, 3) + '.' + wVr.substr(wTam - pPos2, wTam);
  }
  pForm[pCampo].value = wVr;
 
 }

}


//Herdar endereços
function herdar_residencial(form)
{
form.endereco_cob.value      =form.endereco_pessoa.value
form.num_cob.value           =form.num_pessoa.value
form.complemento_cob.value   =form.complemento_residencia.value
form.bairro_cob.value        =form.bairro_pessoa.value
form.cidade_cob.value        =form.cidade_pessoa.value
form.estado_cob.value        =form.estado_resid_pessoa.value
form.cep_cob.value           =form.cep_pessoa.value
form.pontoref_cob.value      =form.pontoref_pessoa.value

}

function herdar_comercial(form)
{
form.endereco_cob.value      =form.endereco_comercial.value
form.num_cob.value           =form.num_comercial.value
form.complemento_cob.value   =form.complemento_comercial.value
form.bairro_cob.value        =form.bairro_comercial.value
form.cidade_cob.value        =form.cidade_comercial.value
form.estado_cob.value        =form.estado_comercial.value
form.cep_cob.value           =form.cep_comercial.value
form.pontoref_cob.value      =form.pontoref_comercial.value
}




//formatar CPF

function FormataCPF(pForm,pCampo,pTamMax,pPos1,pPos2,pPosTraco,pTeclaPres){
 var wTecla, wVr, wTam;
 
       // alert(pForm[pCampo].value);
  
 wTecla = pTeclaPres.keyCode;
 wVr = pForm[pCampo].value;
 wVr = wVr.toString().replace( "-", "" );
 wVr = wVr.toString().replace( ".", "" );
 wVr = wVr.toString().replace( ".", "" );
 wVr = wVr.toString().replace( "/", "" );
 wTam = wVr.length ;

 if (wTam < pTamMax && wTecla != 8) { 
    wTam = wVr.length + 1 ; 
 }

 if (wTecla == 8 ) { 
    wTam = wTam - 1 ; 
 }
   
 if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 ){
  if ( wTam <= 2 ){
    pForm[pCampo].value = wVr ;
  }
  if (wTam > pPosTraco && wTam <= pTamMax) {
        wVr = wVr.substr(0, wTam - pPosTraco) + '-' + wVr.substr(wTam - pPosTraco, wTam);
  }
  if ( wTam == pTamMax){
        wVr = wVr.substr( 0, wTam - pPos1 ) + '.' + wVr.substr(wTam - pPos1, 3) + '.' + wVr.substr(wTam - pPos2, wTam);
  }
  pForm[pCampo].value = wVr;
 
 }

}



// imprimir em frames

function framePrint(whichFrame){
parent[whichFrame].focus();
parent[whichFrame].print();
}


//Função para Completar Cnpj
//Comentário:
function completaCNPJ(campo)
{     
if ((event.keyCode >=48) && (event.keyCode <=57)) {
	if (campo.value.length == 2)
		campo.value=campo.value+'.';
	if (campo.value.length == 6)
		campo.value=campo.value+'.';
	if (campo.value.length == 10)
		campo.value=campo.value+'/';
	if (campo.value.length == 15)
		campo.value=campo.value+'-';	
}	
else 
	return false;
}
//

function formataValorMonetario(campooriginal,decimais)
	{
	  var posicaoPontoDecimal;
	  var campo = '';
	  var resultado = '';
	  var pos,sep,dec;
	
	//Retira possiveis separadores de milhar
	  for (pos=0; pos < campooriginal.value.length; pos ++)
	  {
	    if (campooriginal.value.charAt(pos)!='.')
	        campo = campo + campooriginal.value.charAt(pos);
			campo = campo.replace('-','')
	  }     
	
	//Formata valor monetário com decimais
	  posicaoPontoDecimal = campo.indexOf(',');
	  if (posicaoPontoDecimal != -1)
	   {
	      sep = 0;
	      for (pos=posicaoPontoDecimal-1;pos >= 0;pos--)
	      {
	        sep ++;
	        if (sep > 3)
	        {
	           resultado = '.' + resultado;
	           sep = 1;
	        }
	
	        resultado = campo.charAt(pos) + resultado;   
	      }
	
	      // Trata parte decimal
	      if (parseInt(decimais) > 0 )
	      {
	         resultado = resultado + ',';
	      
	         pos=posicaoPontoDecimal+1;
	         for (dec = 1;dec <= parseInt(decimais); dec++)
	         {
	           if (pos < campo.length)
	           {
	              resultado = resultado + campo.charAt(pos);
	              pos++;
	           }
	           else
	              resultado = resultado + '0';   
	         }
	
	      } // trata decimais
	   }
	   // Trata valor monetário sem decimais
	   else
	   {
	      sep = 0;
	      for (pos=campo.length-1;pos >= 0;pos--)
	      {
	        sep ++;
	        if (sep > 3)
	        {
	           resultado = '.' + resultado;
	           sep = 1;
	        }
	        resultado = campo.charAt(pos) + resultado;   
	      }
	      // Trata parte decimal
	      if (parseInt(decimais) > 0 ) 
	      {
	         resultado = resultado + ',';
	         for (dec = 1;dec <= parseInt(decimais); dec++)
	         {
	              resultado = resultado + '0';   
	         }
	      } // trata decimais
	   }
	   if ( campooriginal.value !=""){
	  	 campooriginal.value = resultado;
	   }
	}


		
function formataValorMonetarioNEG(campooriginal,decimais)
	{
	  var posicaoPontoDecimal;
	  var campo = '';
	  var resultado = '';
	  var pos,sep,dec;
	
	//Retira possiveis separadores de milhar
	  for (pos=0; pos < campooriginal.value.length; pos ++)
	  {
	    if (campooriginal.value.charAt(pos)!='.')
	        campo = campo + campooriginal.value.charAt(pos);
	  }     
	
	//Formata valor monetário com decimais
	  posicaoPontoDecimal = campo.indexOf(',');
	  if (posicaoPontoDecimal != -1)
	   {
	      sep = 0;
	      for (pos=posicaoPontoDecimal-1;pos >= 0;pos--)
	      {
	        sep ++;
	        if (sep > 3)
	        {
	           resultado = '.' + resultado;
	           sep = 1;
	        }
	
	        resultado = campo.charAt(pos) + resultado;   
	      }
	
	      // Trata parte decimal
	      if (parseInt(decimais) > 0 )
	      {
	         resultado = resultado + ',';
	      
	         pos=posicaoPontoDecimal+1;
	         for (dec = 1;dec <= parseInt(decimais); dec++)
	         {
	           if (pos < campo.length)
	           {
	              resultado = resultado + campo.charAt(pos);
	              pos++;
	           }
	           else
	              resultado = resultado + '0';   
	         }
	
	      } // trata decimais
	   }
	   // Trata valor monetário sem decimais
	   else
	   {
	      sep = 0;
	      for (pos=campo.length-1;pos >= 0;pos--)
	      {
	        sep ++;
	        if (sep > 3)
	        {
	           resultado = '.' + resultado;
	           sep = 1;
	        }
	        resultado = campo.charAt(pos) + resultado;   
	      }
	      // Trata parte decimal
	      if (parseInt(decimais) > 0 ) 
	      {
	         resultado = resultado + ',';
	         for (dec = 1;dec <= parseInt(decimais); dec++)
	         {
	              resultado = resultado + '0';   
	         }
	      } // trata decimais
	   }
 	
		if ( campooriginal.value !=""){
		
			if( campooriginal.value.search('-') == -1)
				campooriginal.value = "-"+resultado;
			}
		
	   	//campooriginal.value = "-"+resultado;
	  
	   }

