// Plugin validar campos de formularios
// Autor: Giorgio Caldeira - giorgio@2clicks.com.br


$.fn.formmin = function(settings) {
  var defaults = {
    href: 'editar.html',
    paramName: 'id'
  }

  settings = $.extend(defaults, settings); // sobrepoe defaults
  $this = $(this);

         $(this).submit(function() {
            $("label").css("color","#fff");
            falha = false;
            i = 0;
            $("input.required,select.required").each(function() {
                if ( ! $(this).val()) {
                  //campo = $(this).attr("name");
                  //$("label[@for="+campo+"]").css("color","red");
                  $(this).css("border-bottom","dotted 1px red");
                  falha = true;
                  i = i + 1;
                  };

            });
            if (!falha) {
                 $.post("contato.php",jQuery("#f-contato").serialize(),  function(data){
                        $('#msg').html(data);
                        $('#msg').show();
                        $('#f-contato')[0].reset();
                        setTimeout(function(){ $('#msg').slideUp('fast') },10000);
                 });
               };
            return false;
            } );

  return $this;
}
