$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

    //para las demas campanas en la pagina campna
    
  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var email = $("#email").val();
if (email == "" || !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
      $("label#email_g_error").show();
      $("#email").focus();
      return false;
    }

		var email_amigos = $("#email_amigos").val();
		if (email_amigos == "") {
      $("label#email_g_error").show();
      $("#email_amigos").focus();
      return false;
    }
		var comentarios_folleto = $("#comentarios_folleto").val();
                var id_campana = $("#id_campana").val();
                var LANG_ID = $("#LANG_ID").val();
		var dataString = 'email='+ email + '&email=' + email + '&email_amigos=' + email_amigos+'&comentarios_folleto='+comentarios_folleto+'&id_campana='+id_campana
                +'&LANG_ID='+LANG_ID;
		$.ajax({
      type: "POST",
      url: "/mail/process.php",
      data: dataString,
      success: function() {
        $('#inline1').html("<div id='message'></div>");
        $('#message').html("<img style='float: left;' id='checkmark' src='/images/check.png' />");
        $('#message').append("<h2>Folleto enviado con exito!</h2>")
        .append("<p>Gracias.</p>")
        .hide()
        .fadeIn(1500, function() {
         ;
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#email").select().focus();
});

