
var ApplicationBulletin = (function() {

    var debugOn = false;
    var oldOnLoad;
    var isPageValid = true;
    var dnnForm = document.forms['Form'];
    if (!dnnForm) dnnForm = document.Form;

    function JSErrorHandler(msg, url, l) {
        if (debugOn) {
            mens = "Ocorreu um erro na página.\n\n".concat(
                "Erro: " + msg + "\n").concat(
                "URL: " + url + "\n").concat(
                "Linha: " + l + "\n\n").concat(
                "Clique OK para continuar.\n\n");
            alert(mens);
            return true;
        }
    };

    function Page_Load() {

        if (oldOnLoad != null) try { oldOnLoad(); } catch (e) { e = null; }
        if (debugOn) onerror = JSErrorHandler;

        // code goes bellow
        try {

        }
        catch (e) {
            window.status = "ApplicationBulletin load exception: ".concat(e.message);
        }
    };

    return {

        Toggle: function(ctlId, status) {
            var ctl = $(ctlId);
            ctl.style.display = (status == "on" ? "block" : "none");
        },


        CvOtherCEDs_ClientValidation: function(sender, args) {
            if ($("trOtherCED").style.display == "none")
                args.IsValid = true;
            else
                args.IsValid = (args.Value != "");
        },

        CvIrmCpl_ClientValidation: function(sender, args) {
            if ($("tdIrmLoc").style.display == "none")
                args.IsValid = true;
            else
                args.IsValid = (args.Value != "");
        },

        //cvAcohInstLoc_ClientValidation: function(sender, args){
        //    if ($("tdAcohInstLoc").style.display == "none")
        //        args.IsValid = true;
        //    else
        //        args.IsValid = (args.Value != "");
        //},

        Initialize: function(debugModeOn) {

            //save events
            oldOnLoad = window.onload;

            //initializing
            debugOn = debugModeOn;

            //override events
            window.onload = Page_Load;
        }
    }
})();
