function verificaPreenchimentos() 
{
	//2 - checando se todos os campos foram preenchidos
	if ((document.getElementById("SenhaAtual").value == "") || (document.getElementById("NovaSenha").value == "") || (document.getElementById("ConfirmaNovaSenha").value == ""))
	{
		alert("Por favor, preencha os campos!");
		return false;
	}
	//fim do 2
	//3 - validando os campos da nova senha são iguais
	if (document.getElementById("NovaSenha").value != document.getElementById("ConfirmaNovaSenha").value)
	{
		alert("O campo para confirmação de senha está diferente de sua nova senha.\nPor favor corrija os dados digitados.");
		return false;
	}
	//fim do 3
	//4 - verificando se a senha atual é igual a nova senha
	if (document.getElementById("NovaSenha").value == document.getElementById("SenhaAtual").value)
	{
		alert("Sua nova senha é a mesma que sua senha atual. \nPor favor escolha uma nova senha diferente de sua senha atual.");
		return false;
	}
	//fim do 4
	document.getElementById("lembrarSenhaCli").submit();
}
//fim do 1

function Producao(tipo)
{	
	var opcao = '';
	if (document.getElementById("MesCompetencia").value == 0)
	//if (DemonstrativoProducao.MesCompetencia.value == 0) 
	{
		alert("Selecione um mês de competência!");
		return false;
	}
	
	mes = document.getElementById("MesCompetencia").value;	
	opcao = tipo;

	if(opcao == "0")
		{
				window.open('../prestadores/demonstrativoProducaoImp.asp?mes='+mes,'Demostrativo','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes');
		}
	if(opcao == "1")
		{	
			location.href="../prestadores/demonstrativoProducaoDetDir.asp"						//window.open('demonstrativoProducaoDet.asp?mes='+mes,'Demostrativo','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes');
		}
	if (opcao == '') {
		alert("Informe o tipo de demonstrativo desejado!");
		return false;
	}
}

function checkMail(mail){
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if(typeof(mail) == "string") {
		if(er.test(mail)) {
			return true; 
		}
	}
	else 
		if(typeof(mail) == "object") {
			if(er.test(mail.value)){
				return true;
			}
	}
	else {
		return false;
	}
}

function validarContato(tipo) {
	if (tipo == 'institucional') {
		with (document.frmContato) {
			if (edtNome.value == '') {
				alert('Por favor informe seu nome.');
				edtNome.focus();
				return false;
			}
			
			if (cmbDestino.value == '0') {
				alert('Por favor informe o destino.');
				cmbDestino.focus();
				return false;
			}
				
			if (edtEmail.value == '') {
				alert('Por favor informe seu e-mail.');
				edtEmail.focus();
				return false;
			}
			else {
				if (!checkMail(edtEmail.value)) {
    			alert("Email incorreto, por favor corrija.");
					edtEmail.focus();
					return false;
				}
			}
			
			if (cmbAssunto.value == '0') {
				cmbDestino.value = 'karla.costa@unimedmaceio.com.br';
			}
			
			if (edtTitulo.value == '') {
				alert('Por favor informe o titulo.');
				edtAssunto.focus();
				return false;
			}
			
			if (edtMensagem.value == '') {
				alert('Por favor preencha sua mensagem.');
				edtMensagem.focus();
				return false;
			}
			
			document.frmContato.submit();
			//alert('aqui');
		}
	}	
}

function procurarParcelas() {
	with (document.getElementById("frmBoleto")) {
		if (edtCodigo.value == '') {
			alert(unescape('Você deve informar o código do seu cartão.'));
			edtCodigo.focus();
			return false;
		}
		
		if (edtDigito.value == '') {
			alert('Você deve informar o dígito\nverificador do seu cartão.');
			edtDigito.focus();
			return false;
		}
		
		var codCliente = edtCodigo.value+edtDigito.value;
		parcelasBoleto(codCliente, 'exibirParcelas', true);
	}
}

function decALterarCliente(cliente) {
	document.getElementById("frmCliente").action = "dadosContratuais.asp?codNome="+cliente;
	document.getElementById("frmCliente").submit();
}

function altTipoUnimed(tipoUnimed) {
	document.getElementById("frmTipoPrestador").action = "outrasUnimeds.asp?tipo="+tipoUnimed;
	document.getElementById("frmTipoPrestador").submit();
}

function infoServico(servico, cliente) {
	var servico = servico;
	var cliente = cliente;
	var camada = true;
	var input = 'infoServico';
	
	if (servico == "") {
		return false;
	}
	
	if (isNaN(servico)) {
		ajax = ajaxInit();
	  if(ajax) {
		 	ajax.open("GET", "infoServico.asp?codigo=N&servico="+servico+"&cliente="+cliente);
			 ajax.onreadystatechange =   function() {
																								if (ajax.readyState == 1) {
																									document.getElementById(input).innerHTML = '<br /><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="18"><div align="center"><img src="../imagens/ajax-loader.gif" align="center"></div></td></tr></table>';
																								}
																								if(ajax.readyState == 4) {
																									if(ajax.status == 200) {
																										if(camada == false) {
																											document.getElementById(input).value = ajax.responseText;
																											}
																										else {
																											document.getElementById(input).innerHTML = ajax.responseText;
																											}
																										} 
																									else {
																										alert(ajax.statusText);
																										}
																									}
																								}
																	 ajax.send(null);
																 }
		}
		else {
			ajax = ajaxInit();
			if(ajax) {
				ajax.open("GET", "infoServico.asp?codigo=S&servico="+servico+"&cliente="+cliente);
				 ajax.onreadystatechange =   function() {
																									if (ajax.readyState == 1) {
																										document.getElementById(input).innerHTML = '<br /><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="18"><div align="center"><img src="../imagens/ajax-loader.gif" align="center"></div></td></tr></table>';
																									}
																									if(ajax.readyState == 4) {
																										if(ajax.status == 200) {
																											if(camada == false) {
																												document.getElementById(input).value = ajax.responseText;
																												}
																											else {
																												document.getElementById(input).innerHTML = ajax.responseText;
																												}
																											} 
																										else {
																											alert(ajax.statusText);
																											}
																										}
																									}
																		 ajax.send(null);
																	 }	
		}
}
//Permite digitar apenas números
function Numero(e)
{
	if (document.all) 
		var tecla = event.keyCode;
	else if(document.layers) 
		var tecla = e.which;
		if (tecla > 47 && tecla < 58)
			return true;
		else
			{
				if (tecla != 8)
					event.keyCode = 0;
				else
					return true;
			}
}

function NumLetras(e)
{
	if (document.all) 
		var tecla = event.keyCode;
	else if(document.layers) 
		var tecla = e.which;
		if ((tecla > 47 && tecla < 58) || (tecla > 64 && tecla < 91) || (tecla > 96 && tecla < 123))
			return true;
		else
			{
				if (tecla != 8)
					event.keyCode = 0;
				else
					return true;
			}
}

function Moeda(e)
{
	if (document.all) 
		var tecla = event.keyCode;
	else if(document.layers) 
		var tecla = e.which;
		if ((tecla > 47 && tecla < 58) || (tecla == 44)) //Cód. Vírgula=44
			return true;
		else
			{
				if (tecla != 8)
					event.keyCode = 0;
				else
					return true;
			}
}

function NumeroBcp(e)
{
/*
	Cód. ascii traço (-) = 45
*/
	if (document.all) 
		var tecla = event.keyCode;
	else if(document.layers) 
		var tecla = e.which;
		if ((tecla > 47 && tecla < 58) || (tecla == 45)) //Cód. Vírgula=44
			return true;
		else
			{
				if (tecla != 8)
					event.keyCode = 0;
				else
					return true;
			}
}

function NumeroOs(e)
{
	if (document.all) 
		var tecla = event.keyCode;
	else if(document.layers) 
		var tecla = e.which;
		if ((tecla >= 47 && tecla < 58)) //Cód. Barra=47
			return true;
		else
			{
				if (tecla != 8)
					event.keyCode = 0;
				else
					return true;
			}
}

function NumeroPoste(e)
/*
	Cód. ascii letra (s) = 115
	Cód. ascii letra (S) = 83
	Cód. ascii letra (n) = 110
	Cód. ascii letra (N) = 78
	Cód. ascii Barra (/) = 47

*/
{
	if (document.all) 
		var tecla = event.keyCode;
	else if(document.layers) 
		var tecla = e.which;
		if ((tecla >= 47 && tecla < 58) || (tecla == 115) || (tecla == 83) || (tecla == 110) || (tecla == 78)) 
			return true;
		else
			{
				if (tecla != 8)
					event.keyCode = 0;
				else
					return true;
			}
}

function NumeroPosteProjetos(e)
/*
	Cód. ascii letra (s) = 115
	Cód. ascii letra (S) = 83
	Cód. ascii letra (n) = 110
	Cód. ascii letra (N) = 78
	Cód. ascii traço (-) = 45
	Cód. ascii Barra (/) = 47
*/
{
	if (document.all) 
		var tecla = event.keyCode;
	else if(document.layers) 
		var tecla = e.which;
		if ((tecla >= 47 && tecla < 58) || (tecla == 115) || (tecla == 83) || (tecla == 110) || (tecla == 78) || (tecla == 45)) 
			return true;
		else
			{
				if (tecla != 8)
					event.keyCode = 0;
				else
					return true;
			}
}

//Autotab
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	
function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) {
  var found = false, index = 0;
  while(!found && index < arr.length)
    if(arr[index] == ele)
      found = true;
    else
      index++;
  return found;
}

function getIndex(input) {
  var index = -1, i = 0, found = false;
  while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
  return index;
}

return true;
}
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 parcelasBoleto(codigo, input, camada) { //se camada = true então usa-se .innerHTML para atualizar-la
 ajax = ajaxInit();
 if(ajax) {
   ajax.open("GET", "verificarParcelas.asp?codigo="+codigo);
   ajax.onreadystatechange =   function() {
		 																				if (ajax.readyState == 1) {
																							document.getElementById(input).innerHTML = '<br /><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="18"><div align="center"><img src="../imagens/ajax-loader.gif" align="center"></div></td></tr></table>';
																						}
								 														if(ajax.readyState == 4) {
								   														if(ajax.status == 200) {
																								if(camada == false) {
									 																document.getElementById(input).value = ajax.responseText;
									 																}
																								else {
									 																document.getElementById(input).innerHTML = ajax.responseText;
									 																}
								   															} 
																							else {
									 															alert(ajax.statusText);
																							 	}
																						 	}
																						}
															 ajax.send(null);
														 }
}

function emitirBoleto(nome, codigo, cpf, vencimento, processamento, numdoc, acrescimos, desconto, valor) {
	window.open('imprimirBoleto.asp?nome='+nome+'&codigo='+codigo+'&cpf='+cpf+'&vencimento='+vencimento+'&processamento='+processamento+'&numdoc='+numdoc+'&acrescimos='+acrescimos+'&desconto='+desconto+'&valor='+valor,'imprimirBoleto','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes,location=no');
	//document.frmGeraBoletoCli.submit();
}

function exibeCampos2(tipo) {
	if (tipo == 'demonstrativos') {
		
		
		if (document.getElementById("cmbTipoDemonstrativo").value == '1') {
			document.getElementById("referencia").style.visibility = 'visible'
			document.getElementById("dependentes").style.visibility = 'hidden'
			document.getElementById("periodoIni").style.visibility = 'hidden'
			document.getElementById("periodoFim").style.visibility = 'hidden'
			document.getElementById("a").style.visibility = 'hidden'
			document.getElementById("modelo").style.visibility = 'hidden'
			document.getElementById("anoBase").style.visibility = 'visible'
			document.getElementById("cliente").style.visibility = 'hidden'
			document.getElementById("helpCliente").style.visibility = 'hidden'
			document.getElementById("periodo").style.visibility = 'hidden'
			document.getElementById("helpPeriodo").style.visibility = 'hidden'
			document.getElementById("enviar").style.visibility = 'visible'
		}
		
		if (document.getElementById("cmbTipoDemonstrativo").value == '2') {
			document.getElementById("referencia").style.visibility = 'hidden'
			document.getElementById("dependentes").style.visibility = 'visible'
			document.getElementById("periodoIni").style.visibility = 'visible'
			document.getElementById("periodoFim").style.visibility = 'visible'
			document.getElementById("a").style.visibility = 'visible'
			document.getElementById("modelo").style.visibility = 'visible'
			document.getElementById("anoBase").style.visibility = 'hidden'
			document.getElementById("cliente").style.visibility = 'visible'
			document.getElementById("helpCliente").style.visibility = 'visible'
			document.getElementById("periodo").style.visibility = 'visible'
			document.getElementById("helpPeriodo").style.visibility = 'visible'
			document.getElementById("enviar").style.visibility = 'visible'
		}
		
		if (document.getElementById("cmbTipoDemonstrativo").value == '3') {
			document.getElementById("referencia").style.visibility = 'hidden'
			document.getElementById("dependentes").style.visibility = 'hidden'
			document.getElementById("periodoIni").style.visibility = 'visible'
			document.getElementById("periodoFim").style.visibility = 'visible'
			document.getElementById("a").style.visibility = 'visible'
			document.getElementById("modelo").style.visibility = 'visible'
			document.getElementById("anoBase").style.visibility = 'hidden'
			document.getElementById("cliente").style.visibility = 'hidden'
			document.getElementById("helpCliente").style.visibility = 'hidden'
			document.getElementById("periodo").style.visibility = 'visible'
			document.getElementById("helpPeriodo").style.visibility = 'visible'
			document.getElementById("enviar").style.visibility = 'visible'
		}
	}
	
	if (tipo == 'declaracoes') {
		if (document.getElementById("cmbTipoDec").value == '1') {
			document.getElementById("declararQuite").style.visibility = 'visible'
			document.getElementById("decTipoDeclaracao").style.visibility = 'visible'
			document.getElementById("data").style.visibility = 'visible'
			document.getElementById("edtData1").style.visibility = 'visible'
			document.getElementById("enviar").style.visibility = 'visible'
		}
		if (document.getElementById("cmbTipoDec").value == '2') {
			document.getElementById("declararQuite").style.visibility = 'hidden'
			document.getElementById("decTipoDeclaracao").style.visibility = 'hidden'
			document.getElementById("data").style.visibility = 'hidden'
			document.getElementById("edtData1").style.visibility = 'hidden'
			document.getElementById("enviar").style.visibility = 'visible'
		}
	}
	
	if (tipo == 'declaracoesCli') {
		if (document.getElementById("cmbTipoDeclaracao").value == '1') {
			document.getElementById("declararQuite").style.visibility = 'visible'
			document.getElementById("decTipoDeclaracao").style.visibility = 'visible'
			document.getElementById("edtData").style.visibility = 'visible'
			document.getElementById("data").style.visibility = 'visible'
			document.getElementById("edtData1").style.visibility = 'visible'
			document.getElementById("enviar").style.visibility = 'visible'
		}
		if (document.getElementById("cmbTipoDeclaracao").value == '2') {
			document.getElementById("declararQuite").style.visibility = 'hidden'
			document.getElementById("decTipoDeclaracao").style.visibility = 'hidden'
			document.getElementById("data").style.visibility = 'hidden'
			document.getElementById("edtData1").style.visibility = 'hidden'
			document.getElementById("enviar").style.visibility = 'visible'
		}
	}
}

function showHint(e,sistema)
{
var hint   = document.getElementById("exibeHint");
var url = "hint.asp?help="+sistema+"&time="+new Date();
var posx = 0;
var posy = 0;

if (!e) var e = window.event;
if (e.pageX || e.pageY)
{
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY)
{
posx = e.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}


req.open("GET",url,true);

req.onreadystatechange = function()
{
if(req.readyState == 4)
{
if(req.status == 200)
{

hint.innerHTML = req.responseText;;
hint.style.top = posy + "px";
hint.style.left = posx - 400 + "px";
hint.style.display = 'block';
}
}

};
req.send(null);

}

function hideHint()
{
var hint   = document.getElementById("exibeHint");
hint.style.display = 'none';
}


function gerarDeclaracao2(tipo) {
	if (tipo == '1') {
		document.getElementById("frmDeclaracoes").action = "decQuitacao.asp?data="+document.getElementById("edtData").value+"&todasVendas="+document.getElementById("cmbTipoQuitacao").value+"&codNome="+document.getElementById("cmbDecPessoa").value;
		//alert(document.getElementById("frmDemonstrativos").action);
		document.getElementById("frmDeclaracoes").submit();
	}
	
	if (tipo == '2') {
		document.getElementById("frmDeclaracoes").action = "decTempoUni.asp?codNome="+document.getElementById("cmbDecPessoa").value;
		document.getElementById("frmDeclaracoes").submit();
	}
}

function enviarProcesso(queixa) {
	if (queixa == 'S') {
		if (document.getElementById("cmbMedicos").value == '0') {
			alert('Informe o nome do médico');
			return false;
		}
	}
	
	if (document.getElementById("edtDetalhamento").value == '') {
		alert('Infortme o detalhamento do processo');
		return false;
	}
	
	//document.getElementById("frmProcessosCadastrar").action = 'procIntCadResult.asp';
	//document.getElementById("frmProcessosCadastrar").submit();
	cadastrarProcesso(document.getElementById("codAssunto").value, document.getElementById("codSetor").value, document.getElementById("edtDetalhamento").value, document.getElementById("cmbMedicos").value, document.getElementById("descAssunto").value, 'cadProcesso', true);
}

function cadastrarProcesso(codAssunto, setor, detalhamento, medico, descAssunto, input, camada) {
 var params = "codAssunto="+codAssunto+"&codSetor="+setor+"&edtDetalhamento="+detalhamento+"&cmbMedico="+medico+"&descAssunto="+descAssunto;
 var http = new XMLHttpRequest();
 //ajax = ajaxInit();
 //if(ajax) {
   http.open("POST", "../includes/procIntCadResult.asp"+"?"+params, true);
	 http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	 http.setRequestHeader("Content-length", params.length);
	 http.setRequestHeader("Connection", "close");
   http.onreadystatechange =   function() {
		 																				if (http.readyState == 1) {
																							document.getElementById(input).innerHTML = '<br /><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" height="300"><tr><td height="18"><div align="center"><img src="../imagens/ajax-loader.gif" align="center"></div></td></tr></table>';
																						}
								 														if(http.readyState == 4) {
								   														if(http.status == 200) {
																								if(camada == false) {
									 																document.getElementById(input).value = http.responseText;
									 																}
																								else {
									 																document.getElementById(input).innerHTML = http.responseText;
									 																}
								   															} 
																							else {
									 															alert(http.statusText);
																							 	}
																						 	}
																						}
															 http.send(params);
														 }


function gerarRelacaoPos() {
	//var prest = document.getElementById("edtPrestador").value;
	//var dataIni = document.getElementById("edtDataInicial").value;
	//var dataFim = document.getElementById("edtDataFinal").value;	
	
	document.getElementById("frmPOS").submit();
}


function gerarDemonstrativo(tipo) {
	var tipo = tipo;
	if (tipo == 'A') {
		var ref = document.getElementById("cmbMesReferencia").value;
		//alert(document.getElementById("rdbTipo").value);
		if ((ref == '0')||(ref = null)) {
			alert("Informe o mês de referência");
			document.getElementById("cmbMesReferencia").focus();
			return false;
		}
		window.open('http://189.23.134.134/autoservico/Content/TISS/Demonstrativo/AnaliseContaMedica_print.aspx?prest='+document.getElementById("codContratoCoop").value+'&periodo='+document.getElementById("cmbMesReferencia").value+'&operad=2291','Demostrativo','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes,toolbar=no,menubar=no');
	}
	if (tipo == 'P') {
		var ref = document.getElementById("cmbMesReferencia").value;
		//alert(document.getElementById("rdbTipo").value);
		if ((ref == '0')||(ref = null)) {
			alert("Informe o mês de referência");
			document.getElementById("cmbMesReferencia").focus();
			return false;
		}
		
		if ((document.getElementById("rdbTipo").value == '')||(document.getElementById("rdbTipo").value == null)) {
			if ((document.getElementById("rdbTipo1").value == '')||(document.getElementById("rdbTipo1").value == null)) {
				alert("Informe o tipo desejado");
				document.getElementByName("rdbTipo").focus();
				return false;	
			}
		}
		
		if (document.getElementById("rdbTipo").checked == true) {
			//document.getElementById("frmDemonstrativos").action = "demonstrativoProducaoImp.asp?mes="+document.getElementById("cmbMesReferencia").value;
			//document.getElementById("frmDemonstrativos").submit();
			window.open('demonstrativoProducaoImp.asp?mes='+document.getElementById("cmbMesReferencia").value,'Demostrativo','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes,toolbar=no,menubar=no');
		}
		
		if (document.getElementById("rdbTipo1").checked == true) {
			window.open('demonstrativoProducaoDet.asp?mes='+document.getElementById("cmbMesReferencia").value,'Demostrativo','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes,toolbar=no,menubar=no');
		}
	}
	
	if (tipo == 'IRPF') {
		window.open('demIRPFDetalhado.asp?Referencia='+document.getElementById("edtAno").value,'Demonstrativo','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes');
	}
	
	if (tipo == 'INSS') {
		window.open('demonstrativoINSSImp.asp?ano='+document.getElementById("cmbMesReferencia").value,'Demostrativo','width=650,height=450,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes');
	}
}

function exibeCampos(valor) {
	if (valor == '1') {
		document.getElementById("quite").style.visibility = 'visible';
		document.getElementById("data").style.visibility = 'visible';
		document.getElementById("refInicial").style.visibility = 'hidden';
		document.getElementById("refFinal").style.visibility = 'hidden';
	}
	
	else if (valor == '4') {
		document.getElementById("quite").style.visibility = 'hidden';
		document.getElementById("data").style.visibility = 'hidden';
		document.getElementById("refInicial").style.visibility = 'visible';
		document.getElementById("refFinal").style.visibility = 'visible';
	}
	
	else if (valor = '5') {
		location.href = '../comunicacoes/Declaracao_INSS_Unimed.doc';
	}
	
	else {
		document.getElementById("quite").style.visibility = 'hidden';
		document.getElementById("data").style.visibility = 'hidden';
		document.getElementById("refInicial").style.visibility = 'hidden';
		document.getElementById("refFinal").style.visibility = 'hidden';
	}
}

function gerarDemonstrativo2(tipo) {
	if (tipo == '1') {
		document.getElementById("frmDemonstrativos").action = "demIRPFDetalhado.asp?ref="+document.getElementById("edtRefIRPF").value;
		//alert(document.getElementById("frmDemonstrativos").action);
		document.getElementById("frmDemonstrativos").submit();
	}
	
	if (tipo == '2') {
		document.getElementById("frmDemonstrativos").action = "demUtilizacao.asp?inicio="+document.getElementById("edtDataInicialDemUtilizacao").value+"&fim="+document.getElementById("edtDataFinalDemUtilizacao").value+"&codNome="+document.getElementById("cmbDemPessoa").value+"&tab=0";
		document.getElementById("frmDemonstrativos").submit();
	}
	
	if (tipo == '3') {
		document.getElementById("frmDemonstrativos").action = "demFinanceiro.asp";
		document.getElementById("frmDemonstrativos").submit();
	}
	
	//alert("demIRPFDetalhado.asp?ref="+document.getElementById("edtRefIRPF").value);
	//return true;
}

function gerarDeclaracao(codigo) {
	if (document.getElementById("cmbTipoDeclaracao").value == '0') {
		alert("Informe o tipo de declaração");
		document.getElementById("cmbTipoDeclaracao").focus();
		return false;
	}
	else {
		if (document.getElementById("cmbTipoDeclaracao").value == '1') { //Declaração de pagamento
			if ((document.getElementById("cmbTipoQuitacao").value == '0')||(document.getElementById("edtData").value == '')) {
				alert("Todos os campos são obrigatórios");
				return false;
			}
			else {
				var todasVendas = document.getElementById("cmbTipoQuitacao").value;
				//var codBeneficiario = "<%=vCodTitular%>";
				var data = document.getElementById("edtData").value;
				window.open('decPagamentoPacoop.asp?data='+data+'&todasVendas='+todasVendas+'&codBeneficiario='+codigo,'Declaracao','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes');
			}
		}
		
		if (document.getElementById("cmbTipoDeclaracao").value == '2') { //Declaração de tempo de unimed como beneficiário
			window.open('decTempoUni.asp?codigo='+codigo,'Declaracao','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes');
		}
		
		if (document.getElementById("cmbTipoDeclaracao").value == '3') { //Declaração de tempo de unimed como cooperado
			window.open('decTempoUniCoop.asp','Declaracao','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes');
		}
		
		if (document.getElementById("cmbTipoDeclaracao").value == '4') { //Declaração de recebimento
			if ((document.getElementById("edtRefInicial").value == '')||(document.getElementById("edtRefInicial").value == null)) {
				alert("Informe a referência inicial no formato MMAAAA");
				document.getElementById("edtRefInicial").focus();
				return false;
			}
			
			if ((document.getElementById("edtRefFinal").value == '')||(document.getElementById("edtRefFinal").value == null)) {
				alert("Informe a referência final no formato MMAAAA");
				document.getElementById("edtRefFinal").focus();
				return false;
			}
			
			window.open('decRecebimento.asp?RefInicial='+document.getElementById("edtRefInicial").value+'&RefFinal='+document.getElementById("edtRefFinal").value,'Declaracao','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes');
		}
	}
}

function GeraRelatorio()
{	
		if (document.getElementById("cmbIndicador").value==0) 
		{
			alert("Por favor selecione um indicador!");
			return false;
		}	
		
		if (document.getElementById("cmbReferencia").value == 0) 
		{
			alert("Selecione uma referência!");
			return false;
		}

		referencia = document.getElementById("cmbReferencia").value;
		indicador_escolhido = document.getElementById("cmbIndicador").value;	

		if (document.getElementById("chkEspecialidade").checked)
			{
				especialidade = 'S'
			}
		else
			{
				especialidade = 'N'
			}
		
		window.open('indicadoresperfilCooperados.asp?referencia='+referencia+'&indicador='+indicador_escolhido+'&especialidade='+especialidade,'Indicadores','width=600,height=380,left=200,top=200,screenX=0,screenY=0,status=no,scrollbars=yes,resizable=yes');
}	

function gerarGuiaMedico() 
{
	if ((document.getElementById("TipoConsGuiaMedico").value=="SELECIONE")||(document.getElementById("TipoConsGuiaMedico").value=="0"))
	{
		alert("Selecione o tipo da consulta!");
		document.getElementById("TipoConsGuiaMedico").focus();
		return false;
	}
	
	if (document.getElementById("cidades").value=="0")
	{
		alert("Selecione uma cidade!");
		document.getElementById("cidades").focus();
		return false;
	
	}

	document.getElementById("frmGuiaMedico").submit();
}

function email(codigo, email, input) { //se camada = true então usa-se .innerHTML para atualizar-la
 ajax = ajaxInit();
 if(ajax) {
   ajax.open("GET", "email.asp?codigo="+codigo+"&email="+email);
   ajax.onreadystatechange =   function() {
		 																				if (ajax.readyState == 1) {
																							document.getElementById(input).innerHTML = '<br /><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="18"><div align="center"><img src="../imagens/ajax-loader.gif" align="center"></div></td></tr></table>';
																						}
								 														if(ajax.readyState == 4) {
								   														if(ajax.status == 200) {
																								if(camada == false) {
									 																document.getElementById(input).value = ajax.responseText;
									 																}
																								else {
									 																document.getElementById(input).innerHTML = ajax.responseText;
									 																}
								   															} 
																							else {
									 															alert(ajax.statusText);
																							 	}
																						 	}
																						}
															 ajax.send(null);
														 }
}


function ValidaCampos()
{
	if (document.getElementById("cmbRelacao").value=="0")
	{
		alert("Selecione sua relação com a Unimed!");
		document.getElementById("cmbRelacao").focus();
		return false;
	}
	if (document.getElementById("nome").value=="")
	{
		document.getElementById("nome").value="Não informado";
		//return false;
	}

	if (document.getElementById("email").value=="")
	{
		document.getElementById("email").value="Não informado";
		//return false;
	}

	if (document.getElementById("telefone").value=="")
	{
		document.getElementById("telefone").value="Não informado";
		//return false;
	}
	
	if (document.getElementById("assunto").value=="")
	{
		alert("Preencha o campo assunto!");
		document.getElementById("assunto").focus();
		return false;
	}

	if (document.getElementById("mensagem").value=="")
	{
		alert("Preencha o campo mensagem!");
		document.getElementById("mensagem").focus();
		return false;
	}

document.getElementById("contatoConfis").action="resultadoConfis.asp"
document.getElementById("contatoConfis").submit();
}

function procurarCliente() {
	with (document.getElementById("frmAtualizaCad")) {
		if (edtCodigo.value == '') {
			alert(unescape('Você deve informar o código do seu cartão.'));
			edtCodigo.focus();
			return false;
		}
		
		if (edtDigito.value == '') {
			alert('Você deve informar o dígito\nverificador do seu cartão.');
			edtDigito.focus();
			return false;
		}
		
		var codCliente = edtCodigo.value+edtDigito.value;
		//alert(codCliente);
		parcelasBoleto(codCliente, 'exibirParcelas', true);
	}
}

function enviarCurriculo() {
	with (document.getElementById("frmCurriculo")) {
		if (edtNome.value == '') {
			alert(unescape('Você deve informar seu nome completo.'));
			edtNome.focus();
			return false;
		}
		
		if (cmbArea.value == '0') {
			alert(unescape('Você deve informar a área pretendida.'));
			cmbArea.focus();
			return false;
		}
		
		if (curriculo.value == '') {
			alert(unescape('Você deve anexar o seu curriculo.'));
			curriculo.focus();
			return false;
		}
		
		submit();		
	}
}
function sendCurriculo(nome, area, arquivo, input, camada) { //se camada = true então usa-se .innerHTML para atualizar-la
 ajax = ajaxInit();
 if(ajax) {
   ajax.open("GET", "http://189.23.134.134/satellite/upload.asp?nome="+nome+"&area="+area+"&arquivo="+arquivo);
   ajax.onreadystatechange =   function() {
		 																				if (ajax.readyState == 1) {
																							document.getElementById(input).innerHTML = '<br /><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="18"><div align="center"><img src="../imagens/ajax-loader.gif" align="center"></div></td></tr></table>';
																						}
								 														if(ajax.readyState == 4) {
								   														if(ajax.status == 200) {
																								if(camada == false) {
									 																document.getElementById(input).value = ajax.responseText;
									 																}
																								else {
									 																document.getElementById(input).innerHTML = ajax.responseText;
									 																}
								   															} 
																							else {
									 															alert(ajax.statusText);
																							 	}
																						 	}
																						}
															 ajax.send(null);
														 }
}

function validaForm()
 {
	vCodCli = 		document.getElementById("codCli").value;
	vDigitoCodCli = 		document.getElementById("digitoCodCli").value;

	/* 1------------------------- verificando se algum campo do formulário está em branco ---------------------------*/
	if ((vCodCli=="") || (vDigitoCodCli==""))
	{
		alert("Por favor informe o código do seu cartão Unimed!");
		document.getElementById("codCli").focus();
		return false;
	}	
	/*fim do 1 ------------------------------------------------------------------------------------------------------*/
	
	if ((document.getElementById("dataNascimento").value==""))
	{
		alert("Por favor informe sua data de nascimento!");
		document.getElementById("dataNascimento").focus();
		return false;	
	}

	if ((document.getElementById("NumCPFCliente").value==""))
	{
		alert("Por favor informe seu CPF!");
		document.getElementById("NumCPFCliente").focus();
		return false;	
	}

	document.getElementById("frmLembrarSenha").action="resultadoLembrarSenha.asp"
	document.getElementById("frmLembrarSenha").submit();
}