// JavaScript Document
function efetuarlogin(){
	var enviar = true;
	var email = document.getElementById('email').value;
	var senha = document.getElementById('senha').value;
	
	if(estaVazio(email) || estaVazio(senha)){
		alert("Preencha corretamente os campos!");
		enviar = false;
	} else if(!emailValido(email)){
		alert("Email inválido!");
		enviar = false;
	}
	
	return enviar;
}

function cadastrarme(){
	var email = document.getElementById('email').value;
	
	redirecionar("cadastro");
	if(!estaVazio(email) || emailValido(email)){
		novoCampo = document.createElement("input");
		novoCampo.setAttribute("type", "hidden");
		novoCampo.setAttribute("name", "email");
		novoCampo.setAttribute("id", "email");
		novoCampo.setAttribute("value", email); 
		document.getElementById('redirecionador').appendChild(novoCampo);
	}	
	
	document.getElementById('redirecionador').submit();
}

function esqueciminhasenha(){
	var email = document.getElementById('email').value;

	if(!estaVazio(email) || emailValido(email)){
		enviarpara('controles/controle_esquecisenha.cfm');
		novoCampo = document.createElement("input");
		novoCampo.setAttribute('type', "hidden");
		novoCampo.setAttribute('name', "email");
		novoCampo.setAttribute('id', "email");
		novoCampo.setAttribute('value', email);
		document.getElementById('enviarpara').appendChild(novoCampo);
		document.getElementById('enviarpara').submit();
	} else {
		alert("Por favor, informe o email!");	
	}
}

function abriraula(id){
	var pop = popup('controles/controle_abrirconferencia.cfm?idconferencia='+id,'800','600','abrirconferencias','');
}

function vercomentarios(){
	redirecionar("comentarios");	
	document.getElementById('redirecionador').submit();
}

function reload(form_name){
	var form = document.getElementById(form_name);
	form.action='index.cfm?ver=cadastro';
	form.submit();
}

function acaoprofissao(campo){
	if(campo.options[campo.selectedIndex].value==8){
		document.getElementById('descprofissao').style.display='block';
	}else{
		document.getElementById('descprofissao').style.display='none';
	}
}

function cadastrar(){
	var form = document.getElementById('cadastro');
	var erro = "";
	
	if(estaVazio(document.getElementById('nome').value)){
		erro = "nome";
	}
	if(document.getElementById('pais').value=='BR'){
		if(document.getElementById('estado').selectedIndex==0){
			erro += ", estado";
		}
	}
	if(estaVazio(document.getElementById('cidade').value)){
		erro += ", cidade";
	}
	if(document.getElementById('profissao').selectedIndex==0){
		erro += ", profissão";
	}
	if(estaVazio(document.getElementById('email').value) 
		|| !emailValido(document.getElementById('email').value)
		|| document.getElementById('email').value != document.getElementById('email2').value){
		erro += ", e-mail";
	}
	if(estaVazio(document.getElementById('senha').value)
		|| document.getElementById('senha').value != document.getElementById('senha2').value){
		erro += ", senha";
	}
	
	if(erro==""){
		form.action='controles/controle_cadastro.cfm';
		form.submit();
	} else {
		alert("Foram encontrados erros nos seguintes campos:\n"+erro+".");
	}
}

function mostrarDia(dia,obj){
	if(dia=="todos"){
		escondeMostraTodosDias('block');
	}else {
		escondeMostraTodosDias('none');
		document.getElementById(dia+'DAY').style.display='block';
	}
	retirarCssMenuDias();
	obj.className='dia_selecionado';
}

function escondeMostraTodosDias(param){
	document.getElementById('25DAY').style.display=param;
	document.getElementById('26DAY').style.display=param;
	document.getElementById('27DAY').style.display=param;
}

function retirarCssMenuDias(){
	document.getElementById('menudia25').className='dia_deselecionado';
	document.getElementById('menudia26').className='dia_deselecionado';
	document.getElementById('menudia27').className='dia_deselecionado';
	document.getElementById('menudiatodos').className='dia_deselecionado';
}