//<![CDATA[
var MMM_Popup =
{
    clientWidth: ''
    , clientHeight: ''

    , Show: function(popupId)
    {
        //Effects.ChangeOpacity(0, popupId);
        //Effects.ChangeOpacity(0, popupId + '_bg');
        $(popupId).style.visibility = "visible";
        $(popupId + '_bg').style.visibility = "visible";
        //Effects.Fade(popupId, 0, 100, 400);
        //Effects.Fade(popupId + '_bg', 0, 50, 400);
    }

    , Hide: function(popupId)
    {
        //Effects.Fade(popupId, 100, 0, 400);
        //Effects.Fade(popupId + '_bg', 50, 0, 400);
        setTimeout('$("' + popupId + '").style.visibility = "hidden";$("' + popupId + '_bg").style.visibility = "hidden";', 100);

    }

    , BdvGetClientBounds: function()
    {
        if (!Sys)
            return;

        switch (Sys.Browser.agent)
        {
            case Sys.Browser.InternetExplorer:
                this.clientWidth = document.documentElement.clientWidth;
                this.clientHeight = document.documentElement.clientHeight;
                break;
            case Sys.Browser.Safari:
                this.clientWidth = window.innerWidth;
                this.clientHeight = window.innerHeight;
                break;
            case Sys.Browser.Opera:
                this.clientWidth = Math.min(window.innerWidth, document.body.clientWidth);
                this.clientHeight = Math.min(window.innerHeight, document.body.clientHeight);
                break;
            default:
                this.clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
                this.clientHeight = Math.min(window.innerHeight, document.documentElement.clientHeight);
                break;
        }
        return new Sys.UI.Bounds(0, 0, MMM_Popup.clientWidth, MMM_Popup.clientHeight);
    }
    , SetCustomModalPopupContent: function()
    {
        if (!Sys)
            return;

        var elm = document.getElementsByTagName("div");
        for (var i = 0; i < elm.length; i++)
        {
            if (elm[i].className == "customModalPopupContent")
            {
                elm[i].style.left = (MMM_Popup.BdvGetClientBounds().width / 2) - (elm[i].offsetWidth / 2) + "px";

                if (elm[i].style.top != "20px")
                    elm[i].style.top = (MMM_Popup.BdvGetClientBounds().height / 2) - (elm[i].offsetHeight / 2) + "px";

                if ((elm[i].offsetHeight) > MMM_Popup.BdvGetClientBounds().height - 50)
                {
                    elm[i].style.top = "20px";
                    if (elm[i].offsetHeight >= MMM_Popup.BdvGetClientBounds().height)
                    {
                        elm[i].style.position = "absolute";
                        elm[i].style.left = ((MMM_Popup.BdvGetClientBounds().width / 2) - (elm[i].offsetWidth / 2)) + "px";
                    }
                }
            }
        }
    }
}

//]]>
