﻿CO.Form = function (config) {

    if (!config) config = new Object();

    this.url = config.url;
    this.urlLoad = config.urlLoad;

    this.submit = function (callbackOK, callbackErro) { CO.FormRotinas.submit(config.formId, config.url, callbackOK, callbackErro); }
    this.load = function (id, callbackOK, callbackErro) { CO.FormRotinas.load(id, config.formId, config.urlLoad, callbackOK, callbackErro); };
    this.limpar = function () { CO.FormRotinas.limpar(CO.el(config.formId)); };
    this.mensagemAlerta = function (msg) {
        if (config.mensagemAlerta) {
            config.mensagemAlerta(msg);
        }
        else {
            CO.mensagem(msg, 'alerta');
        }
    };
    this.definirAtributosCampo = function (objConfig) {
        CO.FormRotinas.definirAtributosCampo(config.formId, objConfig);
    };
    this.definirEventos = function () {
        CO.FormRotinas.definirEventos(config.formId);
    };
    this.limparAlerta = function () {
        CO.FormRotinas.limparAlerta(config.formId);
    };
    this.campo = function (nomeCampo) { return CO.FormRotinas.campo(config.formId, nomeCampo); };
    this.obterListaCamposComando = function () { return CO.FormRotinas.obterListaCamposComando(config.formId); };
    this.formId = config.formId;
}
