//// Projeto : RANULFO ALVES PEREIRA - Active Company 
//// Email   : webmaster@activecompany.com.br                    

// bloqueia visualizacao do fonte
function verfonte() {
  if(event.button==2){
    window.alert('O código fonte deste site não pode ser exibido.\n\  Mas solicite você infrmação para o endereço:\n\         webmaster@activecompany.com.br\n\n\     Clique em Ok, para continuar navegando.');
  }
}

function editor( id ){
	$( "#"+id ).htmlarea( {
		toolbar: [ "bold", "italic", "underline" , "|", "p", "h1", "h2", "h3", "|", "link", "unlink", "|", "image", "forecolor", "|", "orderedlist", "unorderedlist", "indent", "outdent", "|", "justifyleft", "justifycenter", "justifyright", "|", "cut", "copy", "paste", "|", {
			css: "note",
			text: "Adicione uma descrição",
			action: function(){
				var sel = this.getSelectedHTML();
				var des = window.prompt( "Escreva a descrição" )
				this.pasteHTML( "<abbr title=\""+des+"\" style=\"text-decoration: underline;\">"+sel+"</abbr>" );
			}
		} ]
	} );
}

function atualiza_editor( id ){
	$( "#"+id ).val( $( "#"+id ).htmlarea( "toHtmlString" ) );
}

// abre janela poup-up de ajuda do sistema
function OpenUpAjuda(pagina,janela) {
   window.open(pagina,janela,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=520,height=400')
}

// funcao para impressao
function imprimir(){
   window.print();
}

//funcao voltar campos
function voltar(todoscampos,getoupost,tab){
  enviagenerico(todoscampos,document.getElementById("ultima").value,getoupost,tab)
}

function Fechar() {
  window.close('janela');
}

function enviacomfoco(campo,todoscampos,idcampo,getoupost,tab){
  enviagenerico(todoscampos,idcampo,getoupost,tab);
}

function levarvalor(origem,destino){
  document.getElementById(destino).value=document.getElementById(origem).value;
}

function foco_primeiro( id_form ){
  for (var i=0; i<document.getElementById( id_form ).elements.length;i++){
    if(document.getElementById( id_form ).elements[i].type!="hidden"){
      document.getElementById( id_form ).elements[i].focus();
      window.setTimeout(function() { document.getElementById( id_form ).elements[i].focus();},250)
      return;
    }
  }
}

/*
function click() {
  if (event.button==2) {
    alert('Todos os Direitos Reservados.')
  }
}
document.onmousedown=click

function disableselect(e){
  return false
}

function reEnable(){
  return true
}
document.onselectstart=new Function ("return false")

if (window.sidebar){
  document.onmousedown=disableselect
  document.onclick=reEnable
}
 */
  
function ajaxupload( config ){
	// BLOQUEIA O FUNCIOAMENTO NO INTERNET EXPLORER 6
	if( $.browser.msie && $.browser.version<7 ){ alert( "Navegador não suportado. Tente novamente com um navegador atual." );return; }

	// VERIFICA O PARÂMETRO
	if( config.url==null ){ config.url = ""; }
	if( config.fileField==null ){ config.fileField = ""; }
	if( config.type==null ){ config.type = ""; }
	if( config.size==null ){ config.size = 0; }
	if( config.onComplete==null ){ config.onComplete = function(){}; }

	// CRIA O IFRAME
	$( "body" ).append( "<iframe id='iajax' name='iajax' name='iajax' width='0' height='0' style='position: absolute;top: 0; left: 0;'></iframe>" );

	// CRIA O FORM
	$( "body" ).append( "<form id='fajax' action='"+config.url+"' method='post' enctype='multipart/form-data' target='iajax' style='position: absolute;top: 0;left: 0;width: 0;height: 0;overflow: hidden;'></form>" );
	$( "#"+config.fileField ).clone( true ).insertAfter( "#"+config.fileField );
	$( "#"+config.fileField ).appendTo( "#fajax" );
	$( "#fajax" ).append( "<input type='text' name='type' value='"+config.type+"' />" );
	$( "#fajax" ).append( "<input type='text' name='size' value='"+config.size+"' />" );

	// ATRIBUI O ON-LOAD AO IFRAME
	$( "#iajax" ).load( function(){
		var contentFrame = ( this.contentWindow )?this.contentWindow.document:this.contentDocument;
		config.onComplete( contentFrame.body.innerHTML );
		$( "#iajax, #fajax" ).remove();
	} );

	// ENVIA O FORMULÁRIO
	$( "#fajax" )[ 0 ].submit();
}

function uti_upload(){
	ajaxupload( {
		url: "uti_upload.php",
      		fileField: "arquivo",
		onComplete: function( retorno ){
		  alert( retorno );
		  eval( "var resultado="+retorno );
		  alert( resultado["msg"]);
		  enviagenerico(resultado["parametros"].replaceall( "&amp;","&"),'uti_cobranca.php','POST','abaixo');
		}
	} );
}  
  
String.prototype.replaceall = function( token, newtoken){
  var string= this;
  while(string.indexOf(token)!=-1){
    string= string.replace(token, newtoken);
  }
  return string;
}

function conv_upload( gatilho ){
  if( $( "#tex_titulo" ).val()!="" ){
	  ajaxupload( {
		  url: "uti_convupload.php",
		  fileField: "arquivo",
		  onComplete: function( retorno ){
			  if( retorno.indexOf( "ERRO:" )!=-1 ){
				  alert( retorno.replace( "ERRO:", "" ) );
			  }
			  if( retorno.indexOf( "ARQUIVO:" )!=-1 ){
				  $( "#img_tex" ).val( retorno.split( "/" ).last() );
			  }
			  uti_cad( "tex_cad", gatilho, "meio" );
		  }
	  } );
  } else {
    alert('O Nome deve ser preenchido');
  }
}

Array.prototype.last = function(){
	var array = this;
	return array[ array.length-1 ];
};
    
function horas(){
  var now = new Date();
  var hours = now.getHours();
  var minutes = now.getMinutes();
  var seconds = now.getSeconds()
  if(hours <=9)
    hours="0"+hours;
  if(minutes<=9)
    minutes="0"+minutes;
  if(seconds<=9)
    seconds="0"+seconds;
  var cdate="<span class=style11>"+hours+":"+minutes+":"+seconds+" "+"</span>" 
  document.getElementById("clock").innerHTML= cdate;
  setTimeout("horas()",1000);
}


// mover relogio
function moveRelogio(){
  momentoAtual = new Date()
  hora = momentoAtual.getHours()
  minuto = momentoAtual.getMinutes()
  segundo = momentoAtual.getSeconds()
  str_segundo = new String (segundo)
  if(str_segundo.length == 1)
    segundo = "0" + segundo
    str_minuto = new String (minuto)
    if(str_minuto.length == 1)
      minuto = "0" + minuto
    str_hora = new String (hora)
    if(str_hora.length == 1)
       hora = "0" + hora
	if(document.getElementById('campoteste2').value==""){
 	  document.getElementById('campoteste2').value=segundo;
	  var tempofinal=document.getElementById('campoteste2').value+3;
	}		
	document.getElementById('campoteste').value=tempofinal;
	if(document.getElementById('campoteste2').value==tempofinal){
	  document.getElementById('palav').value='00000';
	}
    setTimeout("moveRelogio()",1000)
}

// estracao de scrit de texo
function extraiScript(texto){
  //Maravilhosa função feita pelo SkyWalker.TO do imasters/forum
  // inicializa o inicio ><
  var ini = 0;
  // loop enquanto achar um script
  while (ini!=-1){
    // procura uma tag de script
    ini = texto.indexOf('<script', ini);
    // se encontrar
    if(ini >=0){
      // define o inicio para depois do fechamento dessa tag
      ini = texto.indexOf('>', ini) + 1;
      // procura o final do script
      var fim = texto.indexOf('</script>', ini);
      // extrai apenas o script
      codigo = texto.substring(ini,fim);
      //  alert(codigo);
	  // executa o script
      // eval(codigo);	 
      novo = document.createElement("script")
	  // Define parâmetro language=javascript para o objeto de script
  	  novo.setAttribute('language', 'javascript');
      novo.text = codigo;
	  document.body.appendChild(novo);	 
    }
  }
}

// funcao envia formulario com id para validar/gravar/alterar (AJAX)
function enviaForm(frmNome, url, destino){
  var query='';
  // Captura o form
  f = document.getElementById(frmNome);
  for (i=0;i<f.elements.length;i++){
    // concatena a variavel na query
    if(f.elements[i].type=='radio'||f.elements[i].type=='checkbox'){
      if(f.elements[i].checked){
        query +=  '&'+f.elements[i].name + '=' + f.elements[i].value;
      }
    } else {
      query +=  '&'+f.elements[i].name + '=' + escape( f.elements[i].value.replace("&","@@@@@@") );
    }
  }
  // envia o formulario
  //alert(query);
  if(arguments[3]==null){
    enviagenerico(query,url,'POST',destino);
  } else {
    enviagenerico(query,url,'POST',destino,arguments[3]);    
  }
}

// funcao loading (aguarde)
function Loading(a,tab){
  if(a=='on'){
    document.getElementById(tab).innerHTML = "<img src='../images/aguarde.gif'><br>aguarde...";
  } else {
    document.getElementById(tab).innerHTML = "";
  }
}		

// funcao start do AJAX
function startAjax(){
  try { xmlhttp = new XMLHttpRequest(); } 
    catch(e) {
    try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
      catch(ee) {	
      try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} 
        catch(E){
        xmlhttp = false;
      }
    }
  } 
  return xmlhttp;
}	
		
// funcao enviar link  (AJAX)
function enviagenerico(todoscampos,enderecourl,getoupost,tab){
  if(arguments[4]!=null){ var callback=arguments[4];}
  var maiscampos=todoscampos;
  var ajax = startAjax();			
  if(ajax){
    Loading('on', tab);
    ajax.open(getoupost,enderecourl,true)
    ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ajax.onreadystatechange = function(){		
      if(ajax.readyState==4){
	Loading('off', tab);
	//var get = ajax.responseText.replace(/\+/g," ");
	extraiScript(ajax.responseText);
	//alert (ajax.responseText);
	document.getElementById(tab).innerHTML = ajax.responseText;
	if(callback!=null){
	  callback();
	}      
      }
    }
    maiscampos=maiscampos+"&navegador="+document.getElementById('navegador').value;		
    ajax.send(maiscampos);
    /*
    if(document.getElementById("atual").value!=enderecourl){
	  document.getElementById("ultima").value=document.getElementById("atual").value;
	  document.getElementById("atual").value=enderecourl;
    }*/
  } 
}

function buscaPorCEP(url){
	$.ajax( {
//		url: "../sys_sys/adm_cadfuncionario.php?cep=true",
		url: url,
		type: "POST",
		data: "cli_cep="+$( "#cli_cep" ).val(),
		success: function( response ){ 

			eval( "var dadosCEP="+response );
			for( var i=0;i<$( "#cmbbxn11_0" )[ 0 ].options.length;i++ ){
				if( $( "#cmbbxn11_0" )[ 0 ].options[ i ].value==dadosCEP[ "uf" ].toUpperCase() ){
					$( "#cmbbxn11_0" )[ 0 ].options[ i ].selected = true;
				}
			}
						
			list_dados_1( $("#cmbbxn11_0").parents( "form")[0],0,1,1);

                        window.setTimeout( function(){
			for( var i=0;i<$( "#cmbbxn11_1" )[ 0 ].options.length;i++ ){
				if( $( "#cmbbxn11_1" )[ 0 ].options[ i ].value==dadosCEP[ "cidade_cod" ].toUpperCase() ){
					$( "#cmbbxn11_1" )[ 0 ].options[ i ].selected = true;
				}
			}
			},1000);
			
			$( "#cender" ).val( dadosCEP[ "logradouro" ] );
			$( "#cbairr" ).val( dadosCEP[ "bairro" ] );
		}
	} );
}


function buscaPorCEP02(url){
	$.ajax( {
//		url: "../sys_sys/adm_cadfuncionario.php?cep=true",
		url: url,
		type: "POST",
		data: "c__cep="+$( "#c__cep" ).val(),
		success: function( response ){
		  		  
			eval( "var dadosCEP02="+response );			
			for( var i=0;i<$( "#cmbbx1_0" )[ 0 ].options.length;i++ ){
				if( $( "#cmbbx1_0" )[ 0 ].options[ i ].value==dadosCEP02[ "uf" ].toUpperCase() ){
					$( "#cmbbx1_0" )[ 0 ].options[ i ].selected = true;
				}
			}			
			list_dados( $("#cmbbx1_0").parents( "form")[0],0,1,1);
                        window.setTimeout( function(){
			for( var i=0;i<$( "#cmbbx1_1" )[ 0 ].options.length;i++ ){
				if( $( "#cmbbx1_1" )[ 0 ].options[ i ].value==dadosCEP02[ "cidade_cod" ].toUpperCase() ){
					$( "#cmbbx1_1" )[ 0 ].options[ i ].selected = true;
				}
			}
			
		      
			
			},1000);
			
			$( "#cenderr" ).val( dadosCEP02[ "logradouro" ] );
			$( "#cbairrr" ).val( dadosCEP02[ "bairro" ] );
		}
	} );
}



// validacao do dados login da pagina principal
function log_usu(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('usus_login').value==""){
    alert("Campo Login não pode ser vazio.\n           Campo obrigatório.");
    erro="S";
    return false;
  }
  if(document.getElementById('usus_senha').value==""){
    alert("Campo Senha não pode ser vazio.\n           Campo obrigatório.");
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

/******************************************************/
/**********************   BUSCAS   ********************/
/******************************************************/
function busca_dadoscondominio( el ){
	var base = el.options[ el.selectedIndex ].value;
	$.ajax( {
		type: "post",
		url: "fin_buscabase.php",
		data: "busca=000&base="+base,
		success: function( response ){
			eval( "var condominio = "+response );
			var opt = "<option value=\"\">Unid.</option>\n";
			condominio.unidades.each( function( i, t ){
				opt += "<option value=\""+t+"\">"+t+"</option>\n";
			} );
			$( "#cnscoda" ).html( opt );

			opt = "<option value=\"\">Bloco</option>\n";
			if( condominio.blocos[ 0 ]!=null ){
				condominio.blocos.each( function( i, t ){
					opt += "<option value=\""+t+"\">"+t+"</option>\n";
				} );
			}
			$( "#cnscodb" ).html( opt );

			opt = "<option value=\"\">Selecione um proprietário</option>\n";
			condominio.proprietarios.each( function( i, ar ){
				var bloco = ( ar[ "bloco" ]!=null )?"-"+ar[ "bloco" ]:"";
				opt += "<option value=\""+ar[ "cod" ]+"\" class=\""+ar[ "unidade" ]+bloco+"\">"+ar[ "nome" ]+"</option>\n";
			} );
			$( "#cnscodp" ).html( opt );
		}
	} );
}

var pendencias;

function busca_dadosproprietario( cod ){
	var base = $( "#base" )[ 0 ].options[ $( "#base" )[ 0 ].selectedIndex ].value;
	$.ajax( {
		type: "post",
		url: "fin_buscabase.php",
		data: "busca=001&base="+base+"&cod="+cod,
		success: function( response ){
			eval( "pendencias = "+response );
			var tabela = "<table style='width: 100%;'><tr><th style='background: #ccc;'>Mês Ref.</th><th style='background: #ccc;'>Vecto.</th><th style='background: #ccc;'>Valor</th><th style='background: #ccc;'><input type='checkbox' onclick='marcatodos( this, \"pendencia\" );somamarcados( \"pendencia\" );' /></th></tr>";
			pendencias.each( function( i, a ){
				var cor = ( i%2==0 )?"#fff":"#ddd";
				tabela += "<tr style='background: "+cor+";'><td style='text-align: right;'>"+a[ "referencia" ]+"</td><td style='text-align: right;'>"+a[ "vencimento" ]+"</td><td style='text-align: right;'>"+a[ "valor" ]+"</td><td style='text-align: center;'><input type='checkbox' name='marcados' class='pendencia' onclick='somamarcados( this.className );' value='"+a[ "id" ]+"' /></td></tr>";
			} );
			tabela += "</table>";
			$( "#pendencias" ).html( tabela );
		}
	} );
}

function sinc_dadoscondominio( tipo ){
	switch( tipo ){
		case "ub":
			var unidade = $( "#cnscoda" )[ 0 ].options[ $( "#cnscoda" )[ 0 ].selectedIndex ].value;
			var bloco = $( "#cnscodb" )[ 0 ].options[ $( "#cnscodb" )[ 0 ].selectedIndex ].value;
			if( $( "#cnscodb" )[ 0 ].options.length>1 ){
				if( unidade!="" && bloco!="" ){
					$( "option."+unidade+"-"+bloco )[ 0 ].selected = true;
				}
			}
			else{
				if( unidade!="" ){
					$( "option."+unidade )[ 0 ].selected = true;
				}
			}
			break;
		case "p":
			var unidade = $( "#cnscodp" )[ 0 ].options[ $( "#cnscodp" )[ 0 ].selectedIndex ].className.split( "-" );
			var bloco = ( unidade.length==2 )?unidade[ 1 ]:"";
			unidade = unidade[ 0 ];
			for( var i=0;i<$( "#cnscoda" )[ 0 ].options.length;i++ ){
				if( $( "#cnscoda" )[ 0 ].options[ i ].value==unidade ){
					$( "#cnscoda" )[ 0 ].options[ i ].selected = true;
				}
			}
			if( bloco!="" ){
				for( var i=0;i<$( "#cnscodb" )[ 0 ].options.length;i++ ){
					if( $( "#cnscodb" )[ 0 ].options[ i ].value==bloco ){
						$( "#cnscodb" )[ 0 ].options[ i ].selected = true;
					}
				}
			}
			break;
	}
	var cod = $( "#cnscodp" )[ 0 ].options[ $( "#cnscodp" )[ 0 ].selectedIndex ].value;
	if( cod!="" ){
		busca_dadosproprietario( cod );
	}
}

Array.prototype.each = function( func ){
	var array = this;
	for( var i=0;i<array.length;i++ ){
		func( i, array[ i ] );
	}
};

function marcatodos( el, cls ){
	if( el.checked ){
		$( "input."+cls ).each( function( i, input ){
			input.checked = true;
		} );
	}
	else{
		$( "input."+cls ).each( function( i, input ){
			input.checked = false;
		} );
	}
}

function somamarcados( cls ){
	var soma = 0;
	var juros = 0;
	var multa = 0;
	var correcao = 0;
	var encargos = 0;
	$( "input."+cls ).each( function( i, e ){
		if( e.checked==true ){
			soma += parseFloat( pendencias[ i ][ "valor" ] );
			juros += parseFloat( pendencias[ i ][ "juros" ] );
			multa += parseFloat( pendencias[ i ][ "multa" ] );
			correcao += parseFloat( pendencias[ i ][ "correcao" ] );
			encargos += parseFloat( pendencias[ i ][ "honorarios" ] );
		}
	} );
	var total = soma+juros+multa+correcao+encargos;
	$( "#somatoria" ).html( soma.formatMoney() );
	$( "#ntotge" ).val( total.formatMoney() );
	$( "#exb_juros" ).html( juros.formatMoney() );
	$( "#exb_multa" ).html( multa.formatMoney() );
	$( "#exb_correcao" ).html( correcao.formatMoney() );
	$( "#exb_encargos" ).html( encargos.formatMoney() );
	$( "#exb_total" ).html( total.formatMoney() );
}

function calcula_diferenca(){
	var receber = parseFloat( $( "#ntotge" ).val().replace( ".", "" ).replace( ",", "." ) );
	var dinheiro = parseFloat( $( "#ntotdi" ).val().replace( ".", "" ).replace( ",", "." ) );
	var resultado = receber-dinheiro;
	if( resultado>0 ){
		$( "#nfatdi" ).val( resultado.formatMoney() );
		$( "#nfatch" ).val( "0,00" );
	}
	else{
		$( "#nfatdi" ).val( "0,00" );
		resultado = resultado*(-1);
		$( "#nfatch" ).val( resultado.formatMoney() );
  	}
}

Number.prototype.formatMoney = function( c, d, t ){ //Serve para formatar um number em formato dinheiro 
	var n = this;
	c = isNaN( c = Math.abs( c ) )?2:c;
	d = ( d==undefined )?",":d;
	t = ( t==undefined )?".":t;
	var i = parseInt( n = ( +n || 0 ).toFixed( c ) )+"";
	var j = ( ( j=i.length )>3 )?j%3:0;
	return ( ( j )?i.substr( 0, j )+t:"" )+i.substr( j ).replace( /(\d{3})(?=\d)/g, "$1"+t )+( ( c )?d+( n-i ).toFixed( c ).slice( 2 ):"" );
};



// envia texto com fckeditor para um campo de edicao unico
function enviatexto(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ema_data').value==""){
	alert("Informe a data do e-mail.\n       Campo obrigatório.");
	document.getElementById('ema_data').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ema_titulo').value==""){
	alert("Informe o titulo do e-mail.\n       Campo obrigatório.");
	document.getElementById('ema_titulo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ema_tipo').value==""){
	alert("Informe o tipo do e-mail.\n       Campo obrigatório.");
	document.getElementById('ema_tipo').focus();
	erro="S";
	return false;
  }
  var query='';
  var not_conteudo = FCKeditorAPI.GetInstance('not_conteudo').GetXHTML(); 
  //aqui eu troco o & por @@@@@@
  not_conteudo=not_conteudo.replace(/&/g,"@@@@@@");
		
  FCKeditorAPI = null;
  __FCKeditorNS = null;

  // Captura o form
  f = document.getElementById(frmNome);

  for (i=0;i<f.elements.length;i++){
    // concatena a variavel na query
    if(f.elements[i].type=='radio'||f.elements[i].type=='checkbox'){
      if(f.elements[i].checked){
        query +=  '&'+f.elements[i].name + '=' + f.elements[i].value;
	  }
    } else {
      query +=  '&'+f.elements[i].name + '=' + f.elements[i].value.replace("&","@@@@@@");
    }
  }
  // envia o formulario
  // alert(query);

  query+="&not_conteudo="+not_conteudo;
  if(erro=="N"){enviagenerico(query,url,'POST',destino);}
}


function enviatexto2cpo(frmNome, url, destino){
  var query='';
  var not_conteudo1 = FCKeditorAPI.GetInstance('not_conteudo1').GetXHTML();
  //aqui eu troco o & por @@@@@@
  not_conteudo1=not_conteudo1.replace(/&/g,"@@@@@@");
	
  var not_conteudo2 = FCKeditorAPI.GetInstance('not_conteudo2').GetXHTML();
  //aqui eu troco o & por @@@@@@
  not_conteudo2=not_conteudo2.replace(/&/g,"@@@@@@");

  FCKeditorAPI = null;
  __FCKeditorNS = null;

  // Captura o form
  f = document.getElementById(frmNome);

  for (i=0;i<f.elements.length;i++){
    // concatena a variavel na query
    if(f.elements[i].type=='radio'||f.elements[i].type=='checkbox'){
      if(f.elements[i].checked){
        query +=  '&'+f.elements[i].name + '=' + f.elements[i].value;
	  }
    } else {
      query +=  '&'+f.elements[i].name + '=' + f.elements[i].value.replace("&","@@@@@@");
    }
  }
  // envia o formulario
  //alert(query);

  query+="&not_conteudo1="+not_conteudo1+"&not_conteudo2="+not_conteudo2;
  enviagenerico(query,url,'POST',destino);	
}

function enviatexto3cpo(frmNome, url, destino){
  var query='';
  var not_conteudo1 = FCKeditorAPI.GetInstance('not_conteudo1').GetXHTML();
  //aqui eu troco o & por @@@@@@
  not_conteudo1=not_conteudo1.replace(/&/g,"@@@@@@");
	
  var not_conteudo2 = FCKeditorAPI.GetInstance('not_conteudo2').GetXHTML();
  //aqui eu troco o & por @@@@@@
  not_conteudo2=not_conteudo2.replace(/&/g,"@@@@@@");

  var not_conteudo3 = FCKeditorAPI.GetInstance('not_conteudo3').GetXHTML();
  //aqui eu troco o & por @@@@@@
  not_conteudo3=not_conteudo3.replace(/&/g,"@@@@@@");	

  FCKeditorAPI = null;
  __FCKeditorNS = null;

  // Captura o form
  f = document.getElementById(frmNome);

  for (i=0;i<f.elements.length;i++){
    // concatena a variavel na query
    if(f.elements[i].type=='radio'||f.elements[i].type=='checkbox'){
      if(f.elements[i].checked){
        query +=  '&'+f.elements[i].name + '=' + f.elements[i].value;
	  }
    } else {
      query +=  '&'+f.elements[i].name + '=' + f.elements[i].value.replace("&","@@@@@@");
    }
  }
  // envia o formulario
  //alert(query);

  query+="&not_conteudo1="+not_conteudo1+"&not_conteudo2="+not_conteudo2+"&not_conteudo3="+not_conteudo3;
  enviagenerico(query,url,'POST',destino);	
}

// formata campos diversos
function formatar(mascara, documento){
  var i = documento.value.length;
  var saida = mascara.substring(0,1);
  var texto = mascara.substring(i)  
  if (texto.substring(0,1) != saida){
	documento.value += texto.substring(0,1);
  }
}

// formata campo de mes referencia
function mascara_referencia(nascimento,campoesp){ 
  var mynascimento = ''; 
  mynascimento = mynascimento + nascimento; 
  if(mynascimento.length == 2){ 
    mynascimento = mynascimento + '-'; 
    campoesp.value = mynascimento; 
  } 
  if(mynascimento.length == 7){ 
    verifica_referencia(campoesp); 
  } 
} 

// verifica mes referencia
function verifica_referencia (campoesp) { 
  mes = (campoesp.value.substring(0,2)); 
  ano = (campoesp.value.substring(3,7)); 
  situacao = ""; 
  // verifica se o mes e valido 
  if(mes < "01" || mes > "12" ) { 
    situacao = "falsa"; 
  } 
  // verifica se e ano bissexto 
  if(mes == "2" && ( dia < "01" || dia > "29" || ( dia > "28" && (parseInt(ano / 4) != ano / 4)))) { 
    situacao = "falsa"; 
  }     
  if(campoesp.value == "") { 
    situacao = "falsa"; 
  }     
  if(situacao == "falsa") { 
    alert("A Referencia "+campoesp.value+" é inválida!\nInsira uma referência correta!"); 
	campoesp.value=""; 
    campoesp.focus(); 
  } 
}		  

// formata campo data
function mascara_nascimento(nascimento,campoesp){ 
  var mynascimento = ''; 
  mynascimento = mynascimento + nascimento; 
  if(mynascimento.length == 2){ 
    mynascimento = mynascimento + '-'; 
    campoesp.value = mynascimento; 
  } 
  if(mynascimento.length == 5){ 
    mynascimento = mynascimento + '-'; 
    campoesp.value = mynascimento; 
  } 
  if(mynascimento.length == 10){ 
    verifica_nascimento(campoesp); 
  } 
} 

// verifica campo data
function verifica_nascimento (campoesp) { 
  dia = (campoesp.value.substring(0,2)); 
  mes = (campoesp.value.substring(3,5)); 
  ano = (campoesp.value.substring(6,10)); 
  situacao = ""; 
  // verifica o dia valido para cada mes 
  if((dia < "01")||(dia < "01" || dia > "30") && (  mes == "04" || mes == "06" || mes == "09" || mes == "11" ) || dia > "31") { 
    situacao = "falsa"; 
  } 
  // verifica se o mes e valido 
  if(mes < "01" || mes > "12" ) { 
    situacao = "falsa"; 
  } 
  // verifica se e ano bissexto 
  if(mes == "2" && ( dia < "01" || dia > "29" || ( dia > "28" && (parseInt(ano / 4) != ano / 4)))) { 
    situacao = "falsa"; 
  }     
  if(campoesp.value == "") { 
    situacao = "falsa"; 
  }     
  if(situacao == "falsa") { 
    alert("A Data "+campoesp.value+" é inválida!\nInsira uma data correta!"); 
	campoesp.value=""; 
    campoesp.focus(); 
  } 
} 

// mascara para campo telefone
function mascara_telefone(fone,campo){ 
  var mytelefone = ''; 
  mytelefone = mytelefone + fone; 
  if(mytelefone.length == 2){ 
	 mytelefone = '('+mytelefone + ')'; 
	 campo.value = mytelefone; 
  } 
  if(mytelefone.length == 8){ 
	 mytelefone = mytelefone + '-'; 
	 campo.value = mytelefone; 
  } 
} 

// mascara para cep
function mascara_cep(cep,campo){ 
  var mycep = ''; 
  mycep = mycep + cep; 
  if(mycep.length == 5){ 
	 mycep = mycep + '-'; 
	 campo.value = mycep; 
  } 
}

function busca_valor( el ){
  var ctades = el.options[ el.selectedIndex ].value;
  $.ajax( {
    type: "post",
    url: "fin_buscabase.php",
    data: "ctades="+ctades,
    success: function( resposta ){
      resposta = resposta.split( "|" );
      $( "#nvalor" ).val( resposta[ 0 ].replace( ".", "," ) );
      $( "#nquant" ).val( resposta[ 1 ] );
    }
  } );
}

// verifica CPF/CNPJ
function ver_cpf_cnpj(numcpf,campo){
  //Filtragem da entrada do CPF - Filtra caracteres ""-"" ou ""/"" ou "".""\
  var wcgccalc; var wsoma;
  cleancpf = "";
  tamcpf = numcpf.length;
  for(i = 0; i < tamcpf;i++){
    carac = numcpf.substring(i,i+1);
	if(carac != "1" && carac != "2" && carac != "3" && carac !="4" && carac != "5" && carac != "6" && carac != "7" && carac != "8" && carac!= "9" && carac != "0"){
	  carac = "";
	}
	cleancpf = cleancpf + carac;
  }
  numcpf = cleancpf;
  if(numcpf.length == 11){
	x=0; soma=0; dig1=0; dig2=0; texto=""; numcpf1="";
	len = numcpf.length; x = len -1;
	for(var i=0; i <= len - 3; i++){
	  y = numcpf.substring(i,i+1); soma = soma + ( y * x);
	  x = x - 1; texto = texto + y;
	}
	dig1 = 11 - (soma % 11);
	if(dig1 == 10) dig1=0 ; 
	  if(dig1 == 11) dig1=0 ;
	    numcpf1 = numcpf.substring(0,len - 2) + dig1 ;
	    x = 11; soma=0;
		for(var i=0; i <= len - 2; i++){
		  soma = soma + (numcpf1.substring(i,i+1) * x); 
		  x = x - 1;
		}
		dig2= 11 - (soma % 11);
		if(dig2 == 10) dig2=0;
		if(dig2 == 11) dig2=0;
	    if((dig1 + "" + dig2) == numcpf.substring(len,len-2)){
		return true;
	  } else {
		alert("O cpf que digitou está incorreto");
		campo.focus();
		campo.value="";
		return false;
	  }
	} else {
	  if(numcpf.length == 14){  
		wcgccalc= (numcpf.substring(0,12));
		wsoma=0;
		for(var i=0; i<=3; i++){
		  wnum=parseInt(wcgccalc.substring(i,i+1));
		  wsoma= wsoma + wnum * (5-i);
		}
		for(var x=0; x<=7; x++){
		  wnum=parseInt(wcgccalc.substring(x+4,x+5));
		  wsoma=wsoma + wnum * (9-x);
		}
	    wcgcdigit= 11-(wsoma%11);
		if((wcgcdigit == 10) || (wcgcdigit == 11)){
		  wcgccalc= wcgccalc + '0';
		} else {
		  wcgccalc= wcgccalc + wcgcdigit;
		}	
		wsoma=0;
		for(var y=0; y<=4; y++){
		  wnum=parseInt(wcgccalc.substring(y,y+1));
		  wsoma= wsoma + wnum * (6-y);
		}
		for(var z=0; z<=7; z++){
		  wnum=parseInt(wcgccalc.substring(z+5,z+6));
		  wsoma=wsoma + wnum *(9-z);
		}
		wcgcdigit= 11 - (wsoma%11);
		if((wcgcdigit == 10)||(wcgcdigit == 11)){
	      wcgccalc= wcgccalc + '0';
		} else {
		  wcgccalc= wcgccalc + wcgcdigit;
		}
		if(numcpf==wcgccalc){
		  return true;
		} else {
		  alert("O Cnpj que digitou está incorreto");
		  campo.value="";
		  campo.focus();	
	      return false;
		}
      } else {
		alert("O Cnpj/Cnpj que digitou está incorreto");
		campo.value="";
		campo.focus();
		return false;
	  }
	}
}

// formata valores de moedas, percentuais
function FormataValor2(campo,tammax,casas){
  var vr=document.getElementById(campo).value
  // var vrss=document.getElementById(campo).value	
  while (vr.indexOf(".")>=0) {
	vr=vr.replace(".","");
  }
  while (vr.indexOf(",")>=0) {
	vr=vr.replace(",","");
  }	
  if(isNaN(vr)){
	alert ("Foi Digitado uma Letra. Este campo aceita só numeros com virgula ou ponto");
	document.getElementById(campo).value=vr.substring(0,vr.length-1); 
  } else {
    if(vr.length<tammax){	 	
	  if(vr.length>casas){
		vr=vr.substr(0,vr.length-casas)+","+vr.substr(vr.length-casas,vr.length);
		document.getElementById(campo).value=vr;
	  }
	  vrteste=vr.substr(0,vr.length-casas);
	  numero=vrteste.length;
	  if(numero>0){
		comparador=5;
		var numero=0;
		while (numero<=vrteste.length){
		  if(numero==comparador){
			var anterior=numero-1;
			vrteste=vrteste.substr(0,vrteste.length-anterior)+"."+vrteste.substr(vrteste.length-anterior,vr.length);
			comparador=comparador+4;
		  }
		  numero++;
		}
		vr=vrteste+vr.substr(vr.length-casas,vr.length);
	  }
	  document.getElementById(campo).value=vr.substr(0,tammax);
	}
  }
}

// abre janelas poup-u
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//saber qual browser é 
String.prototype.contains = function(){
 var resu = false;
 for(var i=0; i < arguments.length; i++){
  if(this.toLowerCase().indexOf(arguments[i].toLowerCase()) > -1){
   resu = i + 1;
   break;
  }
 }
 return resu;
}

var _ua = navigator.userAgent;
var _vd = navigator.vendor;
var _pd = navigator.product;
var _browser_rv = ( _ua.indexOf('rv:') > -1 );
var _browser_op = ( _ua.indexOf('Opera') > -1 );
var _browser_ie = ( _ua.indexOf('MSIE') > -1 );
var _browser_pd = ( _pd == 'Gecko' );
var _browser_ff = ( _vd == 'Firefox' || ( _browser_pd && _ua.contains('Firefox','BonEcho','Paradiso') && ! _ua.contains('Flock')));
var _browser_fk = ( _browser_pd && _ua.contains('Flock') && ! _browser_ff );
var _browser_ns = ( _vd == 'Netscape' );
 
function isMozilla(){ // Mozilla Suite Browser
  return ( _browser_pd && _browser_rv && ! _browser_ff && ! _browser_ns && ! _browser_fk);
}

function isFirefox(){ // Mozilla Firefox
  return ( _browser_pd && ( _browser_ff || ! _browser_rv ) && ! _browser_fk);
}

function isFlock(){
  return ( _browser_pd && _browser_fk);
}

function isNetscape(){ // Netscape 6 or higher
  return( _browser_pd && _browser_ns ) ;
}

function isIE(){ // Internet Explorer
  return( _browser_ie && ! _browser_pd && ! _browser_op);
}

function isOpera(){ // Opera browser
  return( ! _browser_pd && _browser_op);
}

function otherBrowsers(){
  return( !isMozilla() && !isFirefox() && !isFlock() && !isNetscape() && !isIE() && !isOpera());
}

function verificanav(){
  if(isFirefox()){
    document.getElementById('navegador').value="firefox"
  } else {
	document.getElementById('navegador').value="ie"	
  }
}

/// VALIDAÇAO DE ROTINAS DE CADASTRO

// validacao do formulario de contato
function cad_contato(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('con_nome').value==""){
	alert("Informe o seu nome.");
	document.getElementById('con_nome').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('con_tel').value==""){
	alert("Informe o seu telefone.");
	document.getElementById('con_tel').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('con_email').value.length < 10 || document.getElementById('con_email').value.indexOf("@") < 0 || document.getElementById('con_email').value.indexOf(".") < 0) {
    alert("Informe um e-mail válido."); 
	document.getElementById('con_email').focus(); 
	pronto="S"; 
	return false;
  }
  if(document.getElementById('con_assunto').value==""){
	alert("Informe o assunto.");
	document.getElementById('con_assunto').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de contato
function cad_contatonew(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cli_nome').value==""){
	alert("Informe o seu nome.");
	document.getElementById('cli_nome').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_email').value.length < 10 || document.getElementById('cli_email').value.indexOf("@") < 0 || document.getElementById('cli_email').value.indexOf(".") < 0) {
    alert("Informe um e-mail válido."); 
	document.getElementById('cli_email').focus(); 
	pronto="S"; 
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}


// validacao do dados de esqueci minha senha
function env_sen(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('usus_email').value.length < 10 || document.getElementById('usus_email').value.indexOf("@") < 0 || document.getElementById('usus_email').value.indexOf(".") < 0) {
    alert("Informe um E-mail valido.\n       Campo obrigatório.");
    document.getElementById('usus_email').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}


// validacao do formulario de cadastro de usuario
function adm_cadusus(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('crespo').value==""){
	alert("Informe o nome do usuário.\n       Campo obrigatório.");
	document.getElementById('crespo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cemail').value.length < 10 || document.getElementById('cemail').value.indexOf("@") < 0 || document.getElementById('cemail').value.indexOf(".") < 0) {
	alert("Informe o e-mail do usuário.\n       Campo obrigatório.");
	document.getElementById('cemail').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cusuar').value==""){
	alert("   Informe o login.\nCampo obrigatório.");
	document.getElementById('cusuar').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('csenha').value==""){
	alert(" Informe a senha.\nCampo obrigatório.");
	document.getElementById('csenha').focus();
	erro="S";
	return false;
  }										
  if(document.getElementById('cnivel').value==""){
	alert("Informe tipo de usuário.\n    Campo obrigatório.");
	document.getElementById('cnivel').focus();
	erro="S";
	return false;
  }																																			  
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de usuario
function adm_cadocor(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ddtoco').value==""){
	alert("   Informe a data.\nCampo obrigatório.");
	document.getElementById('ddtoco').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cpropi').value==""){
	alert("Informe o nome do relator.\n       Campo obrigatório.");
	document.getElementById('cpropi').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cemail').value.length < 10 || document.getElementById('cemail').value.indexOf("@") < 0 || document.getElementById('cemail').value.indexOf(".") < 0) {
	alert("Informe o e-mail do usuário.\n       Campo obrigatório.");
	document.getElementById('cemail').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cocorp').value==""){
	alert("Informe a ocorrência.\n  Campo obrigatório.");
	document.getElementById('cocorp').focus();
	erro="S";
	return false;
  }																																			  
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de usuario
function adm_cadocorres(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ddtres').value==""){
	alert("   Informe a data.\nCampo obrigatório.");
	document.getElementById('ddtres').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('crespo').value==""){
	alert("Informe o nome do responsável.\n          Campo obrigatório.");
	document.getElementById('crespo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cocorr').value==""){
	alert("Informe a resposta.\n Campo obrigatório.");
	document.getElementById('cocorr').focus();
	erro="S";
	return false;
  }																																			  
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de historico
function adm_cadhis(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ccodig').value==""){
	alert(" Informe o código.\nCampo obrigatório.");
	document.getElementById('ccodig').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cdescr').value==""){
	alert("Informe a histórico.\n Campo obrigatório.");
	document.getElementById('cdescr').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de contas de despesas
function adm_cadctd(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ccodig').value==""){
	alert(" Informe o código.\nCampo obrigatório.");
	document.getElementById('ccodig').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cdescr').value==""){
	alert("Informe a histórico.\n Campo obrigatório.");
	document.getElementById('cdescr').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de contas de despesas
function adm_cadtipo(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('tip_descricao').value==""){
	alert("Informe a descrição.\n Campo obrigatório.");
	document.getElementById('tip_descricao').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// valida cadastro de contas gerenciais
function adm_cadctg(frmNome,url,destino ){
  var erro="N";
  if(document.getElementById('ccodig').value==""){
    alert("Você precisa informar a conta.\n       Campo obrigatório."); 
	document.getElementById('ccodig').focus(); 
	erro="S";
	return false;
  }
  if(document.getElementById('cdescr').value==""){
    alert("Você precisa informar o nome da conta.\n              Campo obrigatório."); 
	document.getElementById('cdescr').focus(); 
    erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// valida cadastro de centro custo
function adm_cadctr(frmNome,url,destino ){
  var erro="N";
  if(document.getElementById('cta_descricao').value==""){
    alert("Você precisa informar o nome da centro de custo.\n                         Campo obrigatório."); 
	document.getElementById('cta_descricao').focus(); 
    erro="S";
	return false;
  } 
  if(document.getElementById('cta_percentual').value!=""){
    f=document.getElementById(frmNome);
    for (i=0;i<f.elements.length;i++){
      if(f.elements[i].checked){
        if(f.elements[i].value=="N"){
		  alert("Você precisa indicar S para percentual.\n             Campo obrigatório."); 
          erro="S";
	      return false;
		}
      }
	}
  } 
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// valida cadastro de indices mensais
function adm_cadidm(frmNome,url,destino ){
  var erro="N";
  if(document.getElementById('cmesre').value==""){
    alert("Você precisa informar o mês referência.\n               Campo obrigatório."); 
    document.getElementById('cmesre').focus(); 
    erro="S";
    return false;
  } 
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// valida cadastro de indices diario
function adm_cadidd(frmNome,url,destino ){
  var erro="N";
  if(document.getElementById('cli_codigo').value==""){
    alert("Você precisa informar o cliente.\n            Campo obrigatório."); 
    document.getElementById('cli_codigo').focus(); 
    erro="S";
    return false;
  } 
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// valida cadastro de indices diario
function adm_cadcom(frmNome,url,destino ){
  var erro="N";
  if(document.getElementById('com_descricao').value==""){
    alert("Você precisa informar a descrição.\n               Campo obrigatório."); 
	document.getElementById('com_descricao').focus(); 
    erro="S";
	return false;
  } 
  if(document.getElementById('com_percentual').value=="" || document.getElementById('com_percentual').value=="0,00"){
    alert("Você precisa informar o percentual.\n               Campo obrigatório."); 
	document.getElementById('com_percentual').focus(); 
    erro="S";
	return false;
  } 
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// valida cadastro de centro custo
function validacentro(frmNome,url,destino ){
  var erro="N";
  if(document.getElementById('cta_descricao').value==""){
    alert("Você precisa informar o nome da centro de custo"); 
	document.getElementById('cta_descricao').focus(); 
    erro="S";
	return false;
  } 
  if(document.getElementById('cta_conta').value==""){
    alert("Você precisa informar o nome da conta"); 
	document.getElementById('cta_conta').focus(); 
    erro="S";
	return false;
  } 
  if(document.getElementById('cta_percentual').value!="" || document.getElementById('cta_percentual').value!=0.00){
    f=document.getElementById(frmNome);
    for (i=0;i<f.elements.length;i++){
      if(f.elements[i].checked){
        if(f.elements[i].value=="N"){
	  alert("Você precisa indicar S para percentual"); 
          erro="S";
	  return false;
	}
      }
    }
  } 
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// valida cadastro de indices diario
function adm_cadban(frmNome,url,destino ){
  var erro="N";
  if(document.getElementById('cnubco').value==""){
    alert("Você precisa informar o banco.\n          Campo obrigatório."); 
    document.getElementById('cnubco').focus(); 
    erro="S";
    return false;
  } 
  if(document.getElementById('cagenc').value==""){
    alert("Você precisa informar a agência.\n           Campo obrigatório."); 
	document.getElementById('cagenc').focus(); 
    erro="S";
	return false;
  } 
  if(document.getElementById('cctacc').value==""){
    alert("Você precisa informar a conta corrente.\n               Campo obrigatório."); 
	document.getElementById('cctacc').focus(); 
    erro="S";
	return false;
  } 
  if(document.getElementById('cctacb').value==""){
    alert("Você precisa informar a conta cobrança.\n               Campo obrigatório."); 
	document.getElementById('cctacb').focus(); 
    erro="S";
	return false;
  } 
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// valida cadastro de indices diario
function adm_cadbco(frmNome,url,destino ){
  var erro="N";
  if(document.getElementById('ccodig').value==""){
    alert("Você precisa informar o codigo.\n         Campo obrigatório."); 
	document.getElementById('ccodig').focus(); 
    erro="S";
	return false;
  } 
  if(document.getElementById('cbanco').value==""){
    alert("Você precisa informar o banco.\n         Campo obrigatório."); 
	document.getElementById('cbanco').focus(); 
    erro="S";
	return false;
  } 
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// valida cadastro de pesquisa
function adm_pesfil(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('filtr1').value==""){
    alert("Informe a fonte de pesquisa.\n        Campo obrigatório.");
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// valida cadastro de pesquisa
function adm_excfil(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('id_fun').value==""){
    alert("Selecione um ou mais registro.\n        Campo obrigatório.");
    document.getElementById('id_fun').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// valida cadastro de administradora
function adm_cadadm(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cnomes').value==""){
	alert("Informe o nome da empresa.\n       Campo obrigatório.");
	document.getElementById('cnomes').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('c_cnpj').value==""){
	alert("Informe o CPF/CNPJ.\n  Campo obrigatório.");
	document.getElementById('c_cnpj').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_cep').value==""){
	alert("   Informe o cep.\nCampo obrigatório.");
	document.getElementById('cli_cep').focus();
	erro="S";
	return false;
  }										
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade da Empresa.\n          Campo obrigatório");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }										  
  if(document.getElementById('cender').value==""){
	alert("Informe o endereço.\n Campo obrigatório.");
	document.getElementById('cender').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cnumer').value==""){
	alert(" Informe o número.\nCampo obrigatório.");
	document.getElementById('cnumer').focus();
	erro="S";
	return false;
  }										
  if(document.getElementById('ctelef').value==""){
	alert("Informe o telefone.\nCampo obrigatório.");
	document.getElementById('ctelef').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cemail').value.length < 10 || document.getElementById('cemail').value.indexOf("@") < 0 || document.getElementById('cemail').value.indexOf(".") < 0) {
	alert("Informe o e-mail da empresa.\n              Campo obrigatório.");
	document.getElementById('cemail').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('crespo').value==""){
	alert("Informe o responsável.\n   Campo obrigatório.");
	document.getElementById('crespo').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Funcionários
function adm_cadfun(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cnomes').value==""){
	alert("   Informe o nome.\n Campo obrigatório.");
	document.getElementById('cnomes').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('fun_sexo').value==""){
	alert("    Informe o sexo.\n Campo obrigatório.");
	document.getElementById('fun_sexo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('c__cpf').value==""){
	alert(" Informe o CPF/CNPJ.\n  Campo obrigatório.");
	document.getElementById('c__cpf').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_cep').value==""){
	alert("   Informe o cep.\nCampo obrigatório.");
	document.getElementById('cli_cep').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade.\n      Campo obrigatório.");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cender').value==""){
	alert("Informe o endereço.\n    Campo obrigatório.");
	document.getElementById('cender').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cnumer').value==""){
	alert(" Informe o número.\n Campo obrigatório.");
	document.getElementById('cnumer').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('ctelef').value==""){
	alert("Informe o número do telefone.\n          Campo obrigatório.");
	document.getElementById('ctelef').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('fun_email').value.length < 10 || document.getElementById('fun_email').value.indexOf("@") < 0 || document.getElementById('fun_email').value.indexOf(".") < 0) {
	alert("  Informe o e-mail.\nCampo obrigatório.");
	document.getElementById('fun_email').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Condominio
function adm_cadcon(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ccodig').value==""){
	alert(" Informe o código.\nCampo obrigatório.");
	document.getElementById('ccodig').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cpredi').value==""){
	alert("Informe o nome do condomínio.\n           Campo obrigatório.");
	document.getElementById('cpredi').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('capeli').value==""){
	alert("Informe o apelido do condomínio.\n           Campo obrigatório.");
	document.getElementById('capeli').focus();
	erro="S";
	return false;
  }
//  if(document.getElementById('c_cnpj').value==""){
//	alert("Informe o CPF/CNPJ do condomínio.\n          Campo obrigatório.");
//	document.getElementById('c_cnpj').focus();
//	erro="S";
//	return false;
//  }
  if(document.getElementById('cender').value==""){
	alert("Informe o endereço do condomínio.\n          Campo obrigatório.");
	document.getElementById('cender').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cnumer').value==""){
	alert(" Informe o número.\n Campo obrigatório.");
	document.getElementById('cnumer').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('c__cep').value==""){
	alert("   Informe o cep.\nCampo obrigatório.");
	document.getElementById('c__cep').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade.\n      Campo obrigatório.");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }
//  if(document.getElementById('cemail').value.length < 10 || document.getElementById('cemail').value.indexOf("@") < 0 || document.getElementById('cemail').value.indexOf(".") < 0) {
//	alert("  Informe um e-mail.\nCampo obrigatório.");
//	document.getElementById('cemail').focus();
//	erro="S";
//	return false;
//  }																																			
  if(document.getElementById('ctipun').value==""){
	alert("Escolha o tipo de unidade.\n      Campo obrigatório.");
	document.getElementById('ctipun').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ctipfr').value==""){
	alert("Escolha o tipo de fração.\n      Campo obrigatório.");
	document.getElementById('ctipfr').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de bloco
function adm_cadblc(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cbltip').value==""){
	alert("Informe o bloco tipo.\n Campo obrigatório.");
	document.getElementById('cbltip').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cdescr').value==""){
	alert("Informe o nome do descricao.\n       Campo obrigatório.");
	document.getElementById('cdescr').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de bloco
function adm_cadmul(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ddiain').value==""){
	alert("  Informe o período.\n  Campo obrigatório.");
	document.getElementById('ddiain').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('nmulta').value==""){
	alert("Informe o % de multa.\n   Campo obrigatório.");
	document.getElementById('nmulta').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de sindico
function adm_cadsin(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('csindi').value==""){
	alert("Informe o nome do síndico.\n      Campo obrigatório.");
	document.getElementById('csindi').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ctipfj').value==""){
	alert("     Informe o tipo.\n Campo obrigatório.");
	document.getElementById('ctipfj').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('c__cpf').value==""){
	alert("Informe o CPF/CNPJ do síndico.\n          Campo obrigatório.");
	document.getElementById('c__cpf').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cender').value==""){
	alert("Informe o endereço do síndico.\n          Campo obrigatório.");
	document.getElementById('cender').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cnumer').value==""){
	alert(" Informe o número.\n Campo obrigatório.");
	document.getElementById('cnumer').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('c__cep').value==""){
	alert("   Informe o cep.\nCampo obrigatório.");
	document.getElementById('c__cep').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade.\n      Campo obrigatório.");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ctelsi').value==""){
	alert("  Informe o telefone.\nCampo obrigatório.");
	document.getElementById('ctelsi').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cemasi').value.length < 10 || document.getElementById('cemasi').value.indexOf("@") < 0 || document.getElementById('cemasi').value.indexOf(".") < 0) {
	alert("Informe um e-mail.\nCampo obrigatório.");
	document.getElementById('cemasi').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de bloco
function adm_cadcnf(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cbcofx').value==""){
	alert("Selecione o banco de cobrança.\n           Campo obrigatório.");
	document.getElementById('cbcofx').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de contrato
function adm_cadcontrato(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ctr_dtctro').value=="00-00-0000" || document.getElementById('ctr_dtctro').value==""){
	alert("Informe a data do contrato.\n       Campo obrigatório.");
	document.getElementById('ctr_dtctro').focus();
	erro="S";
	return false;
  }
  //if(document.getElementById('ctr_tipo').value==""){
	//alert("Informe o tipo de contrato.\n      Campo obrigatório.");
	//document.getElementById('ctr_tipo').focus();
	//erro="S";
	//return false;
  //}
  if(document.getElementById('ctr_dtterm').value=="00-00-0000" || document.getElementById('ctr_dtterm').value==""){
	alert("Informe a data do término do contrato.\n                  Campo obrigatório.");
	document.getElementById('ctr_dtterm').focus();
	erro="S";
	return false;
  }
  //if(document.getElementById('ctr_dtreaj').value=="00-00-0000" || document.getElementById('ctr_dtreaj').value==""){
	//alert("Informe a data do reajuste do contrato.\n                Campo obrigatório.");
	//document.getElementById('ctr_dtreaj').focus();
	//erro="S";
	//return false;
  //}
  if(document.getElementById('id_adm').value==""){
	alert("Informe o nome da empresa.\n      Campo obrigatório.");
	document.getElementById('id_adm').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}


// validacao do formulario de cadastro de proprietario
function adm_cadpro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cnomes').value==""){
	alert("Informe o nome do proprietário.\n    Campo obrigatório.");
	document.getElementById('cnomes').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('pro_sexo').value==""){
	alert("    Informe o sexo.\n Campo obrigatório.");
	document.getElementById('pro_sexo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('c__cpf').value==""){
	alert("Informe o CPF/CNPJ do proprietário.\n            Campo obrigatório.");
	document.getElementById('c__cpf').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cnumap').value==""){
	alert(" Informe a unidade.\n Campo obrigatório.");
	document.getElementById('cnumap').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cender').value==""){
	alert("Informe o endereço do síndico.\n          Campo obrigatório.");
	document.getElementById('cender').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cnumer').value==""){
	alert(" Informe o número.\n Campo obrigatório.");
	document.getElementById('cnumer').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('c__cep').value==""){
	alert("   Informe o cep.\nCampo obrigatório.");
	document.getElementById('c__cep').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade.\n      Campo obrigatório.");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ctelef').value==""){
	alert("  Informe o telefone.\nCampo obrigatório.");
	document.getElementById('ctelef').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cemail').value.length < 10 || document.getElementById('cemail').value.indexOf("@") < 0 || document.getElementById('cemail').value.indexOf(".") < 0) {
	alert("Informe um e-mail.\nCampo obrigatório.");
	document.getElementById('cemail').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}


// validacao do formulario de cadastro de proprietario para administradora
function adm_cadproe(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cnomes').value==""){
	alert("Informe o nome do proprietário.\n           Campo obrigatório.");
	document.getElementById('cnomes').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('pro_sexo').value==""){
	alert("    Informe o sexo.\n Campo obrigatório.");
	document.getElementById('pro_sexo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cnumap').value==""){
	alert("  Informe a unidade.\n Campo obrigatório.");
	document.getElementById('cnumap').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade.\n      Campo obrigatório.");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do cadastro de moradores
function adm_cadmor(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ass_dependente').value==""){
	alert("Informe o nome do dependente.\n       Campo obrigatório");
	document.getElementById('ass_dependente').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ass_sexo').value==""){
	alert("Informe o sexo do dependente.\n       Campo obrigatório");
	document.getElementById('ass_sexo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ass_grauparente').value==""){
	alert("Informe o grau de parentesco.\n          Campo obrigatório.");
	document.getElementById('ass_grauparente').focus();
	erro="S";
	return false;
  }  
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// validacao do cadastro de inquilino
function adm_cadinq(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ass_nome').value==""){
	alert("Informe o nome do inquilino.\n       Campo obrigatório");
	document.getElementById('ass_nom').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ass_sexo').value==""){
	alert("Informe o sexo do inquilino.\n       Campo obrigatório");
	document.getElementById('ass_sexo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ass_tel').value==""){
	alert("Informe o número do telefone.\n          Campo obrigatório.");
	document.getElementById('ass_tel').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do cadastro de moradores
function adm_cadcxa(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ccodbc').value==""){
	alert("  Informe o caixa.\nCampo obrigatório");
	document.getElementById('ccodbc').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cbanco').value==""){
	alert("Informe o nome do responsável.\n          Campo obrigatório");
	document.getElementById('cbanco').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('crespo').value==""){
	alert("Informe o responsável.\n   Campo obrigatório.");
	document.getElementById('crespo').focus();
	erro="S";
	return false;
  }  
  if(erro=="N"){enviaForm(frmNome,url,destino);}
}

// validacao do movimentacao financeira
function fin_movimento(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('fin_data').value==""){
	alert("Informe uma data.\nCampo obrigatório");
	document.getElementById('fin_data').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('fin_conta').value==""){
	alert("Selecione uma conta\n  Campo obrigatório");
	document.getElementById('fin_conta').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('fin_historico').value==""){
	alert("Digite um histórico.\nCampo obrigatório");
	document.getElementById('fin_historico').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('fin_documento').value==""){
	alert("Informe o documento.\n   Campo obrigatório");
	document.getElementById('fin_documento').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('fin_total').value==""){
	alert("Informe o valor do lançamento.\n          Campo obrigatório");
	document.getElementById('fin_total').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do movimentacao financeira
function fin_movicta(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('fin_data').value==""){
	alert("Informe uma data.\nCampo obrigatório");
	document.getElementById('fin_data').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('fin_conta').value==""){
	alert("Selecione uma conta\n  Campo obrigatório");
	document.getElementById('fin_conta').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('id_ban').value==""){
	alert("Selecione um banco\n  Campo obrigatório");
	document.getElementById('id_ban').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('fin_historico').value==""){
	alert("Digite um histórico.\nCampo obrigatório");
	document.getElementById('fin_historico').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('fin_documento').value==""){
	alert("Informe o documento.\n   Campo obrigatório");
	document.getElementById('fin_documento').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('fin_total').value==""){
	alert("Informe o valor do lançamento.\n          Campo obrigatório");
	document.getElementById('fin_total').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}


// validacao do formulario de orcamento
function valida_orca(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('orc_anoinicial').value==""){
	alert("Você tem que informar ano inicial.\n           Campo obrigatório.");
	document.getElementById('orc_anoinicial').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('orc_anofinal').value==""){
	alert("Você tem que informar ano final.\n             Campo obrigatório.");
	document.getElementById('orc_anofinal').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('orc_mesrefbase').value==""){
	alert("Você tem que informar o Mês referencia Base.\n                   Campo obrigatório.");
	document.getElementById('orc_mesrefbase').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('orc_periodo').value=="" || document.getElementById('orc_periodo').value > 12){
	alert("O período tem que ser maior que 1 mês e menor que 12 meses para projeção.\n                                     Campo obrigatório.");
	document.getElementById('orc_periodo').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de movimentacao de orçamento
function valida_movorca(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('orc_conta').value==""){
	alert("Você tem que informar uma conta.\n           Campo obrigatório.");
	document.getElementById('orc_conta').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('orc_valor').value==""){
	alert("Você tem que informar o valor base.\n             Campo obrigatório.");
	document.getElementById('orc_valor').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Cliente
function cli_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cli_categoria').value==""){
	alert("Informe a categoria do cliente.\n        Campo obrigatório.");
	document.getElementById('cli_categoria').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_excluido').value==""){
	alert("Informe a situação do cliente.\n        Campo obrigatório.");
	document.getElementById('cli_excluido').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_nome').value==""){
	alert("Informe o nome do cliente.\n      Campo obrigatório.");
	document.getElementById('cli_nome').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_cep').value==""){
	alert("   Informe o cep.\nCampo obrigatório.");
	document.getElementById('cli_cep').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade.\n      Campo obrigatório.");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cender').value==""){
	alert("Informe o endereço do cliente.\n        Campo obrigatório.");
	document.getElementById('cender').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_numero').value==""){
	alert("Informe o número do cliente.\n        Campo obrigatório.");
	document.getElementById('cli_numero').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_tel').value==""){
	alert("Informe o número do telefone.\n          Campo obrigatório.");
	document.getElementById('cli_tel').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Cliente
function soc_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cli_respon').value==""){
	alert("Informe o responsável.\n   Campo obrigatório.");
	document.getElementById('cli_respon').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}


// validacao do formulario de cadastro de Cliente NewLetters
function clinew_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cli_nome').value==""){
    alert("Informe o nome do cliente.\n      Campo obrigatório.");
    document.getElementById('cli_nome').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('cli_email').value.length < 10 || document.getElementById('cli_email').value.indexOf("@") < 0 || document.getElementById('cli_email').value.indexOf(".") < 0) {
    alert("Informe um e-mail.\nCampo obrigatório.");
    document.getElementById('cli_email').focus();
    erro="S";
    return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Cliente NewLetters
function clirec_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cli_nome').value==""){
    alert("Informe o nome do cliente.\n      Campo obrigatório.");
    document.getElementById('cli_nome').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('cli_cpfcnpj').value==""){
	alert("Informe o CPF/CNPJ do cliente.\n          Campo obrigatório.");
	document.getElementById('cli_cpfcnpj').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_rg').value==""){
	alert("Informe o RG do cliente.\n      Campo obrigatório.");
	document.getElementById('cli_rg').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Fornecedores
function for_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('for_nome').value==""){
	alert("Informe o nome do fornecedor.\n      Campo obrigatório.");
	document.getElementById('for_nome').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cli_cep').value==""){
	alert("   Informe o cep.\nCampo obrigatório.");
	document.getElementById('cli_cep').focus();
	erro="S";
	return false;
  }																																			
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade.\n      Campo obrigatório.");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('for_tel').value==""){
	alert("Informe o número do telefone.\n          Campo obrigatório.");
	document.getElementById('for_tel').focus();
	erro="S";
	return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do cadastro de pendencia
function fin_movcom(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('comentario').value==""){
	alert("Campo cometário não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('comentario').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas geral para incluir
function conf_ratfgin(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ctades').value==""){
	alert("Campo Conta não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('ctades').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('nvalor').value=="0,00"){
	alert("Campo Valor não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('nvalor').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas geral para exclusao
function conf_ratfgex(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ctades').value==""){
	alert("Campo Conta não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('ctades').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de cota fração
function conf_ratfin(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cmesre').value==""){
    alert("O mês ref. não pode ser vazio\n         Campo obrigatório");
    document.getElementById('cmesre').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('tprate').value==""){
    alert("Selecione o tipo de rateio.\n     Campo obrigatório");
    document.getElementById('tprate').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas individual para incluir
function conf_ratfiin(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cli_codigo').value==""){
	alert("Campo Cliente não pode ser vazio.\n            Campo obrigatório");
	document.getElementById('cli_codigo').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ctades').value==""){
	alert("Campo Conta não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('ctades').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('nvalor').value==""){
	alert("Campo Valor não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('nvalor').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas bloco para incluir
function conf_ratfbin(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ctablc').value==""){
	alert("Campo Bloco não pode ser vazio.\n            Campo obrigatório");
	document.getElementById('ctablc').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ctades').value==""){
	alert("Campo Conta não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('ctades').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('nvalor').value=="0,00"){
	alert("Campo Valor não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('nvalor').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas bloco para incluir
function conf_ratfbex(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ctablc').value==""){
	alert("Campo Bloco não pode ser vazio.\n            Campo obrigatório");
	document.getElementById('ctablc').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('ctades').value==""){
	alert("Campo Conta não pode ser vazio.\n             Campo obrigatório");
	document.getElementById('ctades').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de gas
function conf_ratgin(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ntotga').value=="0,00"){
    alert("Campo Valor da Receita Total não pode ser vazio.\n                          Campo obrigatório.");
    document.getElementById('ntotga').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de agua
function conf_ratain(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('nvlve1').value=="0,00"){
	alert("Campo Consumo Mínimo não pode ser vazio.\n                      Campo obrigatório");
	document.getElementById('nvlve1').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('nvlma2').value=="0,00"){
	alert("Campo M3 do Gás não pode ser vazio.\n                 Campo obrigatório");
	document.getElementById('nvlma2').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('nvlve2').value=="0,00"){
	alert("Campo Consumo Mínimo não pode ser vazio.\n                      Campo obrigatório");
	document.getElementById('nvlve2').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('nvlma3').value=="0,00"){
	alert("Campo M3 do Gás não pode ser vazio.\n                 Campo obrigatório");
	document.getElementById('nvlma3').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('nvlve3').value=="0,00"){
	alert("Campo Consumo Mínimo não pode ser vazio.\n                      Campo obrigatório");
	document.getElementById('nvlve3').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas bloco para incluir
function adm_cadclas(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('clas_descricao').value==""){
    alert("Campo descrição não pode ser vazio.\n               Campo obrigatório");
    document.getElementById('clas_descricao').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas bloco para incluir
function adm_cadpro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('pro_codigo').value==""){
    alert("Campo código não pode ser vazio.\n               Campo obrigatório");
    document.getElementById('pro_codigo').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('pro_descricao').value==""){
    alert("Campo descrição não pode ser vazio.\n               Campo obrigatório");
    document.getElementById('pro_descrição').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('id_clas').value==""){
    alert("Campo classe não pode ser vazio.\n               Campo obrigatório");
    document.getElementById('id_clas').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas bloco para incluir
function fin_pend(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ddtvco').value=="00-00-0000"){
    alert("Campo vencimento não pode ser vazio.\n                  Campo obrigatório.");
    document.getElementById('ddtvco').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('nvalor').value=="0,00"){
    alert("Campo valor não pode ser vazio.\n           Campo obrigatório.");
    document.getElementById('nvalor').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de rateio de despesas bloco para incluir
function ope_orc(frmNome, url, destino){
  var erro="N";
  //if(document.getElementById('id_fac').value==""){
    //alert("Campo faculdade não pode ser vazio.\n               Campo obrigatório.");
    //document.getElementById('id_fac').focus();
    //erro="S";
    //return false;
  //}
  //if(document.getElementById('id_cur').value==""){
    //alert("Campo curso não pode ser vazio.\n               Campo obrigatório.");
    //document.getElementById('id_cur').focus();
    //erro="S";
    //return false;
  //}
  if(document.getElementById('orc_condicao').value=="P"){
    if(document.getElementById('orc_parcela').value==""){    
      alert("Campo parcela não pode ser vazio para condição a prazo.\n                               Campo obrigatório.");
      document.getElementById('orc_parcela').focus();
      erro="S";
      return false;
    }
  }
  if(document.getElementById('id_pro').value==""){
    alert("Campo produto não pode ser vazio.\n               Campo obrigatório.");
    document.getElementById('id_pro').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('qtde').value==""){
    alert("Campo quantidade não pode ser vazio.\n                 Campo obrigatório.");
    document.getElementById('qtde').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

function ope_orcalt(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('orc_condicao').value=="P"){
    if(document.getElementById('orc_parcela').value==""){    
      alert("Campo parcela não pode ser vazio para condição a prazo.\n                               Campo obrigatório.");
      document.getElementById('orc_parcela').focus();
      erro="S";
      return false;
    }
  }
}

// validacao do formulario de cadastro de Fornecedores
function fac_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('fac_nome').value==""){
	alert("Informe o nome da faculdade.\n         Campo obrigatório.");
	document.getElementById('fac_nome').focus();
	erro="S";
	return false;
  }
  if(document.getElementById('cmbbxn11_1').value==""){
	alert("Escolha a U.F. e a cidade.\n      Campo obrigatório.");
	document.getElementById('cmbbxn11_1').focus();
	erro="S";
	return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Fornecedores
function cur_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cur_nome').value==""){
    alert("Informe o nome do curso.\n     Campo obrigatório.");
    document.getElementById('cur_nome').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('orc_turma').value==""){
    alert("Informe o nome da turma.\n     Campo obrigatório.");
    document.getElementById('orc_turma').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('orc_formando').value==""){
    alert("Informe o qtde. de formandos.\n        Campo obrigatório.");
    document.getElementById('orc_formando').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('cli_respon').value==""){
    alert("Informe o nome do representante.\n          Campo obrigatório.");
    document.getElementById('cli_respon').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('cli_tel').value==""){
    alert("Informe o telefone.\n Campo obrigatório.");
    document.getElementById('cli_tel').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('cli_email').value.length < 10 || document.getElementById('cli_email').value.indexOf("@") < 0 || document.getElementById('cli_email').value.indexOf(".") < 0) {
    alert("Informe um e-mail.\nCampo obrigatório.");
    document.getElementById('cli_email').focus();
    erro="S";
    return false;
  }																																			
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Fornecedores
function rec_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('rec_empr').value==""){
    alert("Informe o nome da empresa.\n     Campo obrigatório.");
    document.getElementById('rec_empr').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('for_codigor').value==""){
    if(document.getElementById('cli_codigor').value==""){
      if(document.getElementById('rec_outro').value==""){    
	alert("Informe o nome do favorecido.\n          Campo obrigatório.");
	document.getElementById('rec_outro').focus();
	erro="S";
	return false;
      }
    }
  }
  if(document.getElementById('fin_historicor').value==""){
    alert("Informe um histórico.\n  Campo obrigatório.");
    document.getElementById('fin_historicor').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('fin_totalr').value=="" || document.getElementById('fin_totalr').value==0.00){
    alert("   Informe o valor.\n Campo obrigatório.");
    document.getElementById('fin_totalr').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Fornecedores
function recesc_cadastro(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cli_codigor').value==""){
    alert("Informe o nome do favorecido.\n        Campo obrigatório.");
    document.getElementById('cli_codigor').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('cli_codigo').value==""){
    if(document.getElementById('rec_outro').value==""){    
      alert("Informe o nome do emitente ou outro.\n                Campo obrigatório.");
      document.getElementById('rec_outro').focus();
      erro="S";
      return false;
    }
  }
  if(document.getElementById('fin_historicor').value==""){
    alert("Informe um histórico.\n  Campo obrigatório.");
    document.getElementById('fin_historicor').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('fin_totalr').value=="" || document.getElementById('fin_totalr').value==0.00){
    alert("   Informe o valor.\n Campo obrigatório.");
    document.getElementById('fin_totalr').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do formulario de cadastro de Fornecedores
function cad_rateio(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('ndiaven').value==""){
    alert("Informe o dia de vencimento.\n         Campo obrigatório.");
    document.getElementById('ndiaven').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de texto de conveção/regimento/ata
function uti_cad(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('tex_data').value==""){
    alert("Data não pode ser vazio.\n    Campo obrigatório.");
    document.getElementById('tex_data').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('tex_titulo').value==""){
    alert("Nome não pode ser vazio.\n     Campo obrigatório.");
    document.getElementById('tex_titulo').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('ser_servicotipo').value==""){
    alert("Categoria não pode ser vazio.\n        Campo obrigatório.");
    document.getElementById('ser_servicotipo').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

// validacao do dados de texto de conveção/regimento/ata
function transf_reg(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('id_pro').value==""){
    alert("Você tem que selecionar um ou mais registro.");
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

function cad_pesquisa(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('fontes').value=="Digite uma palavra-chave"){
    alert("Indique uma fonte para pesquisa.");
    document.getElementById('fontes').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

function cad_tel(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('tel_nome').value==""){
    alert("Indique um nome.");
    document.getElementById('tel_nome').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('tel_fone').value==""){
    alert("Indique um telefone.");
    document.getElementById('tel_fone').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

function cad_cat(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('tip_descricao').value==""){
    alert("Indique uma categoria.");
    document.getElementById('tip_descricao').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

function cad_cadata(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('cal_data').value==""){
    alert("A data não pode ser vazia.");
    document.getElementById('cal_data').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('cal_descricao').value==""){
    alert("A obrigação não pode ser vazia.");
    document.getElementById('cal_descricao').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

function cad_depoimento(frmNome, url, destino){
  var erro="N";
  if(document.getElementById('depo_data').value==""){
    alert("A data não pode ser vazia.");
    document.getElementById('depo_data').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('depo_empresa').value==""){
    alert("A tema não pode ser vazia.");
    document.getElementById('depo_empresa').focus();
    erro="S";
    return false;
  }
  if(document.getElementById('depo_texto').value==""){
    alert("O informativo não pode ser vazia.");
    document.getElementById('depo_texto').focus();
    erro="S";
    return false;
  }
  if(erro=="N"){enviaForm(frmNome, url, destino);}
}

