<!--
function mostraData()
{
  var now     = new Date();

  var day     = now.getDate();
  var week    = now.getDay() + 1;
  var month   = now.getMonth() + 1;
  var year    = now.getFullYear();

  var hours   = now.getHours();
  var minutes = now.getMinutes();

  if (hours < 10)
    hours  = "0" + hours;
  if (minutes < 10)
    minutes = "0" + minutes;

  if (week == 1)
    week = "Domingo"
  else if (week == 2)
    week = "Segunda-feira"
  else if (week == 3)
    week = "Terça-feira"
  else if (week == 4)
    week = "Quarta-feira"
  else if (week == 5)
    week = "Quinta-feira"
  else if (week == 6)
    week = "Sexta-feira"
  else
    week = "S&aacute;bado";

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

  document.write(week + ", " + day + " de " + month + " de " + year);
}

function Foco(valorObjetoCondicao, Condicoes, objetosFoco, SemFoco)
{
  var elementoCritico = document.getElementById("CampoCritico1");
  if (elementoCritico)
  {
    if (document.all) // Internet Explorer 4 ou superior.
      elementoCritico.click();
    else // Netscape.
      eval(elementoCritico.href);
  }
  else if (!SemFoco)
  {
    for (i = 0; i < Condicoes.length; i++)
    {
      if (valorObjetoCondicao == Condicoes[i])
      {
        objetosFoco[i].focus();
        break;
      }
      else if ((i == Condicoes.length - 1) && (typeof(objetosFoco[i+1]) != "undefined"))
      {
        objetosFoco[i+1].focus();
        break;
      }
    }
  }
}

function formataData(e, objetoTexto)
{
  if (document.all) // Internet Explorer 4 ou superior.
    var tecla = event.keyCode;
  else // Nestcape.
    var tecla = e.which;
  if (tecla > 47 && tecla < 58) // Números de 0 a 9.
  {
    // 10 é o número máximo de caracteres de uma data no formato "dd/mm/aaaa".
    if (objetoTexto.value.length < 10)
    {
      var dataFormatada = "";
      for (strIndice = 0; strIndice < objetoTexto.value.length; strIndice++)
      {
        if (((dataFormatada.length == 2) && (objetoTexto.value.charAt(2) != "/"))
        ||  ((dataFormatada.length == 5) && (objetoTexto.value.charAt(5) != "/")))
          dataFormatada = dataFormatada + "/";
        dataFormatada = dataFormatada + objetoTexto.value.charAt(strIndice);
      }
      objetoTexto.value = dataFormatada;
    }
  }
  else
  {
    // backspace
    if ((tecla != 8) && (tecla != 13))
    {
      if (document.all) // Internet Explorer 4 ou superior.
        event.keyCode = 0;
      else // Nestcape.
        e.which = 0;
    }
  }
}

function Submit(Opt, Optcn1, Optcn2)
{
  document.form.Opcao.value = Opt;
  if (Optcn1 != '') document.form.Opcional1.value = Optcn1;
  if (Optcn2 != '') document.form.Opcional2.value = Optcn2;
  document.form.submit();
}


function Popup(endereco,largura,altura)
{
 posx = ((screen.width - largura) / 2);
 posy = ((screen.height - altura) / 2);
 // string de parametros para montagem da janela
 features="dependent=no, toolbar=no, status=no, menubar=no, scrollbars=yes, resizable=no, " +
 "width=" + largura + ", height=" + altura + ", top=" + posy + ", left=" + posx;
 window.open(endereco, "Popup", features);
}

function popImagem(titulo,figura,comp,larg,fundo) {
// centraliza('path/logotipo','path/figura''texto')
// logotipo = logotipo a ser exibido na primeira linha da tabela
// figura = Imagem a ser exibida
// posiciona a nova janela centralizada na tela
posx = (screen.width/2)-((larg + 5)/2);
posy = (screen.height/2)-((comp + 93)/2);
// string de parametros para montagem da janela
features="menubar=yes,scrollbars=no,width=" + (larg+10) + ",height=" + (comp+14) + ",top=" + posy + ",left=" + posx;
newin = window.open("","janela",features);
//newin.blur();
// início da geração do conteúdo html
var arquivo = ""+
"<html>" +
"<head>" +
"<title> :::" + titulo + "::: - " + figura + "</title>" +
"</head>" +
"<body bgcolor='" + fundo + "' leftmargin='0' topmargin='0'>" +
"<table>" +
"<tr valign='top'>" +
"<td>" +
"<img border='0' src='" + figura + "' width='" + larg + "'>" +
"</td>" +
"</tr>" +
"</table>" +
"</body>" +
"</html>"
// fim da geração do conteúdo html
//newin.document.open();
// imprime conteúdo gerado
newin.document.write(arquivo);
newin.document.close();
newin.focus();
}

function AreaTexto(ObjetoTexto, TamanhoMaximo, proximo, Evento)
{
  if (ObjetoTexto.value.length > TamanhoMaximo) {
      ObjetoTexto.value = ObjetoTexto.value.substr(0, (TamanhoMaximo-1));
      document.forms[0].elements[proximo].focus();
  }
}

function SomenteNumero(caracter) {
	if(document.all) { // Internet Explorer
		var tecla = event.keyCode;
	} else {
		if(document.getElementById) { // Nestcape
			var tecla = caracter.which;
		}
	}
       if (tecla == 0 || tecla == 8 || tecla == 13 || tecla == 46) { // esc backspace enter
		return true;
	} else {
               if(tecla < 48 || tecla > 57) { // numeros de 0 a 9
			return false;
		}}
}

function FormataCPF(Campo, teclapres) 
{
	
  if(document.all) { // Internet Explorer
  	var tecla = event.keyCode;
  } else {
  	if(document.getElementById) { // Nestcape
  		var tecla = teclapres.which;
  	}
  }

  var vr = new String(Campo.value);
  tam = vr.length;
  
  if (tecla != 9 && tecla != 8) {
     if(tecla > 47 || tecla < 58) { // numeros de 0 a 9
         if (tam == 3)  Campo.value = vr.substr(0, 3)  + ".";
         if (tam == 7)  Campo.value = vr.substr(0, 7)  + ".";
         if (tam == 11) Campo.value = vr.substr(0, 11) + "-";
  	}
  }
  if( tam == 14 ) verificaCPF_CNPJ(vr);

}

function FormataCNPJ(Campo, teclapres)
{

  if(document.all) { // Internet Explorer
  	var tecla = event.keyCode;
  } else {
  	if(document.getElementById) { // Nestcape
  		var tecla = teclapres.which;
  	}
  }

  var vr = new String(Campo.value);
  tam = vr.length;

  if (tecla != 9 && tecla != 8) {
     if(tecla > 47 || tecla < 58) { // numeros de 0 a 9
  	if (tam == 2)  Campo.value = vr.substr(0, 2)  + ".";
  	if (tam == 6)  Campo.value = vr.substr(0, 6)  + ".";
  	if (tam == 10) Campo.value = vr.substr(0, 10) + "/";
  	if (tam == 15) Campo.value = vr.substr(0, 17) + "-";
  	}
  }
  if( tam == 18 ) verificaCPF_CNPJ(vr);

}

function verificaCPF_CNPJ(recebe)
{
var valor, numeros, i, resultado, peso;

recebe = recebe.replace(/[.]+/g, '');
recebe = recebe.replace("/", "");
valor = recebe.replace("-", "");
  if (valor.length == 11) {
      resultado = 0;
      numeros = [];
      peso = [11,10,9,8,7,6,5,4,3,2];
      for (i=0; i<11; i++){
      numeros[i] = valor.charAt(i);
      }
      for (i=0; i<9; i++){
      resultado += numeros[i] * peso[i+1];
      }
      if ((x = resultado % 11) < 2) { dv1 = 0 } else { dv1 = 11-x }
      resultado = 0;
      for (i=0; i<10; i++) {
      resultado += (numeros[i] * peso[i]);
      }
      if ((x = resultado % 11) < 2) { dv2 = 0; } else { dv2 = 11-x; }
      if ((numeros[9] != dv1) || (numeros[10] != dv2)){
      alert('CPF:' + valor + ' inválido!');
      return false;
                }
      return true;
      }
   resultado = 0;
   numeros = [];
   peso = [6,5,4,3,2,9,8,7,6,5,4,3,2];
   for (i=0; i<14; i++){
   numeros[i] = valor.charAt(i);
   }
   for (i=0; i<12; i++){
   resultado += numeros[i] * peso[i+1];
   }
   if ((x = resultado % 11) < 2) { dv1 = 0 } else { dv1 = 11-x }
   resultado = 0;
   for (i=0; i<13; i++) {
   resultado += (numeros[i] * peso[i]);
   }
   if ((x = resultado % 11) < 2) { dv2 = 0; } else { dv2 = 11-x; }
   if ((numeros[12] != dv1) || (numeros[13] != dv2)){
   alert('CNPJ:' + valor + ' inválido!');
   return false;
   }
   return true;
}

//-->