var PageForm = Class.create({
  initialize: function() {
    this.errors = [];
    this.messageTemplate = new Template('<p class="#{className}">#{message}</p>');
  },
  addError: function(error) {
    this.errors.push(error);
  },
  hasErrors: function() {
    return this.errors.size() > 0;
  },
  showErrors: function(containerId) {
    if (!$(containerId)) {
      alert("No target container ID specified for showing of errors");
      return;
    }
    this.errors.each(function(error) {
      $(containerId).appendChild(Builder.node('p', {className: 'error'}, error));
      //this.addMessage(containerId, error, 'error');
    });
  },
  addMessage: function(containerId, text, className) {
    var message = new Element('p', {className: className});
    message.update(text);

    $(containerId).update(message);
  },
  clearErrors: function() {
    this.errors.clear();
  }
});
