﻿/// <reference path="~/src/mootools-1.2-core.js"/>
/// <reference path="~/src/mootools-1.2-more.js"/>
(function () {

    try {
        (function () {
            if (!window.Controls) window.Controls = {};
            window.Controls.CommonDialog = {
                get: function (params) {
                    var params = typeof params == 'string' ? { name: params} : params || {};
                    var type = params.type || 'server';
                    var name = params.name || '';
                    //tl00_ctl00_b_b_cd1_commonDialog
                    if (name) {
                        if (type == 'server') {
                            return $E('div.container_dialog[id$=' + name + '_commonDialog]');
                        }
                        else return $(name);
                    }
                    else return $$('div.container_dialog[id*=commonDialog]');
                }
            };

            (function () {

                function show() {
                    if (typeof (DialogOverlay) != undefined && DialogOverlay != null) {
                        DialogOverlay.show();
                    }

                    this.showCentered();
                };

                function hide() {
                    if (typeof (DialogOverlay) != undefined && DialogOverlay != null) {
                        DialogOverlay.hide();
                    }

                    this.setStyle('display', 'none');
                };


                var dialogs = Controls.CommonDialog.get();
                if (dialogs && dialogs.length) {
                    dialogs.each(function (i) {
                        i.show = show;
                        i.hide = hide;
                    });
                }

            } ());

        }).register();

        if (typeof (Sys) != 'undefined' && typeof (Sys.Application) != 'undefined')
            Sys.Application.notifyScriptLoaded();
    }
    catch (_ex) {
        return _ex;
    }

} ());