var Entidade = {
	acoes : "Entidades/Entidades.actions.php?",
	
	// recarrega o componente Cadastro Associado
	regarregar:function(){
		location = 'index.php?Area-Restrita&cpt=25';
	},	
	login:function(form){
		$j.alert({
			type:'loading', hide:false, modal:true, width:200,
			html:'Efetuando login, aguarde...'
		});
		
		if(form.email.value == "email" || form.senha.value == "senha") {
			$j.alert({
				type: 'error', timeout: 5000, width:450,
				html: 'Para efetuar login, preencha corretamente o formul�rio!'
			})
		}else{
			$j.ajax({
				url: this.acoes+'login', type: 'post', data: $j(form).serialize(),
				success: function(response){
					//alert(response);
					if(response == "logado"){
						$j.alert({
							type:"success", html:'Login efetuado com sucesso, aguarde...', modal:true, timeout:5000, out:Entidade.regarregar()
						});
					}else if(response == "inativo"){
						$j.alert({type:'alert', html:'Seu cadastro se encontra inativado. Entre em contato com a Federa&ccedil;&atilde;o.', timeout:6000});
					}else if(response == "naoFiliada"){
						$j.alert({type:'error', html:'Voc&ecirc; n&atilde;o tem acesso a est&aacute; &aacute;rea.', timeout:6000});
					}else{
						$j.alert({
							type:'error', modal:false, width:450,
							html:'Erro ao efetuar login. Verifique os dados digitados e tente novamente.', timeout:6000
						});
					}
					
				}
			});
		}
		return false;
	},	
	logout:function(){
		$j.alert({type:'loading', html:'Efetuando Logout, aguarde...', hide:false, modal:true});
		$j.ajax({
			url: this.acoes+'logout',
			success: function(response){
				location = "index.php";
			}
		});
	}
}
