
////////////////////////////////////////////////////////////////////////////////////////////////////
// Overlay
////////////////////////////////////////////////////////////////////////////////////////////////////
	
var Overlay = 
{
    id: 'overlay',
    shadeId: 'overlay-shade',
    visible: false,
    
    init: function()
        {
            var onload = window.onload;
            window.onload = function()
                {
                    onload();
                    Overlay.update();
                }	            
            
            var onresize = window.onresize;
            var onscroll = window.onscroll;
            window.onresize = function()
                {
                    if (onresize)
                        onresize();
                    Overlay.update();
                };
            window.onscroll = function()
                {
                    if (onscroll)
                        onscroll();
                    Overlay.update();
                }
        },
    
    update: function()
        {
            if (Overlay.visible && document.body)
            {
                var shade = document.getElementById(Overlay.shadeId);
                var bodyHeight = document.body.offsetHeight;
                var clientHeight = document.documentElement.scrollTop + document.documentElement.clientHeight;
                var height = (clientHeight > bodyHeight) ? clientHeight : bodyHeight;
                shade.style.height = height+'px';
            }
        },
        
    show: function()
        {
            var overlay = document.getElementById(Overlay.id);
            overlay.style.display = 'block';
            Overlay.visible = true;
            Overlay.update();
        },
        
    hide: function()
        {
            var overlay = document.getElementById(Overlay.id);
            overlay.style.display = 'none';
            Overlay.visible = false;
        }	            
};

////////////////////////////////////////////////////////////////////////////////////////////////////

Overlay.init();

////////////////////////////////////////////////////////////////////////////////////////////////////