var XEUtils = {};

/**
 * Checks a HTML form for any elements with a mandatory class, then adds an error class
 * to any which don't have a value. It then returns false if there are any errors.
 */
XEUtils.checkForm = function(form) {
  var mandatory = form.getElementsBySelector(".mandatory");
    
    var errors = mandatory.select(function (i) {
      if(!$F(i)) {
        i.addClassName("error");
        return true;
      } else {
        i.removeClassName("error");
        return false;
      }
    });
    
    return errors.size() == 0;
}