(function($){
	$.Informativo = {

		__constructor : function(){
			var me = this;
			me.initConfig();
			
			// targets (bind em elementos passando o evento)
			$('.informativo_cadastrar').click(function(e){
				me.cadastrarEmail(e);
				return false;
			});
		},
		
		pegarCampo : function(e, campo){
			var me = this;
			return $(e.target).parents('form').find('input[name="'+campo+'"]').val();
		},

		pegarCampoCheck : function(e, campo){
			var me = this;
			return $(e.target).parents('form').find('input[name="'+campo+'"]:checked').val();
		},

		validarEmail : function(e){
			var me = this;
			var email = me.pegarCampo(e, "m1");
			return validarEmail(email) && email != "Informativo por e-mail";
		},

		emitirAlerta : function(mensagem, campo){
			alert(mensagem);
			$('#'+campo).focus();
		},

		cadastrarEmail : function(e){
			var me = this;
			var nome = me.pegarCampo(e, "nome");
			var acao = me.pegarCampoCheck(e, "acao");
			if(acao != "" && typeof acao != "undefined"){
				if(nome != ""){
					if(me.validarEmail(e)){
						var m1 = me.pegarCampo(e, "m1");
						$.get('informativo',{m1:m1,nome:nome,acao:acao},function(msg){
							alert(msg); // alerta a mensagem de erro ou de sucesso
						});
					} else {
						me.emitirAlerta('Digite o seu email corretamente', "m1");
					}
				} else {
					me.emitirAlerta('Digite o seu nome', "nome");
				}
			} else {
				me.emitirAlerta('Selecione uma ação', "acao");
			}
		},

		initConfig: function() {
			
		}

	}
})(jQuery);

$(function(){
	$.Informativo.__constructor();
})