var trocaObjeto = {
	base_url: null,
	txtusuario: null,
	txtsenha: null,
	txtid: null,
	
	fadeIn:function(id) {
		target = document.getElementById(id);
		
		if($(target)){
			$(target).fadeIn(500);
		}
	},
	
	fadeOut:function(id) {
		this.base_url = null;
		this.txtusuario = null;
		this.txtsenha = null;
		this.txtid = null;
		$('#txtusuario').val("");
		$('#txtsenha').val("");
		
		target = document.getElementById(id);
		
		if($(target))
			$(target).fadeOut(250);
	},
	
	fadeTrade:function(objeto1, objeto2) {
		target = document.getElementById(objeto1);
		target2 = document.getElementById(objeto2);
		
		if($(target))
			$(target).fadeOut(500);
			
		if($(target2))
			$(target2).fadeIn(700);
	},
	
	enviarSenha:function(base_url){
		this.base_url = base_url;
		this.txtusuario = $('#txtemail').val();
		
		if(this.txtusuario.length == 0){
			$('#alerta_erro_senha').show();
			$('#alerta_erro_senha').html("<img src="+(trocaObjeto.base_url)+"/publico/ack/imgs/exclamacao_pequena.png> Preencha o campo com um e-mail válido.");
			$('#txtemail').val("");
			$('#txtemail').focus();
			this.txtusuario = "";
			return false;
		}
		
		$('#at_senha').load(trocaObjeto.base_url+'welcome/enviarSenhaSite/'+trocaObjeto.txtusuario,function(str){
			$('#alerta_erro_senha').show();
			var erro = $('#at_senha').html();			
			
			if(erro==1){
				$('#alerta_erro_senha').html("<img src="+(trocaObjeto.base_url)+"/publico/ack/imgs/successo_pequeno.png> Informações enviadas com sucesso...");
			}else{
				$('#alerta_erro_senha').html("<img src="+(trocaObjeto.base_url)+"/publico/ack/imgs/exclamacao_pequena.png> Erro ao enviar informações, tente novamente!!");
				$('#txtemail').val("");
				$('#txtemail').focus();
				trocaObjeto.txtusuario = "";
				return false;
			}
		});
	},
	
	
	validaLoginRestrito:function(base_url){
		this.base_url = base_url;
		this.txtusuario = $('#txtusuario').val();
		this.txtsenha = $('#txtsenha').val();
		
		if(this.txtusuario.length == 0 || this.txtsenha.length == 0){
			$('#alerta_erro').show();
			$('#alerta_erro').html("<img src="+(trocaObjeto.base_url)+"/publico/ack/imgs/exclamacao_pequena.png> Nenhum dos campos podem ficar em branco.");
			$('#txtusuario').val("");
			$('#txtsenha').val("");
			$('#txtusuario').focus();
			return false;
		}
		$('#at').load(trocaObjeto.base_url+'welcome/validaLoginRestrito/'+trocaObjeto.txtusuario+'/'+trocaObjeto.txtsenha,function(str){
			$('#alerta_erro').show();
			trocaObjeto.txtid = $('#at').html();
			
			if(trocaObjeto.txtid > 0){
				$('#alerta_erro').html("<img src="+(trocaObjeto.base_url)+"/publico/ack/imgs/successo_pequeno.png> Registrando usuario...");
				setTimeout(function() { 
					window.location=trocaObjeto.base_url+"welcome/acessoRestrito"; 
			    }, 2000);
			}else{
				$('#alerta_erro').html("<img src="+(trocaObjeto.base_url)+"/publico/ack/imgs/exclamacao_pequena.png> Usuario ou senha invalido, tente novamente!!");
				$('#txtusuario').val("");
				$('#txtsenha').val(""); 
				$('#txtusuario').focus();
				return false;
			}
		});
	}
}





