
// Funções para Solicitação de Aluguel

function limparFormularioAluguel(){
	desabilitarPessoaFisica();
}

function fixarRadioOptionSimples(acionador, alvo, par){

	if (document.getElementById(acionador).checked) {
		document.getElementById(alvo).checked = true;
		document.getElementById(par).checked = false;
	}

}

function fixarRadioOption(acionador, alvo, correspondente_alvo, par, correspondente_par){

	if (document.getElementById(acionador).checked) {
		document.getElementById(alvo).checked = document.getElementById(correspondente_alvo).checked;
		document.getElementById(par).checked = document.getElementById(correspondente_par).checked;
	}

}

function habilitarOutraDestinacao(seletor) {
	if (seletor.selectedIndex == seletor.length - 1) {
		document.getElementById('outras-destinacoes').disabled = '';
		document.getElementById('outras-destinacoes').readOnly = false;
		document.getElementById('outras-destinacoes').focus();
	} else {
		document.getElementById('outras-destinacoes').disabled = 'DISABLED';
		document.getElementById('outras-destinacoes').readOnly = true;
		document.getElementById('outras-destinacoes').value = '';
	}
}

function desabilitarPessoaFisica() {
	liberarRepresentanteLegal();
	limparDadosTitular();
	document.getElementById('cpf').disabled = 'DISABLED';
	document.getElementById('cpf').readOnly = true;
	document.getElementById('cpf').value = '';
	document.getElementById('rg').disabled = 'DISABLED';
	document.getElementById('rg').readOnly = true;
	document.getElementById('rg').value = '';
	document.getElementById('rg-oe').disabled = 'DISABLED';
	document.getElementById('rg-oe').readOnly = true;
	document.getElementById('rg-oe').value = '';
	document.getElementById('genero-m').disabled = 'DISABLED';
	document.getElementById('genero-m').readOnly = true;
	document.getElementById('genero-f').disabled = 'DISABLED';
	document.getElementById('genero-f').readOnly = true;
	document.getElementById('estado-civil').disabled = 'DISABLED';
	document.getElementById('estado-civil').readOnly = true;
	document.getElementById('estado-civil').value = '';
	document.getElementById('ocupacao').disabled = 'DISABLED';
	document.getElementById('ocupacao').readOnly = true;
	document.getElementById('ocupacao').value = '';
	document.getElementById('naturalidade').disabled = 'DISABLED';
	document.getElementById('naturalidade').readOnly = true;
	document.getElementById('naturalidade').value = '';
	document.getElementById('nacionalidade').disabled = 'DISABLED';
	document.getElementById('nacionalidade').readOnly = true;
	document.getElementById('nacionalidade').value = '';
	document.getElementById('cnpj').disabled = '';
	document.getElementById('cnpj').readOnly = false;
	document.getElementById('nome-comercial').disabled = '';
	document.getElementById('nome-comercial').readOnly = false;
	document.getElementById('cnpj').focus();
}

function desabilitarPessoaJuridica() {
	limparDadosTitular();
	document.getElementById('cnpj').disable = 'DISABLED';
	document.getElementById('cnpj').readOnly = true;
	document.getElementById('cnpj').value = '';
	document.getElementById('nome-comercial').disable = 'DISABLED';
	document.getElementById('nome-comercial').readOnly = true;
	document.getElementById('nome-comercial').value = '';
	document.getElementById('cpf').disabled = '';
	document.getElementById('cpf').readOnly = false;
	document.getElementById('rg').disabled = '';
	document.getElementById('rg').readOnly = false;
	document.getElementById('rg-oe').disabled = '';
	document.getElementById('rg-oe').readOnly = false;
	document.getElementById('genero-m').disabled = '';
	document.getElementById('genero-m').readOnly = false;
	document.getElementById('genero-f').disabled = '';
	document.getElementById('genero-f').readOnly = false;
	document.getElementById('estado-civil').disabled = '';
	document.getElementById('estado-civil').readOnly = false;
	document.getElementById('ocupacao').disabled = '';
	document.getElementById('ocupacao').readOnly = false;
	document.getElementById('naturalidade').disabled = '';
	document.getElementById('naturalidade').readOnly = false;
	document.getElementById('nacionalidade').disabled = '';
	document.getElementById('nacionalidade').readOnly = false;
	document.getElementById('cpf').focus();
}

function desabilitarPessoaFisicaTitular(focar, desabilitar, especial) {

	if (document.getElementById('titular-conta-locador').checked) {

		fixarRadioOption('titular-conta-locador', 'tipo-documento-cnpj-titular-conta', 'tipo-documento-cnpj', 'tipo-documento-cpf-titular-conta', 'tipo-documento-cpf');

		if (!desabilitar) {
			desabilitar = true;
		} else {
			desabilitar = false;
		}
	}

	if (especial)
		if (!desabilitar) {
			desabilitar = true;
		} else {
			desabilitar = false;
		}

	if (desabilitar) {

		document.getElementById('cpf-titular-conta').disabled = 'DISABLED';
		document.getElementById('cpf-titular-conta').readOnly = true;
		document.getElementById('cpf-titular-conta').value = '';
		document.getElementById('rg-titular-conta').disabled = 'DISABLED';
		document.getElementById('rg-titular-conta').readOnly = true;
		document.getElementById('rg-titular-conta').value = '';
		document.getElementById('rg-oe-titular-conta').disabled = 'DISABLED';
		document.getElementById('rg-oe-titular-conta').readOnly = true;
		document.getElementById('rg-oe-titular-conta').value = '';
		document.getElementById('genero-m-titular-conta').disabled = 'DISABLED';
		document.getElementById('genero-m-titular-conta').readOnly = true;
		document.getElementById('genero-f-titular-conta').disabled = 'DISABLED';
		document.getElementById('genero-f-titular-conta').readOnly = true;
		document.getElementById('estado-civil-titular-conta').disabled = 'DISABLED';
		document.getElementById('estado-civil-titular-conta').readOnly = true;
		document.getElementById('estado-civil-titular-conta').value = '';
		document.getElementById('ocupacao-titular-conta').disabled = 'DISABLED';
		document.getElementById('ocupacao-titular-conta').readOnly = true;
		document.getElementById('ocupacao-titular-conta').value = '';
		document.getElementById('naturalidade-titular-conta').disabled = 'DISABLED';
		document.getElementById('naturalidade-titular-conta').readOnly = true;
		document.getElementById('naturalidade-titular-conta').value = '';
		document.getElementById('nacionalidade-titular-conta').disabled = 'DISABLED';
		document.getElementById('nacionalidade-titular-conta').readOnly = true;
		document.getElementById('nacionalidade-titular-conta').value = '';
		document.getElementById('cnpj-titular-conta').disabled = '';
		document.getElementById('cnpj-titular-conta').readOnly = false;
		document.getElementById('nome-comercial-titular-conta').disabled = '';
		document.getElementById('nome-comercial-titular-conta').readOnly = false;
		if (focar)
			document.getElementById('cnpj-titular-conta').focus();

	}

}

function desabilitarPessoaJuridicaTitular(focar, desabilitar, especial) {

	if (document.getElementById('titular-conta-locador').checked) {

		fixarRadioOption('titular-conta-locador', 'tipo-documento-cpf-titular-conta', 'tipo-documento-cpf', 'tipo-documento-cnpj-titular-conta', 'tipo-documento-cnpj');

		if (!desabilitar) {
			desabilitar = true;
		} else {
			desabilitar = false;
		}
	}

	if (especial)
		desabilitar = true;

	if (desabilitar) {

		//alert("Ok");

		document.getElementById('cnpj-titular-conta').disable = 'DISABLED';
		document.getElementById('cnpj-titular-conta').readOnly = true;
		document.getElementById('cnpj-titular-conta').value = '';
		document.getElementById('nome-comercial-titular-conta').disable = 'DISABLED';
		document.getElementById('nome-comercial-titular-conta').readOnly = true;
		document.getElementById('nome-comercial-titular-conta').value = '';
		document.getElementById('cpf-titular-conta').disabled = '';
		document.getElementById('cpf-titular-conta').readOnly = false;
		document.getElementById('rg-titular-conta').disabled = '';
		document.getElementById('rg-titular-conta').readOnly = false;
		document.getElementById('rg-oe-titular-conta').disabled = '';
		document.getElementById('rg-oe-titular-conta').readOnly = false;
		document.getElementById('genero-m-titular-conta').disabled = '';
		document.getElementById('genero-m-titular-conta').readOnly = false;
		document.getElementById('genero-f-titular-conta').disabled = '';
		document.getElementById('genero-f-titular-conta').readOnly = false;
		document.getElementById('estado-civil-titular-conta').disabled = '';
		document.getElementById('estado-civil-titular-conta').readOnly = false;
		document.getElementById('ocupacao-titular-conta').disabled = '';
		document.getElementById('ocupacao-titular-conta').readOnly = false;
		document.getElementById('naturalidade-titular-conta').disabled = '';
		document.getElementById('naturalidade-titular-conta').readOnly = false;
		document.getElementById('nacionalidade-titular-conta').disabled = '';
		document.getElementById('nacionalidade-titular-conta').readOnly = false;
		if (focar)
			document.getElementById('cpf-titular-conta').focus();

	}

}

function preencherDadosTitularLocador() {

	if (document.getElementById('tipo-documento-cpf').checked) {

		if (document.getElementById('cpf').value != "" &&
			document.getElementById('rg').value != "" &&
			document.getElementById('rg-oe').value != "" &&
			document.getElementById('estado-civil').value != "" &&
			document.getElementById('ocupacao').value != "" &&
			document.getElementById('naturalidade').value != "" &&
			document.getElementById('nacionalidade').value != "" &&
			document.getElementById('nome-outra-parte').value != "" &&
			document.getElementById('endereco-outra-parte').value != "") {

			desabilitarPessoaJuridicaTitular(true, false, false);

			document.getElementById('tipo-documento-cpf-titular-conta').checked = true;
			document.getElementById('tipo-documento-cnpj-titular-conta').checked = false;

			document.getElementById('cpf-titular-conta').value = document.getElementById('cpf').value;
			document.getElementById('rg-titular-conta').value = document.getElementById('rg').value;
			document.getElementById('rg-oe-titular-conta').value = document.getElementById('rg-oe').value;
			if (document.getElementById('genero-m').checked) {
				document.getElementById('genero-m-titular-conta').checked = true;
				document.getElementById('genero-f-titular-conta').checked = false;
			}
			if (document.getElementById('genero-f').checked) {
				document.getElementById('genero-m-titular-conta').checked = false;
				document.getElementById('genero-f-titular-conta').checked = true;
			}
			document.getElementById('estado-civil-titular-conta').value = document.getElementById('estado-civil').value;
			document.getElementById('ocupacao-titular-conta').value = document.getElementById('ocupacao').value;
			document.getElementById('naturalidade-titular-conta').value = document.getElementById('naturalidade').value;
			document.getElementById('nacionalidade-titular-conta').value = document.getElementById('nacionalidade').value;
			document.getElementById('nome-titular-conta').value = document.getElementById('nome-outra-parte').value;
			document.getElementById('endereco-titular-conta').value = document.getElementById('endereco-outra-parte').value;
			document.getElementById('telefones-titular-conta').value = document.getElementById('telefones').value;
			document.getElementById('emails-titular-conta').value = document.getElementById('emails').value;

			document.getElementById('cpf-titular-conta').readOnly = true;
			document.getElementById('rg-titular-conta').readOnly = true;
			document.getElementById('rg-oe-titular-conta').readOnly = true;
			document.getElementById('genero-m-titular-conta').readOnly = true;
			document.getElementById('genero-f-titular-conta').readOnly = true;
			document.getElementById('estado-civil-titular-conta').readOnly = true;
			document.getElementById('ocupacao-titular-conta').readOnly = true;
			document.getElementById('naturalidade-titular-conta').readOnly = true;
			document.getElementById('nacionalidade-titular-conta').readOnly = true;
			document.getElementById('nome-titular-conta').readOnly = true;
			document.getElementById('endereco-titular-conta').readOnly = true;
			document.getElementById('telefones-titular-conta').readOnly = true;
			document.getElementById('emails-titular-conta').readOnly = true;

		} else {

			document.getElementById('titular-conta-locador').checked = false;
			document.getElementById('titular-conta-recebedor').checked = true;

		}

	}

	if (document.getElementById('tipo-documento-cnpj').checked) {

		if (document.getElementById('cnpj').value != "" &&
			document.getElementById('nome-comercial').value != "" &&
			document.getElementById('nome-outra-parte').value != "" &&
			document.getElementById('endereco-outra-parte').value != "") {

			desabilitarPessoaFisicaTitular(true, false, false);

			document.getElementById('tipo-documento-cnpj-titular-conta').checked = true;
			document.getElementById('tipo-documento-cpf-titular-conta').checked = false;

			document.getElementById('cnpj-titular-conta').value = document.getElementById('cnpj').value;
			document.getElementById('nome-comercial-titular-conta').value = document.getElementById('nome-comercial').value;
			document.getElementById('nome-titular-conta').value = document.getElementById('nome-outra-parte').value;
			document.getElementById('endereco-titular-conta').value = document.getElementById('endereco-outra-parte').value;
			document.getElementById('telefones-titular-conta').value = document.getElementById('telefones').value;
			document.getElementById('emails-titular-conta').value = document.getElementById('emails').value;

			document.getElementById('cnpj-titular-conta').readOnly = true;
			document.getElementById('nome-comercial-titular-conta').readOnly = true;
			document.getElementById('nome-titular-conta').readOnly = true;
			document.getElementById('endereco-titular-conta').readOnly = true;
			document.getElementById('telefones-titular-conta').readOnly = true;
			document.getElementById('emails-titular-conta').readOnly = true;

		} else {

			document.getElementById('titular-conta-locador').checked = false;
			document.getElementById('titular-conta-recebedor').checked = true;

		}

	}

}

function limparDadosTitular() {

	desabilitarPessoaJuridicaTitular(false, false, true);

	document.getElementById('titular-conta-locador').checked = false;
	document.getElementById('titular-conta-recebedor').checked = true;

	if (document.getElementById('tipo-documento-cnpj-titular-conta').checked) {

		document.getElementById('cnpj-titular-conta').disabled = '';
		document.getElementById('nome-comercial-titular-conta').disabled = '';
	}

	if (document.getElementById('tipo-documento-cpf-titular-conta').checked) {

		document.getElementById('cpf-titular-conta').value = '';
		document.getElementById('rg-titular-conta').value = '';
		document.getElementById('rg-oe-titular-conta').value = '';
		document.getElementById('genero-m-titular-conta').readOnly = true;
		document.getElementById('genero-f-titular-conta').readOnly = true;
		document.getElementById('estado-civil-titular-conta').value = '';
		document.getElementById('ocupacao-titular-conta').value = '';
		document.getElementById('naturalidade-titular-conta').value = '';
		document.getElementById('nacionalidade-titular-conta').value = '';

	}

	document.getElementById('nome-titular-conta').value = "";
	document.getElementById('endereco-titular-conta').value = "";
	document.getElementById('telefones-titular-conta').value = "";
	document.getElementById('emails-titular-conta').value = "";

	document.getElementById('nome-titular-conta').readOnly = false;
	document.getElementById('endereco-titular-conta').readOnly = false;
	document.getElementById('telefones-titular-conta').readOnly = false;
	document.getElementById('emails-titular-conta').readOnly = false;

	document.getElementById('tipo-documento-cnpj-titular-conta').checked = false;
	document.getElementById('tipo-documento-cpf-titular-conta').checked = true;

}

function liberarRepresentanteLegal() {

	document.getElementById("possue-representante-sim").checked = true;

	document.getElementById('cpf-representante').readOnly = false;
	document.getElementById('rg-representante').readOnly = false;
	document.getElementById('rg-oe-representante').readOnly = false;
	document.getElementById('estado-civil-representante').readOnly = false;
	document.getElementById('ocupacao-representante').readOnly = false;
	document.getElementById('naturalidade-representante').readOnly = false;
	document.getElementById('nacionalidade-representante').readOnly = false;
	document.getElementById('nome-representante').readOnly = false;
	document.getElementById('endereco-representante').readOnly = false;
	document.getElementById('telefones-representante').readOnly = false;
	document.getElementById('emails-representante').readOnly = false;

}

function bloquearRepresentanteLegal() {

	if (document.getElementById('tipo-documento-cpf').checked) {

		document.getElementById('cpf-representante').value = "";
		document.getElementById('rg-representante').value = "";
		document.getElementById('rg-oe-representante').value = "";
		document.getElementById('estado-civil-representante').value = "";
		document.getElementById('ocupacao-representante').value = "";
		document.getElementById('naturalidade-representante').value = "";
		document.getElementById('nacionalidade-representante').value = "";
		document.getElementById('nome-representante').value = "";
		document.getElementById('endereco-representante').value = "";
		document.getElementById('telefones-representante').value = "";
		document.getElementById('emails-representante').value = "";

		document.getElementById('genero-m-representante').checked = true;

		document.getElementById('cpf-representante').readOnly = true;
		document.getElementById('rg-representante').readOnly = true;
		document.getElementById('rg-oe-representante').readOnly = true;
		document.getElementById('estado-civil-representante').readOnly = true;
		document.getElementById('ocupacao-representante').readOnly = true;
		document.getElementById('naturalidade-representante').readOnly = true;
		document.getElementById('nacionalidade-representante').readOnly = true;
		document.getElementById('nome-representante').readOnly = true;
		document.getElementById('endereco-representante').readOnly = true;
		document.getElementById('telefones-representante').readOnly = true;
		document.getElementById('emails-representante').readOnly = true;

	}

}

function compararValoresAluguel(objeto, campo_1, campo_2) {

	valor_pgto = document.getElementById(campo_1).value;
	//alert("valor_pgto 1: " + valor_pgto);

	valor_total_pgto = document.getElementById(campo_2).value;
	//alert("valor_total_pgto 1: " + valor_total_pgto);

	valor_pgto = remove(valor_pgto, ".", "");
	//alert("valor_pgto 2: " + valor_pgto);
	valor_pgto = remove(valor_pgto, ",", ".");
	//alert("valor_pgto 3: " + valor_pgto);

	valor_total_pgto = remove(valor_total_pgto, ".", "");
	//alert("valor_total_pgto 2: " + valor_total_pgto);
	valor_total_pgto = remove(valor_total_pgto, ",", ".");
	//alert("valor_total_pgto 3: " + valor_total_pgto);

	valor_pgto = parseFloat(valor_pgto);
	//alert("valor_pgto 4: " + valor_pgto);

	valor_total_pgto = parseFloat(valor_total_pgto);
	//alert("valor_total_pgto 4: " + valor_total_pgto);

	if (valor_total_pgto > 0)
		if (valor_total_pgto < valor_pgto) {
			alert("O Valor Total está menor que o Valor do Pagamento Mensal!");
			objeto.value = "0,00";
			focarCampo(objeto);
		}

}

function validarSolicitarAluguel(nameform) {

	//Se a Unidade for nula
	if(document.getElementById('und-solicitante').selectedIndex == 0) {
		alert("Por favor selecione a Unidade!");
		return false;
	}

	//Se o Solicitante for nulo
	if (document.getElementById('solicitante').value == "") {
		alert("Por favor selecione o Solicitante!");
		return false;
	}

	/*
	//Se a FR for nula
	if(document.getElementById('fonte').selectedIndex == 0) {
		alert("Por favor selecione a Fonte de Recursos!");
		return false;
	}

	//Se a Ação for nula
	if(document.getElementById('acao').selectedIndex == 0) {
		alert("Por favor selecione a Ação!");
		return false;
	}
	*/

	//Se a Destinação do Imóvel for nula
	if (document.getElementById('destinacao-imovel').value == "") {
		alert("Por favor selecione a Destinação do Imóvel do Contrato!");
		return false;
	}

	//Se a Destinação do Imóvel for nula
	if (document.getElementById('destinacao-imovel').value == "OUTRAS") {
		if (document.getElementById('outras-destinacoes').value == "") {
			alert("Por favor digite a Destinação do Imóvel do Contrato!");
			return false;
		}
	}

	//Se o Endereço do Imóvel for nulo
	if(document.getElementById('endereco-imovel').value == "") {
		alert("Por favor digite o Endereço do Imóvel do Contrato!");
		return false;
	}

	//Se a Regional for nula
	if(document.getElementById('regional').selectedIndex == 0) {
		alert("Por favor selecione a Regional do Município onde está o Imóvel!");
		return false;
	}

	//Se o Município for nulo
	if(document.getElementById('municipio').value == "") {
		alert("Por favor selecione o Município onde está o Imóvel!");
		return false;
	}

	//Se a Descrição do Imóvel for nula
	if(document.getElementById('descricao-imovel').value == "") {
		alert("Por favor digite a Descrição do Imóvel do Contrato!");
		return false;
	}

	/*
	//Se a Melhoria do Imóvel for nula
	if(document.getElementById('melhorias-imovel').value == "") {
		alert("Por favor digite as Melhorias a serem feitas no Imóvel do Contrato!");
		return false;
	}
	*/

	//Se o Endereço do Imóvel for nulo
	if(document.getElementById('prazo-contrato').value == "") {
		alert("Por favor digite o Prazo do Contrato!");
		return false;
	}

	if (document.getElementById('data-inicio').value == "00/00/0000") {
		alert("Por favor selecione a data de início do contrato!");
		return false;
	}

	if (document.getElementById('data-fim').value == "00/00/0000") {
		alert("Por favor selecione a data de encerramento do contrato!");
		return false;
	}

	/*
	if(document.getElementById('dia-pgto').value == "") {
		alert("Por favor digite o dia do Pagamento Mensal!");
		return false;
	}

	dia_pgto = document.getElementById('dia-pgto').value;
	dia_pgto = parseInt(dia_pgto);

	if(dia_pgto < 1 || dia_pgto > 28) {
		alert("Por favor digite apenas valores entre 1 e 28 para o dia do Pagamento Mensal!");
		
	return false;
	}
	*/

	valor_pgto = document.getElementById('valor-pgto').value;
	valor_pgto = remove(valor_pgto,".", "");
	valor_pgto = remove(valor_pgto,",", ".");
	valor_pgto = parseFloat(valor_pgto);

	if (valor_pgto <= 0) {
		alert("Por favor digite o Valor do Pagamento Mensal!");
		return false;
	}

	valor_total_pgto = document.getElementById('valor-total-pgto').value;
	valor_total_pgto = remove(valor_total_pgto,".", "");
	valor_total_pgto = remove(valor_total_pgto,",", ".");
	valor_total_pgto = parseFloat(valor_total_pgto);

	if (valor_total_pgto <= 0) {
		alert("Por favor digite o Valor Total do Pagamento!");
		return false;
	}

	if (valor_pgto > valor_total_pgto) {
		alert("O Valor Total do Pagamento está menor que o Valor do Pagamento Mensal!");
		return false;
	}

	//Se o CPF ou CNPJ for nulo
	if (document.getElementById('tipo-documento-cpf').checked) {
		if(document.getElementById('cpf').value == "") {
			alert("Por favor digite o CPF da outra parte no Contrato!");
			return false;
		}
		//Se o RG for nulo
		if(document.getElementById('rg').value == "") {
			alert("Por favor digite o RG da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('rg-oe').value == "") {
			alert("Por favor digite o Orgão Emissor do RG da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('estado-civil').value == "") {
			alert("Por favor digite o Estado Civil da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('ocupacao').value == "") {
			alert("Por favor digite a Ocupação da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('naturalidade').value == "") {
			alert("Por favor digite a Naturalidade da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('nacionalidade').value == "") {
			alert("Por favor digite a Nacionalidade da outra parte no Contrato!");
			return false;
		}
	} else {
		if(document.getElementById('cnpj').value == "") {
			alert("Por favor digite o CNPJ da outra parte no Contrato!");
			return false;
		}
		/*
		if(document.getElementById('nome-comercial').value == "") {
			alert("Por favor digite o Nome Comercial (Fantasia) da outra parte no Contrato!");
			return false;
		}
		*/
	}

	//Se o Nome da outra parte for nulo
	if(document.getElementById('nome-outra-parte').value == "") {
		alert("Por favor digite o nome da outra parte no Contrato!");
		return false;
	}

	//Se o Endereço da outra parte for nulo
	if(document.getElementById('endereco-outra-parte').value == "") {
		alert("Por favor digite o Endereço da outra parte no Contrato!");
		return false;
	}



	if (document.getElementById('banco').value == "") {
		alert("Por favor digite o nome do Banco!");
		return false;
	}

	if (document.getElementById('agencia').value == "") {
		alert("Por favor digite o Código da Agência!");
		return false;
	}

	/*
	if (document.getElementById('agencia-digito').value == "") {
		alert("Por favor digite o dígito do Código da Agência!");
		return false;
	}
	*/

	if (document.getElementById('cc').value == "") {
		alert("Por favor digite o Código da Conta Corrente!");
		return false;
	}

	if (document.getElementById('cc-digito').value == "") {
		alert("Por favor digite o dígito do Código da Conta Corrente!");
		return false;
	}

	if (document.getElementById('titular-conta-recebedor').checked) {

		if (document.getElementById('tipo-documento-cpf-titular-conta').checked) {
			if (document.getElementById('cpf-titular-conta').value == "") {
				alert("Por favor digite o CPF do Titular da Conta!");
				return false;
			}

			if (document.getElementById('rg-titular-conta').value == "") {
				alert("Por favor digite o RG do Titular da Conta!");
				return false;
			}

			if (document.getElementById('rg-oe-titular-conta').value == "") {
				alert("Por favor digite o Orgão Emissor do RG do Titular da Conta!");
				return false;
			}

			if(document.getElementById('estado-civil-titular-conta').value == "") {
				alert("Por favor digite o Estado Civil do Titular da Conta!");
				return false;
			}
			if(document.getElementById('ocupacao-titular-conta').value == "") {
				alert("Por favor digite a Ocupação do Titular da Conta!");
				return false;
			}
			if(document.getElementById('naturalidade-titular-conta').value == "") {
				alert("Por favor digite a Naturalidade do Titular da Conta!");
				return false;
			}
			if(document.getElementById('nacionalidade-titular-conta').value == "") {
				alert("Por favor digite a Nacionalidade do Titular da Conta!");
				return false;
			}

			if (document.getElementById('nome-titular-conta').value == "") {
				alert("Por favor digite o nome do Titular da Conta!");
				return false;
			}

			if (document.getElementById('endereco-titular-conta').value == "") {
				alert("Por favor digite o endereço residencial do Titular da Conta!");
				return false;
			}
		} else {
			if(document.getElementById('cnpj-titular-conta').value == "") {
				alert("Por favor digite o CNPJ do Titular da Conta!");
				return false;
			}
			/*
			if(document.getElementById('nome-comercial-titular-conta').value == "") {
				alert("Por favor digite o Nome Comercial (Fantasia) do Titular da Conta!");
				return false;
			}
			*/
		}

	}



	if (document.getElementById('possue-representante-sim').checked ||
		document.getElementById('tipo-documento-cnpj').checked) {

		if (document.getElementById('cpf-representante').value == "") {
			alert("Por favor digite o CPF do Representante!");
			return false;
		}

		if (document.getElementById('rg-representante').value == "") {
			alert("Por favor digite o RG do Representante!");
			return false;
		}

		if (document.getElementById('rg-representante').value == "") {
			alert("Por favor digite o Orgão Emissor do RG do Representante!");
			return false;
		}

		if(document.getElementById('estado-civil-representante').value == "") {
			alert("Por favor digite o Estado Civil do Representante!");
			return false;
		}
		if(document.getElementById('ocupacao-representante').value == "") {
			alert("Por favor digite a Ocupação do Representante!");
			return false;
		}
		if(document.getElementById('naturalidade-representante').value == "") {
			alert("Por favor digite a Naturalidade do Representante!");
			return false;
		}
		if(document.getElementById('nacionalidade-representante').value == "") {
			alert("Por favor digite a Nacionalidade do Representante!");
			return false;
		}

		if (document.getElementById('nome-representante').value == "") {
			alert("Por favor digite o nome do Representante!");
			return false;
		}

		if (document.getElementById('endereco-representante').value == "") {
			alert("Por favor digite o endereço residencial do Representante!");
			return false;
		}

	}

	resposta = confirm("Você tem certeza que deseja submeter esta solicitação?");

	if (resposta) {
		return true;
	} else {
		return false;
	}

}

var permitir_validar_avaliar_aluguel = true;

function validarAvaliarAluguel() {

	//alert("Entrou!");

	if (permitir_validar_avaliar_aluguel) {

		if (document.getElementById("fonte") != null)
			if (document.getElementById("fonte").selectedIndex == 0) {
				alert("Por favor, selecione a Fonte de Recursos!");
				return false;
			}

		if (document.getElementById("acao") != null)
			if (document.getElementById("acao").selectedIndex == 0) {
				alert("Por favor, selecione a Ação!");
				return false;
			}

		/*
		if (document.getElementById('data-inicio').value == "00/00/0000") {
			alert("Por favor selecione a data de início do contrato!");
			return false;
		}

		if (document.getElementById('data-fim').value == "00/00/0000") {
			alert("Por favor selecione a data de encerramento do contrato!");
			return false;
		}
		*/

		if (document.getElementById('data-celebracao').value == "00/00/0000") {
			alert("Por favor selecione a data de Celebração do Contrato!");
			return false;
		}

	}

	resposta = confirm("Você tem certeza que deseja submeter esta avaliação?");

	if (resposta) {
		window.document.formulario_avaliar_aluguel.submit();
	} else {
		return false;
	}

}

var permitir_empenhar_aluguel = false;

function empenharAluguel() {

	/*
	if (document.getElementById('empenhado').value == "nao") {
		alert("Esta Solicitação de Aluguel ainda não foi empenhada!\nPara submeter esta avaliação empenhe-a,\nou encaminhe-a a um usuário que tenha permissão para\nEmpenhar Solicitações de Aluguel!");
		return false;
	}
	*/

	if (permitir_empenhar_aluguel) {

		if (document.getElementById('data-emissao').value == "00/00/0000") {
			alert("Por favor selecione a data de emissão do Empenho!");
			return false;
		}

		if (document.getElementById('nota-empenho').value == "") {
			alert("Por favor digite a Nota de Empenho!");
			return false;
		}

		valor_empenho = document.getElementById('valor-empenho').value;
		valor_empenho = remove(valor_empenho,".", "");
		valor_empenho = remove(valor_empenho,",", ".");
		valor_empenho = parseFloat(valor_empenho);
		//alert(valor_empenho);

		if (valor_empenho <= 0) {
			alert("Por favor digite o Valor do Empenho!");
			return false;
		}

	}

	resposta = confirm("Você tem certeza que deseja submeter este empenho?");

	if (resposta) {
		window.document.formulario_avaliar_aluguel.submit();
	} else {
		return false;
	}

}

var permitir_realizar_tarefa_contrato_aluguel = false;

function realizarTarefaContratoAluguel(tipo, texto_1, texto_2) {

	//alert("Entrou!");

	if (permitir_realizar_tarefa_contrato_aluguel) {

		var arrayElements = document.getElementsByTagName('input');

		existe_checks = false;
		existe_checks_validos = false;

		for (var i = 0; i < arrayElements.length; i++) {
			if (arrayElements[i].type == 'radio') {
				if (arrayElements[i].checked == true) {
					existe_checks = true;
					if (arrayElements[i].id.indexOf(tipo) != -1) {
						existe_checks_validos = true;
					}
				}
			}
		}

		if (!existe_checks) {
			alert(texto_1)
			return false;
		}

		if (!existe_checks_validos) {
			alert(texto_2)
			return false;
		}

	}

	resposta = confirm("Você tem certeza que deseja submeter esta requisição?");

	if (resposta) {
		window.document.formulario_gerar_contrato_aluguel.submit();
	} else {
		return false;
	}

}
