
	var NetContabil
	
	function abre_login( form ) {
		window.document.form_login.target = "NetContabil";
		window.document.form_login.usuario.value = form.usuario.value;
		window.document.form_login.senha.value = form.senha.value;

		if(navigator.appName.indexOf("Netscape") != -1)
	   		NetContabil = window.open("", "NetContabil","toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=0,screenX=0,screenY=0,left=0,top=0,width=780,height=480");
		else
   			NetContabil = window.open("", "NetContabil","toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=780,height=480");

		if(NetContabil)
		{
			window.document.form_login.submit();
			form.reset();
		}

		return false;
	}
	
	function abre_esqueci(url) {

		if(navigator.appName.indexOf("Netscape") != -1)
	   		NetContabil = window.open(url, "NetContabil","toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=0,screenX=0,screenY=0,left=0,top=0,width=780,height=480");
		else
   			NetContabil = window.open(url, "NetContabil","toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=780,height=480");

		return false;
	}
	
	function existe_email(campo) {
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo.value)))
   					{
			return false;
		} else	return true;
	}
		
	function consiste(form){
		var div = document.getElementById("iframe_boletim_id");
		if( div ) div.innerHTML = "<iframe name=\"iframe_boletim\" style=\"display:none\" ></iframe>"; 
		
		var message = "";
		var nome = form.nome.value;
		if( nome.length <= 2 ){
			message += "O campo nome é de preenchimento obrigatório.\n";
		}
		
		if( !existe_email(  form.email ) ){
			message += "O email informado é inválido.\n";
		}
		
		var assinado = false;
		var checks = 0;
		
		for( i = 0; i < form.elements.length; i++){
			if ( form.elements[ i ].type == "checkbox"){
				checks++;
				if( form.elements[ i ].checked ) {
					assinado = true;
					break;
				}
			}
		}
		if ( checks == 0 ) assinado = true;
		
		if( !assinado  ){
			message += "Escolha uma área de seu interesse.\n"
		}	
		
		
		if( message != ""){
			message += "\n\r\nCorrija os erros e tente novamente."
			alert( message );
		} else {
			form.target = "iframe_boletim";
		}
		return ( message == "");
		
	}
	
	function reset_form_boletim(){
		document.boletim.reset();
		alert('Assinatura efetuada com sucesso. Obrigado!');
	}
	
	function consiste_contato(form){
		var div = document.getElementById("iframe_contato_id");
		if( div ) div.innerHTML = "<iframe name=\"iframe_contato\" style=\"display:none\" ></iframe>"; 
		

		var message = "";
		
		var empresa = form.nome.value;
		if( empresa.length < 3){
			message += "O campo Nome é de preenchimento obrigatório.\n";
		}
		
		if( !existe_email(  form.email ) ){
			message += "O email informado é inválido.\n";
		}
				
		var tel = form.tel.value;
		if( tel.length < 3){
			message += "O campo Telefone é de preenchimento obrigatório.\n";
		}
		
		
		
		var mensagem = form.mensagem.value;
		if( mensagem.length < 3 ){
			message += "O campo Mensagem é de preenchimento obrigatório.\n";
		}

		if( message != ""){
			message += "\n\r\nCorrija os erros e tente novamente."
			alert( message );
		} else {
			
			form.target = "iframe_contato";
		}

		return ( message == "");
	}
	
	function reset_form_contato(){
		document.contato.reset();
		
	}
	
	function consiste_remove(form){
		var div = document.getElementById("iframe_remove_id");
		if( div ) div.innerHTML = "<iframe name=\"iframe_remove\" style=\"display:none\" ></iframe>"; 
		

		var message = "";
		
		if( !existe_email(  form.email ) ){
			message += "O email informado é inválido.\n";
		}
		
		
		if( message != ""){
			message += "\n\r\nCorrija os erros e tente novamente."
			alert( message );
		} else {
			form.target = "iframe_remove";
		}

		return ( message == "");
	}
	
	function reset_form_remove(){
		document.remove.reset();
	}
	
	function fechar(){
		var Div = document.getElementById("banner_flutuante");
		Div.style.display = "none";
	}		

	function ver_boletim(id) {
		url = 'newsletter_visualiza.php?id='+id;
		window.open(url,'','width=620,height=450,scrollbars=1');
	}	
		function existe_email(campo) {
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo.value)))
   					{
			return false;
		} else	return true;
	}

function TestaValorCurrency(nValor) {

  var newValue = nValor;
  var newLength = newValue.length;
  var newValue2 = "";
  var bNegativo = false;
  
  for (var i =0; i != newLength; i++) {
    aChar = newValue.substring (i, i+1);
    
    if (aChar == "-")
       bNegativo = true
    if (aChar == ",") 
      newValue2 = newValue2 + ".";
    else
      newValue2 = newValue2 + aChar;
  }

  var newValue = newValue2;
  
  if ( isNaN(newValue) || bNegativo) {
    alert ("O valor informado é inválido. Formato: 9999,99 ")
    return false;
  }
  
  return true;
}

function TestaValorInt(nValor) {

  var newValue = nValor;
  var newLength = newValue.length;
  var newValue2 = "";
  var bNegativo = false;
  
  for (var i =0; i != newLength; i++) {
    aChar = newValue.substring (i, i+1);
    
    if (aChar == "-")
       bNegativo = true
    if (aChar == ",") 
       bNegativo = true
    else
      newValue2 = newValue2 + aChar;
  }

  var newValue = newValue2;
  
  if ( isNaN(newValue) || bNegativo) {
    alert ("O Valor informado inválido. Formato: 999999 ")
    return false;
  }
  
  return true;
}

function AcertaValor(nValor) {

  var newValue = nValor;
  var newLength = newValue.length;
  var newValue2 = "";
  var bNegativo = false;
  
  for (var i =0; i != newLength; i++) {
    aChar = newValue.substring (i, i+1);
    
    if (aChar == "-")
       bNegativo = true
    if (aChar == ",") 
      newValue2 = newValue2 + ".";
    else
      newValue2 = newValue2 + aChar;
  }

  var newValue = newValue2;
  
    
  return newValue;
}

function AcertaValor2(nValor) {

  var newValue3 = nValor;
  var newLength = newValue3.length;
  var newValue2 = "";
  var bNegativo = false;
  
  for (var i =0; i != newLength; i++) {
    aChar = newValue3.substring (i, i+1);
    
    if (aChar == "-")
       bNegativo = true
    if (aChar == ".") 
      newValue2 = newValue2 + ",";
    else
      newValue2 = newValue2 + aChar;
  }

  var newValue3 = newValue2;
  
    
  return newValue3;
}

function CheckData(sData) {

  var monthDays = "101010110101";
  var validDate = new String("");
  var aDay, aMonth, aYear;
  var aN, aMonthFlg;

  validDate = sData;
  aFilName  = "Erro";
  
  if( validDate.length != 10 ) {
    alert(aFilName + " - Data deve estar no formato dd/mm/yyyy.");
	return false;
  }

  aDay = validDate.substring(0, 2);
  aMonth = validDate.substring(3, 5);
  aYear = validDate.substring(6, 10);
  
  aAnoBi = aYear % 4;

  if( isNaN(parseInt(aDay)) || isNaN(parseInt(aMonth)) || isNaN(parseInt(aYear)) ) {
    alert(aFilName + " - Dia, Mês e Ano devem ser numéricos.");
	return false;
	  }

  aN = aDay;
  if( (aN < 1) || (aN > 31) ) {
    alert(aFilName + " - Dia do Mês deve estar entre 1 e 31.");
	return false;
  }

  if( (aMonth < 1) || (aMonth > 12) ) {
    alert(aFilName + " - Mês deve estar entre 1 e 12.");
	return false;
  }

  var MaxFev
  MaxFev = aAnoBi ? 28 : 29;

  if( (aMonth == 2) && (aDay > MaxFev)) {
       alert(aFilName + " - Fevereiro possui até " + MaxFev + " dias.");
	   return false;
  }

  aMonthFlg = parseInt(monthDays.substring(aMonth-1, aMonth));

  if( (aMonthFlg == 0) && (aDay > 30) ) {
    alert(aFilName + " - Mês possui somente 30 dias.");
	return false;
  }
  return true;

}
function check_cpf_cgc(num){ 
   if (check_cpf(num) == false ) {
      if (check_cgc(num) == false ) {
         return false;
      }   
   }
   return true
}

function check_cpf (numcpf) {
    var len = numcpf.length;
    var x = 0;
    var soma = 0;
    var dig1 = 0;
    var dig2 = 0;
    var texto = "";
    var numcpf1 = "";
    var iContaIguais = 0;
    var sPrimeiroChar = "";

    x = len - 1;

    if (len != 11) return false;

    for (var i=0; i <= (len - 3); i++) {
      y = numcpf.substring(i, i+1);

      if (sPrimeiroChar == "") sPrimeiroChar = y;

      if (sPrimeiroChar == y) iContaIguais++;

      soma = soma + (y * x);

      x = x - 1;
    }

    if (iContaIguais == 9) return false;

    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;

    return false;
}

function EhIgual(campo) { // Verifica se todos os valores são iguais
	var i = 0
	var j = 1
	var igual = true;
	// Todos os caracteres devem ser diferentes
	while (i < campo.length-1 && igual == true) {
		while (j < campo.length && igual == true) {
			if (campo.charAt(i) != campo.charAt(j)) {
				igual = false;
			}
			else j++;
		}
		i++;
	}
	return igual;
}

function EhNumero(campo) { // Verifica se o valor é númerico e diferente de zero e não é tudo igual
	var i
	var digitos = "0123456789"
	var zero = "0"	

	// Todos os caracteres devem ser digitos
	for (i=0; i < campo.length; i++) {
		if (digitos.indexOf(campo.charAt(i)) < 0 ) {
			return false;	
		}
	}
	return true;
}

function check_cgc(cgc) 
{
	if (EhIgual(cgc)==true)
	   return false;

	dac1 = 0; dac2 = 0; dac = ""; dact = ""; sum = 0;
	dac = cgc.substring(cgc.length-2, cgc.length);
	cgc = cgc.substring(0,cgc.length-2);
	for (i=cgc.length-1, j=2; i >= 0 ; i--, j++)
		{	j = (j == 10) ? 2 : j; sum += (cgc.substring(i, i+1) * j); }
	dac1 = ((sum * 10) % 11); dac1 = (dac1 == 10) ? 0 : dac1; sum = 0;
	for (i=cgc.length-1, j=3; i >= 0 ; i--, j++)
		{	j = (j == 10) ? 2 : j; sum += (cgc.substring(i, i+1) * j); }
	sum  += (dac1 * 2); dac2 = ((sum * 10) % 11); 
	dac2 = (dac2 == 10) ? 0 : dac2; dact = dac1+""+dac2;

	if (dact == dac) 
	   return true;
	else 
	   return false;
}


function SoNumero(nValor) {

  var newValue  = nValor;
  var newLength = newValue.length;
  var newValue2 = "";
  var bNegativo = false;
  
  for (var i =0; i != newLength; i++) {
    aChar = newValue.substring (i, i+1);
    
    if( isNaN(aChar) == false){
       newValue2 = newValue2 + aChar;
    }   
  }

  var newValue = newValue2;
    
  return newValue;
}

function check_cpf (numcpf) 

{

    var len = numcpf.length;
    var x = 0;
    var soma = 0;
    var dig1 = 0;
    var dig2 = 0;
    var texto = "";
    var numcpf1 = "";
    var iContaIguais = 0;
    var sPrimeiroChar = "";

    x = len - 1;

    if (len != 11) return false;

    for (var i=0; i <= (len - 3); i++) {
      y = numcpf.substring(i, i+1);

      if (sPrimeiroChar == "") sPrimeiroChar = y;

      if (sPrimeiroChar == y) iContaIguais++;

      soma = soma + (y * x);

      x = x - 1;
    }

    if (iContaIguais == 9) return false;

    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;

    return false;
}

function EhIgual(campo) { // Verifica se todos os valores são iguais
	var i = 0
	var j = 1
	var igual = true;
	// Todos os caracteres devem ser diferentes
	while (i < campo.length-1 && igual == true) {
		while (j < campo.length && igual == true) {
			if (campo.charAt(i) != campo.charAt(j)) {
				igual = false;
			}
			else j++;
		}
		i++;
	}
	return igual;
}

function EhNumero(campo) { // Verifica se o valor é númerico e diferente de zero e não é tudo igual
	var i
	var digitos = "0123456789"
	var zero = "0"	

	// Todos os caracteres devem ser digitos
	for (i=0; i < campo.length; i++) {
		if (digitos.indexOf(campo.charAt(i)) < 0 ) {
			return false;	
		}
	}
	return true;
}

//Verifica a consistencia do CGC
function check_cgc(cgc) 
{
	if (EhIgual(cgc)==true) { return false; }
	dac1 = 0; dac2 = 0; dac = ""; dact = ""; sum = 0;
	dac = cgc.substring(cgc.length-2, cgc.length);
	cgc = cgc.substring(0,cgc.length-2);
	for (i=cgc.length-1, j=2; i >= 0 ; i--, j++)
		{	j = (j == 10) ? 2 : j; sum += (cgc.substring(i, i+1) * j); }
	dac1 = ((sum * 10) % 11); dac1 = (dac1 == 10) ? 0 : dac1; sum = 0;
	for (i=cgc.length-1, j=3; i >= 0 ; i--, j++)
		{	j = (j == 10) ? 2 : j; sum += (cgc.substring(i, i+1) * j); }
	sum  += (dac1 * 2); dac2 = ((sum * 10) % 11); 
	dac2 = (dac2 == 10) ? 0 : dac2; dact = dac1+""+dac2;
	if (dact == dac) return true;
		else { return false; }
}

	