// JavaScript Document
function Valida_Cadastro(){
	if ((document.getElementById('nome_cadastro').value == '') || (document.getElementById('nome_cadastro').value == 'Nome')){
		alert('Informe o Nome!');
		document.getElementById('nome_cadastro').focus();
		return false;
	}
	if ((document.getElementById('email_cadastro').value == '') || (document.getElementById('email_cadastro').value == 'E-mail')){
		alert('Informe o E-mail!');
		document.getElementById('email_cadastro').focus();
		return false;
	}
	else{
		if (!Validar_Email(document.getElementById('email_cadastro').value)) {
			alert("Informe um E-mail válido!");
			document.getElementById('email_cadastro').focus();
			return false;
		}
	}
	return true;
}

var arInputFocus = [{id:"nome_cadastro",value:"Nome"},
					{id:"email_cadastro",value:"E-mail"},
					{id:"login_associado",value:"Login"},
					{id:"senha_associado",value:"Senha"},
					{id:"login_esqueci_ass",value:"Login"},
					{id:"email_esqueci_ass",value:"E-mail"},
					{id:"busca_espaco",value:"Pesquise Aqui"}
					];

function inputFocus(inputObj){
	var found  = false;
	for (var i in arInputFocus) {
		if (arInputFocus[i].id == inputObj.id){
			found  = true;
			break;
		}
	}
	if (found){
		if (inputObj.value == arInputFocus[i].value) {
			//remove valor inicial
			inputObj.value = "";
		}
	}
}
function inputBlur(inputObj){
	var found  = false;
	for (var i in arInputFocus) {
		if (arInputFocus[i].id == inputObj.id){
			found  = true;
			break;
		}
	}
	if (found){
		if (inputObj.value.trim() == "") {
			//insere novamente valor inicial pois estava vazio
			inputObj.value = arInputFocus[i].value;
		}
	}
}
function enviaForm(){
	if(Valida_Cadastro()){
	//document.getElementById("form_cadastro").submit();
	document.form_cadastro.submit();

	}	
}

function alertEspAssociado(mensagem){
		document.getElementById("msg_associado").style.display = '';
		document.getElementById("msg_associado").innerHTML = mensagem;
}
function loginAssociado(){
	document.getElementById("msg_associado").style.display = 'none';
	if((document.getElementById("login_associado").value == "") || (document.getElementById("login_associado").value == "Login")){
		alertEspAssociado("Digite seu login!");
		document.getElementById("login_associado").focus();
		return false;
	}
	if((document.getElementById("senha_associado").value == "") || (document.getElementById("senha_associado").value == "Senha")){
		alertEspAssociado("Digite a senha!");
		document.getElementById("txt_pasenha_associadossword").focus();
		return false;
	}
	document.form_associado.submit();
}
function erroLoginAssociado(){
	document.getElementById("senha_associado").value = "";
	alertEspAssociado("Login / Senha incorreto!");
}

function mostraDivEsqueci(){
	document.getElementById("div_esqueci_senha").style.display = '';
}

function escondeDivEsqueci(){
	document.getElementById("div_esqueci_senha").style.display = 'none';
}

function alertEsqueciAssociado(mensagem){
		document.getElementById("msg_esq_associado").style.display = '';
		document.getElementById("msg_esq_associado").innerHTML = mensagem;
}
function esqueciSenhaAssociado(){
	document.getElementById("msg_associado").style.display = 'none';
	if((document.getElementById("email_esqueci_ass").value == "") || (document.getElementById("email_esqueci_ass").value == "E-mail")){
		alertEsqueciAssociado("Digite e-mail relacionado com o login do usuário!");
		document.getElementById("email_esqueci_ass").focus();
		return false;
	}
	if((document.getElementById("login_esqueci_ass").value == "") || (document.getElementById("login_esqueci_ass").value == "Login")){
		alertEsqueciAssociado("Digite o login do usuário!");
		document.getElementById("login_esqueci_ass").focus();
		return false;
	}
	document.form_esqueci_associado.submit();
	
}
