function RepositorioBase(p) {
    var mSelf = this,
		ajaxReturn = false,
	    o = null;

    function beforeSendDefault(jqXHR, settings) {
    }

    function successDefault(data, textStatus, jqXHR) {
    }

    function errorDefault(jqXHR, textStatus, errorThrown) {
        var msg = "Erro no servidor:\n";
        msg += "Status: " + textStatus + "\n";
        msg += "error: " + errorThrown + "\n";
        mSelf.log(msg);
    }

    function doneDefault() {
    }

    function callAjax(t) {
        try {
            var options = {
                url: urlGlobal,
                type: t.toUpperCase(),
                data: mSelf.params,
                success: mSelf.success,
                error: mSelf.error,
                beforeSend: mSelf.beforeSend
            },
                url = mSelf.urlBase + "/";
            if (mSelf.UsarUrlComplemento) {
                url += mSelf["url" + t];
            }
            options.url += url;

            options.url = options.url.replace("//", "/");

            if (mSelf.contentType) {
                options.contentType = mSelf.contentType;
            }

            $.ajax(options).done(mSelf.done);
        } catch (e) {
            var msg = "Erro: \n\n";
            msg += "Message: " + e.message + "\n";
            msg += "Stack: " + e.stack;
            mSelf.log(msg);
        }
    }

    p = checkValue(p, arguments[0]);
    o = checkValue(p, {});

    // propriedades
    mSelf.urlBase = checkValue(o.urlBase, "");
    mSelf.urlGet = checkValue(o.urlGet, "Get");
    mSelf.UsarUrlComplemento = checkValue(o.UsarUrlComplemento, false);
    mSelf.urlPost = checkValue(o.urlPost, "Post");
    mSelf.urlPut = checkValue(o.urlPut, "Put");
    mSelf.urlDelete = checkValue(o.urlDelete, "Delete");
    mSelf.contentType = checkValue(o.contentType, "");
    mSelf.params = checkValue(o.params, {});

    mSelf.success = checkValue(o.success, successDefault);
    mSelf.error = checkValue(o.error, errorDefault);
    mSelf.beforeSend = checkValue(o.beforeSend, beforeSendDefault);
    mSelf.done = checkValue(o.done, doneDefault);

    mSelf.get = function (parameters) {
        mSelf.params = checkValue(parameters, mSelf.params);
        callAjax("Get");
    };

    mSelf.post = function (parameters) {
        mSelf.params = checkValue(parameters, mSelf.params);
        callAjax("Post");
    };

    mSelf.put = function (parameters) {
        mSelf.params = checkValue(parameters, mSelf.params);
        callAjax("Put");
    };

    mSelf.del = function (parameters) {
        mSelf.params = checkValue(parameters, mSelf.params);
        callAjax("Delete");
    };

    mSelf.call = function (action) {
        callAjax(action);
    };

    mSelf.log = function (msg) {
        var m = new Date().format("yyyy-MM-dd h:mm:ss.S: ");
        m += this.constructor.name;
        m += " => " + msg;
        try {
            console.log(m);
            alert(m);
        } catch (e) {
            document.write(m.replace(/\\n/g, "<br />"));
        }
    };
}