Author = Class.create(ModalEditable, {

    name: 'author',
    validFields: [],

    validations: {
        name: [Validate.Presence],
        cnp:  [Validate.Presence, Validate.CNP]
    },

    initialize: function ($super) {
        this.template = new Template(
           '<dd id="invoice-author-name"><strong>Intocmit de:</strong> <span>#{name}</span></dd> \
            <dd id="invoice-author-cnp"><strong>CNP:</strong> <span>#{cnp}</span></dd> \
            <dd><strong>Semnatura si stampila furnizorului</strong></dd>'
        );

        this.attachDialog();

        $super();        
    },

    attachDialog: function () {
        this.dialog = new Dialog({
            handle: '#edit-author-handle',
            title: $('edit-author-handle').title,
            target: {
                id: 'edit-author',
                auto: true
            },

            /**
             * Destroy validation instances
             */
            beforeClose: (function () {
                this.destroyValidations();
            }).bind(this),

            /**
             * Attach validation instances
             */
            afterOpen: (function () {
                this.form  = $('dialog-content').down('#invoice-author-form');

                this.addValidations();
                this.populateForm();                
            }).bind(this)
        });
    },

    update: function ($super, data) {
        $super(data);

        $('invoice-author').down('dl.details').update(this.template.evaluate(data));

        for (var field in this.data) {
            if (!this.data[field]) {
                $('invoice-author' + '-' + field).addClassName('empty');
            }
            $('author_' + field).value = this.data[field];
        }
    }
});