function FormataFaleConosco(valor) {
	if (valor == "CAD") {
		document.getElementById('FormOutros').style.display = 'none';
		document.getElementById('FormCadastro').style.display = '';
	} else {
		document.getElementById('FormOutros').style.display = '';
		document.getElementById('FormCadastro').style.display = 'none';
	};
}

function ExibeFlash(w,h,wmode,movie) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="wmode" value="'+wmode+'"/>');
	document.write('<param name="quality" value="high"/>');
	document.write('<param name="movie" value="'+movie+'"/>');
	document.write('<embed src="'+movie+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="'+wmode+'" width="'+w+'" height="'+h+'"></embed>');
	document.write('</object>');
}

var voto = "nulo";

function EnqueteVoto(opcao){
	voto = opcao;
}

function ParcialEnquete(cod){
	top.location.href='../enquete/resultado.asp?cod=' + cod;
}

function VotarEnquete(cod){
 if (voto == "nulo" ){ alert("Selecione uma opção antes de votar!"); } else { top.location.href='../enquete/votar.asp?enquetecod=' + cod + '&opcao=' + voto};
}

function ParcialEnquetePP(cod){
	top.location.href='enquete/resultado.asp?cod=' + cod;
}

function VotarEnquetePP(cod){
 if (voto == "nulo" ){ alert("Selecione uma opção antes de votar!"); } else { top.location.href='enquete/votar.asp?enquetecod=' + cod + '&opcao=' + voto};
}

function formularioDepartamento() {
	document.getElementById('homologacoes').style.display = (document.getElementById('departamento').value == "1") ? "" : "none";
	document.getElementById('odontologia').style.display = (document.getElementById('departamento').value == "2") ? "" : "none";
	document.getElementById('assessoria').style.display = (document.getElementById('departamento').value == "3") ? "" : "none";
	document.getElementById('advocacia').style.display = (document.getElementById('departamento').value == "4") ? "" : "none";
}

function Esconde (id) {
	document.getElementById(id).style.display = (document.getElementById(id).style.display == "none") ? "" : "none";
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function mudacor(prmThis,prmName)	{
	if ((window.document.all) || (window.document.getElementById))
		prmThis.className = prmName;
	else if (window.document.layers)
		prmThis.className = prmName;
}

// FUNÇÃO DE ABERTURA DE POPUP CENTRALIZADO
// ----------------------------------------------------------------------------
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
	var nversao = navigator.appVersion;
	var nresult = nversao.search(/\bMSIE 7.0\b/g);
	if (nresult > 0) {
		h = parseInt(h) + 30;
	}
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',noresizable,status=yes'
	win = window.open(mypage,myname,settings)
}
// ----------------------------------------------------------------------------

// FUNÇÃO QUE REDIMENSIONA JANELA POPUP
// ----------------------------------------------------------------------------
function Redimensiona(w, h) {
	//Corrige o tamanho da janela
	if (navigator.appName == "Microsoft Internet Explorer") {
		w = parseInt(w) + 10;
		h = parseInt(h) + 71;
	} else {
		w = parseInt(w) + 6;
		h = parseInt(h) + 49;
	};
	// IE 7
	var nversao = navigator.appVersion;
	var nresult = nversao.search(/\bMSIE 7.0\b/g);
	if (nresult > 0) {
		h = parseInt(h) + 30;
	};
	//
	window.resizeTo(w, h);
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	window.moveTo(LeftPosition,TopPosition);
	window.focus();
}
// ----------------------------------------------------------------------------

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

// Recupera informações de um cookie
function getCookieVal(inicio) {
	var fim = document.cookie.indexOf(";", inicio);
	if (fim == -1) fim = document.cookie.length;
	return unescape(document.cookie.substring(inicio, fim));
}

function getCookie(label) {
	var arg = label + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i,j) == arg) return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function setCookie(label, valor, expires) {
	document.cookie = label + "=" + escape(valor) + 
		((expires) ? "; expires=" + expires.toGMTString() : "");
}

function delCookie(label) {
	if (getCookie(label)) {
		document.cookie = label + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

/* 
	Mascara para Campos.
	"#" - Numeros
	"A" - Letras UpperCase
	"a" - Letras LowerCase
	"Z" - Letras
	"*" - Qualquer Caracter
	"/", ".", "-", " ", ":" - Caracteres Fixos
*/
function Mascara(objeto, evt, mask) {
		
	var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
	var Letras 	= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	var Numeros = '0123456789';
	var Fixos 	= '().-:/ '; 
	var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";
	
	evt = (evt) ? evt : (window.event) ? window.event : "";
	var value = objeto.value;
	if (evt) {
		var ntecla = (evt.which) ? evt.which : evt.keyCode;
		tecla = Charset.substr(ntecla - 32, 1);
		if (ntecla < 32) return true;

		var tamanho = value.length;
		if (tamanho >= mask.length) return false;

		var pos = mask.substr(tamanho,1); 
		while (Fixos.indexOf(pos) != -1) {
			value += pos;
			tamanho = value.length;
			if (tamanho >= mask.length) return false;
			pos = mask.substr(tamanho,1);
		}

		switch (pos) {
				case '#' : if (Numeros.indexOf(tecla) == -1) return false; break;
				case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break;
				case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break;
				case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break;
				case '*' : objeto.value = value; return true; break;
				default : return false; break;
		}
	}
	objeto.value = value; 
	return true;
}

// Deixa a string apenas com os numeros, eliminando o restante.
function trimToDigits(string) {
	s = "";
	var Numeros = /\d/;
	for (i = 0; i <= string.length; i++) 
		if (Numeros.test(string.substr(i,1))) s += string.substr(i,1);
	return s;	
}

function VEmail( strEmail ) {
     var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
     return (filter.test(strEmail));
}

function VAno(ano) {
	ano = trimToDigits(ano);
	return ((parseInt(ano) < 1900) || (ano.length != 4) || (parseInt(ano) > 2050)) ? false : true; 
}

function VMes(mes) {
	mes = trimToDigits(mes);
	return ((mes.length != 2) || (parseInt(mes) < 1) || (parseInt(mes) > 12)) ? false : true; 
}

function VMesAno(data) {
	data = trimToDigits(data);
	if (data.length < 6) return false;
	mes = data.substr(0,2);
	ano = data.substr(2,4);
	return (!VAno(ano) || !VMes(mes)) ? false : true;
}
//Verifica se a data é valida
function VData(data) {
	data = trimToDigits(data);
	if (data.length < 8) return false;
	dia = data.substr(0,2);
	mes = data.substr(2,2);
	ano = data.substr(4,4);
	
	if(ano >= 0 && ano < 1900) return false; 
	if(ano > 2100 || ano < 0 || mes > 12 || mes < 1) return false; 
	numero = ((parseInt(ano) - 1884) / 4) 
	dias = (numero == Math.floor(numero)) ? "312931303130313130313031" : "312831303130313130313031"; 
	diamax = parseInt(dias.substring((mes - 1) * 2, ((mes - 1) * 2) + 2)); 
	if(dia < 1 || dia > diamax) return false; 	
	
	return true;
}


// Verifica a autenticidade do CPF
function VCPF(cpf) {
	cpf = trimToDigits(cpf);
	if (cpf.length < 11) return false;
	if (cpf == "00000000000" || cpf == "11111111111" || 
			cpf == "22222222222" || cpf == "33333333333" || 
			cpf == "44444444444" || cpf == "55555555555" || 
			cpf == "66666666666" || cpf == "77777777777" || 
			cpf == "88888888888" || cpf == "99999999999") return false;

	var a = [];
	var b = new Number;
	var c = 11;
	for (i = 0; i < 11; i++) {
		a[i] = cpf.charAt(i);
		b = (i < 9) ? b + (a[i] *  --c) : b;
	}
	
	a[9] = ((x = b % 11) < 2) ? 0 : 11 - x;

	b = 0;
	c = 11;
	for (y = 0; y < 10; y++) b += (a[y] *  c--); 
	a[10] = ((x = b % 11) < 2) ? 0 : 11 - x;

	return (cpf.charAt(9) == a[9]) && (cpf.charAt(10) == a[10]);
}	


function fRemoveEspacos( cString, cPosString )
			{
			var nCount		= 0  ;
			var cRetorno	= "" ;
		
				//
				// se for para remover espaços 
				// a direita.
				//
				if ( cPosString.toUpperCase() == "D" )
					{
						//
						// faça até o final da string.
						//
						for ( nCount = (cString.length - 1); (nCount >= 0); nCount-- )
							{								
								//
								// se for um caracter diferente de branco.
								//
								if ( ( cString.substring( nCount, nCount + 1 ) != " " ) )
									{
										cRetorno = cString.substring( 0, nCount + 1 );
										nCount = 0;
									}
							}
					return cRetorno
					}
				
				//
				// se for para remover espaços  
				// a esquerda.
				//
				if ( cPosString.toUpperCase() == "E" )
					{
						for ( nCount = 0; (nCount < (cString.length)); nCount++ )
 							{
 								//
								// se for um caracter diferente de branco.
								//
								if ( ( cString.substring( nCount, nCount + 1 ) != " " ) )
									{
										cRetorno = cString.substring( nCount, cString.length );
										nCount = cString.length;
									}							
							}
					return cRetorno
					}
		
				//
				// se for para remover de ambos.
				//	
				if ( cPosString.toUpperCase() == "A" )
					{
					cRetorno = fRemoveEspacos( cString,  "D" )
					cRetorno = fRemoveEspacos( cRetorno, "E" )
					return cRetorno
					}								
}

// FUNÇÃO PARA VERIFICAR CNPJ ---------------------------------------------------
function VCNPJ( cCodigo ){
parte1 = cCodigo.substring(0,2)
parte1a = cCodigo.substring(0,1)
parte1b = cCodigo.substring(1,2)
parte2 = cCodigo.substring(3,6)
parte3 = cCodigo.substring(7,10)
parte4 = cCodigo.substring(11,15)
parte5 = cCodigo.substring(16,18)

//if (parte1a == 0) {
	cCodigo = parte1+parte2+parte3+parte4+parte5;
//}else {
//	cCodigo = parte1b+parte2+parte3+parte4+parte5;
//}



var cChavecdv  = "";
var cCampo     = "";
var cPeso      = "543298765432";
var nPdc       = 13;
var nLooping   = 1;
var nTotdc     = 0;
var nCd        = 1;
var sdc        = 0;
var nResto     = 0;
var lFalha     = false;





   if ( cCodigo != "" || cCodigo != 0 ) {
      
      cChavecdv = cCodigo;
      cCampo    = cChavecdv.substring( 12, 15 );
      
      while ( nLooping < 3 ) {
         
         nTotdc = 0;
         
         for( nCd = 0; nCd < 14; nCd++ ) {
            
            sdc = cChavecdv.substring( nCd, nCd + 1 ) * cPeso.substring( nCd, nCd + 1 );
            nTotdc += sdc;
         }
         
         nResto = nTotdc % 11;
         
         if ( nResto < 2 ) {
            
            cChavecdv = cChavecdv.substring( 0 , nPdc - 1 ) + "0" + cChavecdv.substr( nPdc + 1, 1 );
         }                
         else {
         
            nResto = 11 - nResto;
            cChavecdv = cChavecdv.substring( 0, nPdc - 1 ) + parseInt( nResto , 10 ) + cChavecdv.substring( nPdc + 1 , 1 );
         }
         
         cPeso = "6" + cPeso;
         nPdc ++;
         nLooping ++;
      }
      
      if ( cCampo != cChavecdv.substring( 12, 14 ) ) {
           
         lFalha = true;
      }
   }
   else {
   
      lFalha = true;
   }

   return ( !lFalha );
}


function MaskAno(objeto, evt) { 
	return Mascara(objeto, evt, '####');
}

function MaskMesAno(objeto, evt) { 
	return Mascara(objeto, evt, '##/####');
}

function MaskCEP(objeto, evt) { 
	return Mascara(objeto, evt, '##.###-###');
}

function MaskTelefone(objeto, evt) { 
	return Mascara(objeto, evt, '(##) ####-####');
}

function MaskCPF(objeto, evt) { 
	return Mascara(objeto, evt, '###.###.###-##');
}

function MaskCNPJ(objeto, evt) { 
	return Mascara(objeto, evt, '##.###.###/####-##');
}

function MaskData(objeto, evt) { 
	return Mascara(objeto, evt, '##/##/####');
}

function MaskHora(objeto, evt) { 
	return Mascara(objeto, evt, '##:##');
}

function MaskHora2(objeto, evt) { 
	return Mascara(objeto, evt, '##:##:##');
}

var tipo = 0;

function FaleConosco() {
	tipo = 1;
	document.form1.action = "mail.asp";
	document.form1.method = "post";
}

function Newsletter() {
	tipo = 2;
	document.form1.action = "newsletter-action.asp";
	document.form1.method = "post";
}

function Busca() {
	tipo = 3;
	document.form1.action = "";
	document.form1.method = "get";
}

function AcessoRestrito() {
	tipo = 4;
	document.form1.action = "../boletoonline/login.asp";
	document.form1.method = "post";
}

function AlterarSenha() {
	tipo = 5;
	document.form1.action = "../boletoonline/alterar-action.asp";
	document.form1.method = "post";
}

function AgendeVisita() {
	tipo = 6;
	document.form1.action = "mail.asp";
	document.form1.method = "post";
}

function BuscaPP() {
	tipo = 7;
	document.form1.action = "";
	document.form1.method = "get";
}

function Homologa() {
	tipo = 8;
	document.form1.action = "homologa_action.asp";
	document.form1.method = "post";
}

function EmiteGuia() {
	tipo = 9;
	document.form1.action = "";
	document.form1.method = "post";
}

function CadastroGuias() {
	tipo = 10;
	document.form1.action = "ficha-action.asp";
	document.form1.method = "post";
}

function Associese() {
	tipo = 11;
	document.form1.action = "mail.asp";
	document.form1.method = "post";
}

function EnviarNoticia() {
	tipo = 12;
	document.form1.action = "mail.asp";
	document.form1.method = "post";
}

function AgendeHomologa() {
	tipo = 13;
	document.form1.action = "homologa.asp";
	document.form1.method = "post";
}

function VAgendeHomologa() {
	if (document.form1.tipo.value == "-") { alert("Por favor, selecione se deseja um agendamento ou cancelamento."); document.form1.tipo.focus(); return false; };
	if (!VCNPJ(document.form1.homologacoescnpj.value)) { alert("Por favor, informe um CNPJ válido.");	document.form1.homologacoescnpj.focus(); return false; };
	return true;
}

function VAgendeVisita() {
	switch(document.getElementById('departamento').value) {
		case '1': 
			if (document.form1.cnpjcei[1].checked) {
				if (!(document.form1.homologacoescei.value)) { alert("Por favor, informe o CEI.");	document.form1.homologacoescei.focus(); return false; } else { document.form1.action = 'homologa.asp'; }; 	
			} else {
				if (!VCNPJ(document.form1.homologacoescnpj.value)) { alert("Por favor, informe um CNPJ válido.");	document.form1.homologacoescnpj.focus(); return false; } else { document.form1.action = 'homologa.asp'; }; 	
			};
			break;
		case '2':	
			if (document.form1.cnpjcei[1].checked) {
				if (!(document.form1.homologacoescei.value)) { alert("Por favor, informe o CEI.");	document.form1.homologacoescei.focus(); return false; } else { document.form1.action = 'homologa.asp'; }; 	
			} else {
				if (!VCNPJ(document.form1.homologacoescnpj.value)) { alert("Por favor, informe um CNPJ válido.");	document.form1.homologacoescnpj.focus(); return false; } else { document.form1.action = 'homologa.asp'; }; 	
			};
			break;
		default: return false; break;
	}
  return true;
}

function VNewsletter() {
	if (!document.form1.newsnome.value) { alert("Por favor, informe seu nome."); document.form1.newsnome.focus(); return false; };
  if (!VEmail(document.form1.newsemail.value)) { alert("O seu e-mail não é válido!\nVerifique-o novamente."); document.form1.newsemail.focus(); return false; };
  return true;
}

function VBusca() {
	if (!(document.form1.busca.value.length > 1)) { alert("Informe um número maior de caracteres para busca."); document.form1.busca.focus(); return false; };
	return true;
}

function VAcessoRestrito() {
  if (!document.form1.login.value) { alert("Por favor, informe seu Login."); document.form1.login.focus(); return false; };
  if (!document.form1.senha.value) { alert("Por favor, informe a Senha."); document.form1.senha.focus(); return false; };
  return true;
}

function VAlterarSenha() {
  if (!document.form1.asenha.value) { alert("Por favor, informe a Senha atual."); document.form1.asenha.focus(); return false; };
  if (!document.form1.nsenha.value) { alert("Por favor, informe a nova Senha."); document.form1.nsenha.focus(); return false; };
  if (!document.form1.csenha.value) { alert("Por favor, confirme a sua nova Senha."); document.form1.csenha.focus(); return false; };
  if (!document.form1.nsenha.value != document.form1.csenha.value) { alert("As Senhas digitadas não coincidem."); document.form1.nsenha.focus(); return false; };
  return true;
}

function VHomologa() {
  if (!document.form1.data.value) { alert("Por favor, informe a data a ser agendada."); document.form1.data.focus(); return false; };
  if (!document.form1.nome.value) { alert("Por favor, informe o nome do funcionário."); document.form1.nome.focus(); return false; };
  if (!VEmail( document.form1.email.value)) { alert("O e-mail informado não é válido!\nVerifique-o novamente."); document.form1.email.focus(); return false; };
  if (!document.form1.telefone.value) { alert("Por favor, informe o telefone de contato."); document.form1.telefone.focus(); return false; };
   return true;
}

function VCadastroGuias() {
  if (!VCNPJ(document.form1.cnpj.value)) { alert("Por favor, informe um CNPJ válido.");	document.form1.cnpj.focus(); return false; };
  if (!document.form1.razao.value) { alert("Por favor, informe a razão social da empresa."); document.form1.razao.focus(); return false; };
  if (!document.form1.endereco.value) { alert("Por favor, informe o endereço da empresa."); document.form1.endereco.focus(); return false; };
  if (!document.form1.bairro.value) { alert("Por favor, informe o bairro."); document.form1.endereco.focus(); return false; };
  if (!document.form1.cidade.value) { alert("Por favor, informe a cidade."); document.form1.cidade.focus(); return false; };
  if (document.form1.estado.value == "-") { alert("Por favor, selecione o estado."); document.form1.estado.focus(); return false; };
  if (!document.form1.cep.value) { alert("Por favor, informe o CEP."); document.form1.cep.focus(); return false; };
  if (!document.form1.escritorio.value) { alert("Por favor, informe o nome do escritrio de contabilidade."); document.form1.escritorio.focus(); return false; };
  if (!document.form1.telefone.value) { alert("Por favor, informe o telefone de contato."); document.form1.telefone.focus(); return false; };
  if (!VEmail( document.form1.email.value)) { alert("O e-mail informado não é válido!\nVerifique-o novamente."); document.form1.email.focus(); return false; };
}

function VAssociese() {
  if (!document.form1.nome.value) { alert("Por favor, informe seu nome."); document.form1.nome.focus(); return false; };
  if (!VEmail( document.form1.email.value)) { alert("O e-mail informado não é válido!\nVerifique-o novamente."); document.form1.email.focus(); return false; };
  if (!document.form1.empresa.value) { alert("Por favor, informe o nome da empresa."); document.form1.empresa.focus(); return false; };
  if (!document.form1.endereco.value) { alert("Por favor, informe o endereço da empresa."); document.form1.endereco.focus(); return false; };
  if (!document.form1.bairro.value) { alert("Por favor, informe o bairro."); document.form1.bairro.focus(); return false; };
  if (!document.form1.cidade.value) { alert("Por favor, informe a cidade."); document.form1.cidade.focus(); return false; };
  if (!document.form1.cep.value) { alert("Por favor, informe o CEP."); document.form1.cep.focus(); return false; };
  if (!document.form1.telefone.value) { alert("Por favor, informe o telefone de contato."); document.form1.telefone.focus(); return false; };
}

function VEnviarNoticia() {
  if (!document.form1.seunome.value) { alert("Por favor, informe seu nome."); document.form1.seunome.focus(); return false; };
  if (!VEmail( document.form1.seuemail.value)) { alert("O e-mail informado não é válido!\nVerifique-o novamente."); document.form1.seuemail.focus(); return false; };
  if (!document.form1.destinatario.value) { alert("Por favor, informe o nome do destinatário."); document.form1.destinatario.focus(); return false; };
  if (!VEmail( document.form1.email.value)) { alert("O e-mail informado não é válido!\nVerifique-o novamente."); document.form1.email.focus(); return false; };
  return true;
}

function EnviaFormulario() {
	switch(tipo) {
		case 1: return VFaleConosco(); break;
		case 2: return VNewsletter(); break;
		case 3:	if (VBusca()) { document.location.href="busca.asp?busca=" + document.form1.busca.value; } break;
		case 4: return VAcessoRestrito(); break;
		case 5: return VAlterarSenha(); break;
		case 6: return VAgendeVisita(); break;
		case 7:	if (VBusca()) { document.location.href="noticias/busca.asp?busca=" + document.form1.busca.value; } break;
		case 8: return VHomologa(); break;
		case 9: VEmiteGuia(); return false; break;
		case 10: return VCadastroGuias(); break;
		case 11: return VAssociese(); break;
		case 12: return VEnviarNoticia(); break;
		case 13: return VAgendeHomologa(); break;
	}
	return false;
}

function VEmiteGuia() {
  if (!VCNPJ(document.form1.cnpj.value)) { alert("Por favor, informe um CNPJ válido.");	document.form1.cnpj.focus(); return false; };

	  remote = window.open("","remotewin","'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=no,copyhistory=no,width=780,height=500,top=100,left=100'");
	  remote.location.href = "guias/grcsu.asp?competencia_ano="+ document.form1.competencia_ano.value +"&competencia_mes="+ document.form1.competencia_mes.value +"&cnpj=" + document.getElementById('cnpj').value +"";
  remote.opener = window;
  return false;
}

//--------------------------------------------------------------------
// SUBMENUS
//--------------------------------------------------------------------
var tempoesconde = new Array();

function Esconde(id) {
	document.getElementById(id).style.display = "none";
}

function EscondeF(id) {
	tempoesconde[id] = setTimeout("Esconde('"+id+"')", 400);
}

function Mostra(id) {
	if (typeof(tempoesconde[id]) != 'undefined')
		clearTimeout(tempoesconde[id]);

	document.getElementById(id).style.display =  "";
}
//--------------------------------------------------------------------

//===============================================================================
//= INICIA AJAX =================================================================
//===============================================================================
function ajaxInit() {
	var req;
	
	try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ex) {
			try {
				req = new XMLHttpRequest();
			} catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				req = null;
			}
		}
	}
	return req;
};

function LoadAjax(metodo, url, send, destino) {
	var ajax = ajaxInit();	
	if(ajax) {  
		if(metodo == "post") {  
				ajax.open("POST", url, true);  
				ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
		} else {  
				ajax.open("GET", url + "?" + send, false);  
		}  
				
		ajax.onreadystatechange = function() { 
																if (ajax.readyState == 1) {
																	//document.getElementById(destino).innerHTML = 'Carregando...';
																}
																if (ajax.readyState == 4) {
																	if (ajax.status == 200) {
																		document.getElementById(destino).innerHTML = unescape(ajax.responseText.replace(/\+/g," "));
																	};
																}
															}  
			
		if(metodo == "post") {  
			ajax.send(send);  
		} else {  
			ajax.send(null);  
		}  
	}  
}

//===============================================================================
//= CARREGA CALENDARIO - MES ====================================================
//===============================================================================
function CarregaMes(codmes,tipo) { 
	if (codmes != "-") {
		if (tipo == 1) {		
			var url = "calendar.asp";
		}
		else	{
			var url = "cancelamento.asp";
		}
		var aleatorio=Math.random();
		var send = new Array();  
		send[send.length] = "date=" + codmes;
		send[send.length] = "index=" + aleatorio;
		send = send.join("&");
		
		if(document.getElementById) { // Para os browsers complacentes com o DOM W3C. 
			var exibeResultado = document.getElementById("calendario"); // div que exibirá o resultado. 
			var exibeResultado2 = document.getElementById("datadisp"); // div que exibirá o resultado. 
			var Ajax = ajaxInit(); // Inicia o Ajax. 
			Ajax.open("GET", url + "?" + send, true); 
			Ajax.onreadystatechange = function() 
			{ 
				if(Ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando... 
					//conteudo = "carregando...";
					//exibeResultado.innerHTML = conteudo;
				};
				if(Ajax.readyState == 4) { // Quando estiver tudo pronto. 
					if(Ajax.status == 200) { 
						var resultado = Ajax.responseText; // Coloca o retornado pelo Ajax nessa variável 
						resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4) 
						resultado = unescape(resultado); // Resolve o problema dos acentos 
						exibeResultado.innerHTML = resultado; 
						exibeResultado2.value = codmes; 
					} else { 
						exibeResultado.innerHTML = "Erro: ."; 
					};
				};
			};
			Ajax.send(null); // submete 
		};
	} 
}
