$(function() {
  $('.errores').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"});
  });
 $('textarea.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  $('textarea.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $(".buttones2").click(function() {
		// validate and process form
		// first hide any error messages
    $('.errores').hide();
		
	  var name = $("input#dependencia").val();
		if (name == "") {
      $("label#name_errores").show();
      $("input#dependencia").focus();
      return false;
    }
		var email = $("input#tema").val();
		if (email == "") {
      $("label#email_errores").show();
      $("input#tema").focus();
      return false;
    }
	
	var comentarios = $("textarea#mensaje").val();
	if (comentarios == "") {
      $("label#phone_errores").show();
      $("textarea#mensaje").focus();
      return false;
    }
	
	var dataString = 'dependencia='+name+'&tema='+email +'&mensaje='+ comentarios;
		//alert (dataString);return false;
		
	  $.ajax({
      type: "POST",
      url: "controlador/enviarQueja.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Informaci&oacute;n Enviada!</h2>")
        .append("<p>Muchas Gracias.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='imagenes/check.gif' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#dependencia").select().focus();
});
