var ns = (navigator.appName == "Netscape");
var ie = (navigator.appName == "Microsoft Internet Explorer") || (window.navigator.userAgent.indexOf("Chrome")>0);

//document.write('<sc'+'ript language="JavaScript" type="text/javascript" src="http://www.mirvan.com.br/sitemeter/sitemeter.php?id=dacar&origem='+location.href+'"></scr'+'ipt>\n');

function correctPNG() {
	// somente executa essa função se o navegador for Internet Explorer versão < 7.0
	var userAgent = navigator.userAgent.toLowerCase();
	var msie = userAgent.indexOf("msie");
	executa = false;
	if (msie > 0) {
		var msieversion = userAgent.substr(msie+5,3);
		if (msieversion<7) executa=true;
	}
	
if (executa) {
   for(var i=0; i<document.images.length; i++)
      {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgIDName = (img.name) ? "name='" + img.name + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "

		 verifica = img.style.cssText.toLowerCase();
		 verifica = verifica.indexOf("filter");
		 complemento='';
		 if (verifica>= 0) complemento = ";"+img.style.cssText.substr(7);
         var imgStyle = "display:inline-block;" // + img.style.cssText
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span "+ imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale'";
		 
		 strNewHTML = strNewHTML + ");\"></span>"
         img.outerHTML = strNewHTML
         i = i-1
         }
      }
   }
}
window.attachEvent("onload", correctPNG);

document.write('<link rel="stylesheet" href="/thickbox/thickbox.css" type="text/css" media="screen" />');
document.write('<scr'+'ipt type="text/javascript" src="/thickbox/jquery-latest.js"></scr'+'ipt>');
document.write('<scr'+'ipt type="text/javascript" src="/thickbox/thickbox.js"></scr'+'ipt>');



function abrejogos() {
  acentraljogos = window.open('http://www.acentralbs.com.br/jogos/jogos.php?origem=dacar','acentralbsjogos','top=50,left=50,width=750,height=700,toolbar=yes,location=no,directories=no,copyhistory=no,maximized=no,status=no,menubar=no,resizable=yes,scrollbars=yes') ;
  acentraljogos.focus();
}

function abresimulador() {
  simwin = window.open('http://www.dacar.ind.br/simulador/simulador.php?parametro=x','simulador','location=no, status=no, resizable=no, width=400, height=450') ;
  simwin.focus();
}

function abre_local_br_277() {
  simwin = window.open('http://www.dacar.ind.br/localizacao/via-br-277.html','localizacao','location=no, status=no, resizable=no, width=587, height=495') ;
  simwin.focus();
}

function abre_local_av_das_torres() {
  simwin = window.open('http://www.dacar.ind.br/localizacao/via-av-das-torres.html','localizacao','location=no, status=no, resizable=no, width=587, height=495') ;
  simwin.focus();
}

function geomapa() {
  largura = 600;
  altura  = screen.availHeight-200;
  larg_meio = ( (screen.availWidth/2) - (largura/2) );
  alt_meio  = ( (screen.availHeight/2) - (altura/2) );
  xtop  = 0;
  xleft = larg_meio;
  comando = 'top='+xtop+',left='+xleft+',height='+altura+',width='+largura+',toolbar=no,location=no,directories=no,copyhistory=no,maximized=no,status=no,menubar=no,resizable=yes,scrollbars=yes';
  janela = window.open('geomapa.php','geomapa',comando);
  janela.focus();

//  animawin = window.open('texturas.html','sabedoria','status=no,resizable=no,scrollbars=no,menubar=no,width=587,height=540') ;
//  animawin.focus();
}

// Centraliza layer
// Uso: na seção body -> onload="vhcenter(layer)" onresize="vhcenter(layer)"
function vhcenter(obj, largura, altura) {

  if (obj==null) return false;
  if (largura==null) largura=100;
  if (altura==null)  altura=100;

  if (ie) { 
    layerheight = obj.style.height;
    layerwidth  = obj.style.width;
  } else {
    layerheight = altura;
    layerwidth  = largura;
  }

  layerheight = parseInt(layerheight);
  layerheight = unescape(layerheight);
  layerwidth  = parseInt(layerwidth);
  layerwidth  = unescape(layerwidth);

  docmiddle    = (layerheight/2);
  if (ie) screenmiddle = (document.body.offsetHeight/2);
  else    screenmiddle = (innerHeight/2);
  screenmiddle = parseInt( screenmiddle );
  newoffset = (screenmiddle - docmiddle);
  newoffset -= 50;
  if (newoffset < 0) {
    newoffset = 0;
  }
  if (ie) obj.style.top = newoffset + "px";
  else obj.top = newoffset ;

  docmiddle = (layerwidth/2);
  if (ie) screenmiddle = (document.body.offsetWidth/2);
  else screenmiddle = (innerWidth/2);
  screenmiddle = parseInt( screenmiddle );
  newoffset = (screenmiddle - docmiddle);
  newoffset -= 10   // Centering correction
  if (newoffset < 0) {
    newoffset = 0;
  }
  if (ie) obj.style.left = newoffset + "px";
  else {
    obj.left = unescape(newoffset);
  }

}

function vhlt(obj) {

  if (obj==null) return false;
  if (ie) { 
    obj.style.top = document.body.scrollTop;
  } else { 
    obj.top = pageYOffset;
  }
}

function vhlb(obj, alt) {

  if (obj==null) return false;
  if (alt==null) alt=100;

  if (ie) layerheight = obj.style.height;
  else layerheight = alt;

  layerheight = parseInt(layerheight);
  layerheight = unescape(layerheight);
  if (ie) { 
    obj.style.top = ((document.body.scrollTop + document.body.clientHeight)-layerheight);
  } else { 
    obj.top = ((pageYOffset + innerHeight) - alt);
    obj.left = 0;
  }
}

function vhrb(obj, alt, larg) {

  if (obj ==null) return false;
  if (larg==null) larg=100;
  if (alt ==null) alt =100;

  if (ie) {
    layerheight = obj.style.height;
    layerwidth  = obj.style.width;
  } else {
    layerheight = alt;
    layerwidth  = larg;
  }

  layerheight = parseInt(layerheight);
  layerheight = unescape(layerheight);
  layerwidth  = parseInt(layerwidth);
  layerwidth  = unescape(layerwidth);

  // Altura
  if (ie) { 
    obj.style.top = ((document.body.scrollTop + document.body.clientHeight)-layerheight)-4;
  } else { 
    obj.top = ((pageYOffset+innerHeight) - larg);
  }

  // Largura
  if (ie) { 
    obj.style.left = ((document.body.scrollLeft + document.body.clientWidth)-layerwidth);
  } else { 
    obj.left = ((pageXOffset + innerWidth) - alt);
  }

}
 
// Coloca o layer à direita do plano
// Uso: na seção body -> onload="vhright(layer)" onresize="vhright(layer)"
function vhright(obj, larg) {

  if (obj ==null) return false;
  if (larg==null) larg=100;

  if (ie) {
    layerwidth  = obj.style.width;
  } else {
    layerwidth  = larg;
  }

  layerwidth  = parseInt(layerwidth);
  layerwidth  = unescape(layerwidth);

  // Largura
  if (ie) { 
    obj.style.left = ((document.body.scrollLeft + document.body.clientWidth)-layerwidth);
  } else { 
    obj.left = ((pageXOffset + innerWidth) - alt);
  }

}


// Coloca o layer centralizado e abaixo no plano
// Uso: na seção body -> onload="vhbottomcenter(layer)" onresize="vhbottomcenter(layer)"
function vhbottomcenter(obj) {

  if (obj==null) return false;

  layerheight = obj.style.height;
  layerheight = parseInt(layerheight);
  layerheight = unescape(layerheight);

  docmiddle    = (layerheight/2)
  screenmiddle = (document.body.offsetHeight/2)
  newoffset = (screenmiddle - docmiddle)
  newoffset -= 2
  if (newoffset < 0) {
    newoffset = 0
  }
  obj.style.top = newoffset + "px"


  layerwidth  = obj.style.width;
  layerwidth = parseInt(layerwidth);
  layerwidth = unescape(layerwidth);

  docmiddle    = (layerwidth/2)
  screenmiddle = (document.body.offsetWidth/2)
  newoffset = (screenmiddle - docmiddle)
  newoffset -= 10   // Centering correction
  if (newoffset < 0) {
    newoffset = 0
  }
  obj.style.left = newoffset + "px"

}


// Centraliza layer no topo do plano
// Uso: na seção body -> onload="vhcentertop(layer)" onresize="vhcentertop(layer)"
function vhcentertop(obj) {

  if (obj==null) return false;

//  layerheight = obj.style.height;
//  layerheight = parseInt(layerheight);
//  layerheight = unescape(layerheight);

  layerwidth  = obj.style.width;
  layerwidth = parseInt(layerwidth);
  layerwidth = unescape(layerwidth);

//  docmiddle    = (layerheight/2)
//  screenmiddle = (document.body.offsetHeight/2)
//  newoffset = (screenmiddle - docmiddle)
//  newoffset -= 2
//  if (newoffset < 0) {
//    newoffset = 0
//  }
  obj.style.top = "0px"
  docmiddle    = (layerwidth/2)
  screenmiddle = (document.body.offsetWidth/2)
  newoffset = (screenmiddle - docmiddle)
  newoffset -= 10   // Centering correction
  if (newoffset < 0) {
    newoffset = 0
  }
  obj.style.left = newoffset + "px"
}

// Coloca o dia e hora no rodapé
// Uso: na seção body -> onload="startclock()"

var timerID = null;
var timerRunning = false;
function startclock () {
   stopclock();
   time();
}

function stopclock () {
   if(timerRunning)
      clearTimeout(timerID);
   timerRunning = false;
}

function time () {
   var now = new Date();
   var yr = now.getYear();
   var mName = now.getMonth() + 1;
   var dName = now.getDay() + 1;
   var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
   var ampm = (now.getHours() >= 12) ? " pm" : " am"
   var hours = now.getHours();

   hours = ((hours > 12) ? hours - 12 : hours);

   var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
   var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();

   if(dName==1) Day = "domingo";
   if(dName==2) Day = "segunda-feira";
   if(dName==3) Day = "terça-feira";
   if(dName==4) Day = "quarta-feira";
   if(dName==5) Day = "quinta-feira";
   if(dName==6) Day = "sexta-feira";
   if(dName==7) Day = "sábado";

   if(mName==1) Month="janeiro";
   if(mName==2) Month="fevereiro";
   if(mName==3) Month="março";
   if(mName==4) Month="abril";
   if(mName==5) Month="maio";
   if(mName==6) Month="junho";
   if(mName==7) Month="julho";
   if(mName==8) Month="agosto";
   if(mName==9) Month="setembro";
   if(mName==10) Month="outubro";
   if(mName==11) Month="novembro";
   if(mName==12) Month="dezembro";

   var DayDateTime=(" Hoje é " 
       + Day
       + ", "
       + dayNr
       + " de "
       + Month
       + " de "
       + ""
       + yr
       + ". - "
       + hours
       + minutes
       + seconds
       + " "
       + ampm
        );

   window.status=DayDateTime;
   timerID = setTimeout("time()",1000);
   timerRunning = true;
}

function clearStatus() {
   if(timerRunning)
      clearTimeout(timerID);
   timerRunning = false;
   window.status=" ";   
}


function escrevedata() {
   var now = new Date();
   var yr = now.getYear();
   var mName = now.getMonth() + 1;
   var dName = now.getDay() + 1;
   var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
   var ampm = (now.getHours() >= 12) ? " pm" : " am"
   var hours = now.getHours();

   hours = ((hours > 12) ? hours - 12 : hours);

   var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
   var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();

   if(dName==1) Day = "Domingo";
   if(dName==2) Day = "Segunda-feira";
   if(dName==3) Day = "Terça-feira";
   if(dName==4) Day = "Quarta-feira";
   if(dName==5) Day = "Quinta-feira";
   if(dName==6) Day = "Sexta-feira";
   if(dName==7) Day = "Sábado";

   if(mName==1) Month="janeiro";
   if(mName==2) Month="fevereiro";
   if(mName==3) Month="março";
   if(mName==4) Month="abril";
   if(mName==5) Month="maio";
   if(mName==6) Month="junho";
   if(mName==7) Month="julho";
   if(mName==8) Month="agosto";
   if(mName==9) Month="setembro";
   if(mName==10) Month="outubro";
   if(mName==11) Month="novembro";
   if(mName==12) Month="dezembro";

   var DayDateTime=( Day
       + ", "
       + dayNr
       + " de "
       + Month
       + " de "
       + ""
       + yr
       + "." );
  document.writeln( DayDateTime );
  return true;
}

// Troca imagens
// Uso: swapImage('id_da_imagem','nova_imagem.gif')
function swapImage(imgName,newImg){
  if ((navigator.appName == 'Netscape' && parseFloat(navigator.appVersion) >= 3) || (parseFloat(navigator.appVersion) >= 4))
     { eval('document.' + imgName + '.src = "' + newImg + '"');
     }
}

// Executa pre-load em imagens
// Uso: preloadImages('imagem1.gif','imagem2.gif','imagem3.jpg.gif')">

function preloadImages() { 
  if (document.images) {
    var imgFiles = preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

// Verifica a validade de data (com ano bissexto)
// Uso: 
//   if (!dataok(document.forms[0].nascimento) ) {
//       return false;
//   }

function dataok(dataObj) {

  temp = new String(dataObj.value);

  dia = temp.substring(0,2);
  if ((dia>31) || (dia<1)) {
    alert("Dia inválido !");
    return false;
  }

  if (temp.indexOf("/") == -1) {
    var mes = temp.substring(2,4);
    var ano = temp.substring(4,8);
  } else {
    var mes = temp.substring(3,5);
    var ano = temp.substring(6,10);
  }

  if ((mes>12) || (mes<1)) {
    alert("Mês inválido !");
    return false;
  }

  if ( (mes==4) || (mes==6) || (mes==9) || (mes==11) ) {
    if (dia>30) {
      alert("Dia inválido para este mês !");
      return false;
    }
  }

  if (mes==2) {
    // extrai módulo
    ano = parseInt(ano);
    ano = unescape(ano);
    divinteiro = Math.floor(ano/4);
    divisao    = (ano/4);
    resto = (divisao-divinteiro);

    if (resto>0) { // Não é ano bissexto
      if (dia>28) {
        alert("Neste ano fevereiro tem 28 dias !");
        return false;
      } else {
        if (dia>29) {
          alert("Fevereiro não pode ter mais que 29 dias !");
          return false;
        }
      }
    }
  }
  return true;
}

function semacento(Source)
	{
	var CharOrig="ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÃÕÑÇáéíóúàèìòùâêîôûäëïöüãõñç";
	var CharAlte="abcdefghijklmnopqrstuvwxyzaeiouaerouaeiouaeiouaoncaeiouaeiouaeiouaeiouaonc";
	var I;		// CONTADOR DE USO GERAL
	var Car;	      // CADA CARACTERE DO TEXTO
	var Saida="";	// TEXTO DE SAIDA
	var Pos;	      // POSICAO DO ACENTO

	for(I=0;I<Source.length;I++)
		{//VERIFICA CADA LETRA
		Car=Source.charAt(I);
		if((Pos=CharOrig.indexOf(Car))!=-1)
		{//E um caracter a ser alterado
		Car=CharAlte.charAt(Pos);
		}
		Saida=Saida + Car;
		}
	return(Saida);
}

function boltecrodape() {
  document.write( "<hr>" );
  document.write( "<table width=400 align=center cellpading=0 cellspacing=3>" );
  document.write( "  <tr>" );
//  document.write( "    <td><p class=center><b>DACAR - Indústria e Comércio de Tintas Ltda.</b></p></td>" );
  document.write( "    <td><p class=center><b>DACAR Química do Brasil S/A.</b></p></td>" );
  document.write( "  </tr>" );
  document.write( "  <tr>" );
//  document.write( "    <td><p>C.G.C.:12.123.123/0001-12</p></td>" );
//  document.write( "    <td><p class=right>SAC-DACAR: (41) 999-9999</p></td>" );
  document.write( "    <td>" );
  document.write( "      <p class=center>C.G.C.: 78.949.013/0001-07</p>" );
  document.write( "      <p class=center>Fone: 55 (41) 3382-3332&nbsp;-&nbsp;Fax: 55 (41) 3382-4568</p>" );
  document.write( "      <p class=center><a href='http://www.dacar.ind.br' target='_top'>http://www.dacar.ind.br</a> - e-mail: <a href='mailto:dacar@dacar.ind.br'>dacar@dacar.ind.br</a></p>" );
  document.write( "    </td>" );
  document.write( "  </tr>" );
  document.write( "</table>" );
//  top.controle.focus();
//window.top.frames.controle.document.body.focus() 
// window.document.body.focus() 
  window.print();
  return true;
}


function bolteccabecalho() {
  document.write( "<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
  document.write( "  <tr>" );
  document.write( "    <td width='110'>&nbsp;</td>");
//  document.write( "<table width=400 align=center cellpading=0 cellspacing=3 border=1>" );
  document.write( "    <td><p class=center><img src='http://www.dacar.ind.br/produtos/logo-dacar-ultimo.gif'></p></td>" );
  document.write( "  </tr>" );
  document.write( "  <tr>" );
  document.write( "    <td width='110'>&nbsp;</td>");
  document.write( "    <td><p class=center><img src='http://www.dacar.ind.br/produtos/logo-boletim-tecnico.gif'></p></td>" );
  document.write( "  </tr>" );
  document.write( "  <tr>" );
  document.write( "    <td width='110'>&nbsp;</td>");
  document.write( "    <td><hr></td>" );
  document.write( "  </tr>" );
  document.write( "</table>" );
  return true;
}

function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num)) num = "0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents<10) cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + 'R$ ' + num + '.' + cents);
}

// Bloqueia a visualização do código fonte
function right(e) {
 var msg = "   Fabio Fittipaldi studio\n";
     msg+= "   Rua Carlos Cesarini, 56\n";
     msg+= " Curitiba - Paraná - Brasil\n\n";
     msg+= "(41) 3015-4889 - 9906-0056\n";
//     msg+= "        www.acentralbs.com.br\n";
     msg+= "   fhfittipaldi@gmail.com";
//     msg+= "  Design                  : André L. Fittipaldi\n";
//     msg+= "  Desenvolvimento : Fabio H. Fittipaldi";

 if ( (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) ||
      (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) ) {
   alert(msg);
   return false;
 }
 return true;
}
//document.onmousedown=right;
//if (document.layers) window.captureEvents(Event.MOUSEDOWN);
//window.onmousedown=right;


function limpastring( _var ) {
  _varAux=new String(_var);
  // para limpeza de caracteres
  var limpar = " +-*/qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM!@#$%^&*()_=[]{};:?,<>~`|" + '".';
//  var limpar = " +-*/.";
  var tamanho = (limpar.length );
  // limpa qualquer ocorrência
  for (vezes=1;vezes<=_varAux.length;++vezes) {
    for (conta=0; conta<=tamanho; ++conta ) { _varAux=_varAux.replace((limpar.substr(conta,1)),""); }
  }

}

// Testa uma string para saber se é CPF ou CGC
function CPFouCNPJ( valor ) {
  _valor = limpastring( valor );
  if ( _valor.length <= 11 ) {
     retorno = CPFOK( _valor );
  } else {
     retorno = CNPJOK( _valor );
  }
  return retorno;
}

// Extrai o módulo de uma string
function modulo(str) {
  soma=0;
  ind=2;
  for(pos=str.length-1;pos>-1;pos=pos-1) {
    soma = soma + (parseInt(str.charAt(pos)) * ind);
    ind++;
    if(str.length>11) {
      if(ind>9) ind=2;
    }
  }
  resto = soma - (Math.floor(soma / 11) * 11);
  if(resto < 2) {
    return 0;
  } else {
    return 11 - resto;
  }
}
    	

function CPFOK(cpf) {
// Verifica se o campo é nulo
if (cpf == '') {
//  alert('Este campo é de preenchimento obrigatório!');
  return false;
}

  cpfAux=new String(cpf);
  // para limpeza de caracteres
//  var limpar = " +-*/qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM!@#$%^&*()_=[]{};:?,<>~`|" + '".';
  var limpar = " +-*/.";
  var tamanho = (limpar.length );
  // limpa qualquer ocorrência
  for (vezes=1;vezes<=cpf.length;++vezes) {
    for (conta=0; conta<=tamanho; ++conta ) { cpf=cpf.replace((limpar.substr(conta,1)),""); }
  }

// Aqui começa a checagem do CPF
var POSICAO, I, SOMA, DV, DV_INFORMADO;
var DIGITO = new Array(10);
DV_INFORMADO = cpf.substr(9, 2); // Retira os dois últimos dígitos do número informado

// Desemembra o número do CPF na array DIGITO
for (I=0; I<=8; I++) {
  DIGITO[I] = cpf.substr( I, 1);
}

// Calcula o valor do 10º dígito da verificação
POSICAO = 10;
SOMA = 0;
for (I=0; I<=8; I++) {
  SOMA = SOMA + DIGITO[I] * POSICAO;
  POSICAO = POSICAO - 1;
}
DIGITO[9] = SOMA % 11;
if (DIGITO[9] < 2) {
  DIGITO[9] = 0;
} else {
  DIGITO[9] = 11 - DIGITO[9];
}

// Calcula o valor do 11º dígito da verificação
POSICAO = 11;
SOMA = 0;
for (I=0; I<=9; I++) {
  SOMA = SOMA + DIGITO[I] * POSICAO;
  POSICAO = POSICAO - 1;
}
DIGITO[10] = SOMA % 11;
if (DIGITO[10] < 2) {
  DIGITO[10] = 0;
} else {
  DIGITO[10] = 11 - DIGITO[10];
}

// Verifica se os valores dos dígitos verificadores conferem
DV = DIGITO[9] * 10 + DIGITO[10];
if (DV != DV_INFORMADO) {
//  alert('CPF inválido');
//  formulario.CPF.value = '';
//  formulario.CPF.focus();
   return false;
  } 
  return true;
}


// Verifica a validade de CGC
function CNPJOK( valor ) {
  if (valor.length < 14) {
    return false;
  }

  cgcAux=new String(valor);

  pos=cgcAux.indexOf(" ");
  while (pos>0) {
    valor=cgcAux.replace(" ",'');
    cgcAux=valor;
    pos=cgcAux.indexOf(" ");
  }

  pos=cgcAux.indexOf(".");
  while (pos>0) {
    valor=cgcAux.replace(".",'');
    cgcAux=valor;
    pos=cgcAux.indexOf(".");
  }
	
  pos=cgcAux.indexOf("/");
  while (pos>0) {
    valor=cgcAux.replace("/",'');
    cgcAux=valor;
    pos=cgcAux.indexOf("/");
  }

  pos=cgcAux.indexOf("-");
  while (pos>0) {
    valor=cgcAux.replace("-",'');
    cgcAux=valor;
    pos=cgcAux.indexOf("-");
  }

  primeiro=valor.substr(1,1);
  falso=true;
  size=valor.length;
  size--;
  for (i=2; i<size-1; ++i) {
    proximo=(valor.substr(i,1));
    if (primeiro!=proximo) {
      falso=false;
    }
  }

  if (falso) {
    return false;
  }
		
  if( modulo( valor.substring( 0, valor.length - 2 ) ) + "" + modulo( valor.substring( 0, valor.length - 1) ) != valor.substring( valor.length - 2, valor.length ) ) {
    return false;
  }
  return true;
}

function direitos() {
  endereco = location.hostname;  // vai informar www.endereco.com.br
  if ( endereco != "" ) endereco = "http://" + endereco + "/";

//  document.write( "<hr size=1>" );
//  document.write( "<table align=center cellpading=0 cellspacing=3>" );
//  document.write("<tr><td><p class='center'><font face='verdana,arial,helvetica' size='-2' color='Gray'><a href='" + endereco + "' onmouseover='javascript:window.status=" + '"Visite nosso site"' + "; return true' onmouseout ='javascript:window.status=" + '""' + "; return true'><b>DACAR</b> Química do Brasil S/A - Todos os direitos reservados</a></font></p></td></tr>" );
//  document.write( "<tr><td><p class='center'><font face='verdana,arial,helvetica' size='-2' color='Gray'><a href='mailto:dacar@dacar.ind.br'  onmouseover='javascript:window.status=" + '"Converse conosco"' + "; return true'  onmouseout ='javascript:window.status=" + '""' + "; return true'>Converse conosco.</a></font></p></td></tr>" );
//  document.write( "</table>" );
//  document.write('<sc'+'ript language="JavaScript" type="text/javascript" src="http://www.acentralbs.com.br/sitemeter/sitemeter.php?id=dacar&origem='+location.href+'"></scr'+'ipt>\n');

document.write('<scr'+'ipt type="text/javascript">');
document.write('var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");');
document.write('document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));');
document.write('</scr'+'ipt>');
document.write('<scr'+'ipt type="text/javascript">');
document.write('try {');
document.write('var pageTracker = _gat._getTracker("UA-5916341-3");');
document.write('pageTracker._trackPageview();');
document.write('} catch(err) {}</scr'+'ipt>');

}

// funções para fade de imagens
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if(!document.all)
return
if (object != "[object]"){
setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
return;
}
clearTimeout(nereidFadeTimers[object.sourceIndex]);
diff = destOp-object.filters.alpha.opacity;
direction = 1;
if (object.filters.alpha.opacity > destOp){
direction = -1;
}
delta=Math.min(direction*diff,delta);
object.filters.alpha.opacity+=direction*delta;
if (object.filters.alpha.opacity != destOp){
nereidFadeObjects[object.sourceIndex]=object;
nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
}
}
if(document.images) {
var offimg = new Array()
offimg["cool"] = new Image(120,50)
offimg["cool"].src = "[INSERT]"
function imageOn(imgName) {
if (document.images) {
document.images[imgName].src = onimg[imgName].src
}
}
function imageOff(imgName) {
if (document.images) {
document.images[imgName].src = offimg[imgName].src
}
}
function setMsg(msg) {
window.status = msg
return true
}
function playIt() {
}
}

