How do I control if an ajax webform has errors? I have a webform that sends an email upon submission. Ajax is enabled so when I hit submit and there are errors on the form they will show instantly. However if there are no errors I would like to hide the form along with the success message.

Some pseudo code (sort of):

Drupal.behaviors.sendMail = {
  attach: function (context) {

    $('#webform-client-form-340', context).ajaxComplete(function(event, xhr, settings) {
      if ($('.alert-errors').length == 1) {
        thisForm.highLight()
      } else {
        thisForm.hide();
      }
    });

  }
};


This doesn't work because the .alert-errors div is not yet there on ajaxComplete. 
So how do I check for errors, highlight the form if they are present and otherwise hide the form?
I when I normally have to debug this I use 

Debugging ajax with FIREPHP


  Explaines how you can debug ajax with FIREPHP