// Enrico Simonetti 2009

if(Browser.Engine.name == 'trident' && Browser.Engine.version <= 4)
{
	// ie less and equal to 6 is not supported
        window.location = base_url + 'notsupported';
}

function moveBoxOverlayImage()
{
        scroller = window.getScroll();
        windowsize = window.getSize();
        new Fx.Morph('BoxOverlayImage', {
                duration: '600'
        }).start({
                'top': ((windowsize.y/2 + scroller.y)).toInt()
        });     
}

function showOverlay()
{
        moveBoxOverlayImage();
        
        $('BoxOverlay').setStyles({
                'height': window.getScrollHeight() + 'px',
                'width': window.getScrollWidth() + 'px',
                'display': 'inline'
        });
}

function showStaticOverlay()
{
	$('StaticBoxOverlay').setStyles({
                'height': window.getScrollHeight() + 'px',
                'width': window.getScrollWidth() + 'px',
                'display': 'inline'
        });
}

function hideOverlay()
{
        $('BoxOverlay').setStyles({
                'height': window.getScrollHeight() + 'px',
                'width': window.getScrollWidth() + 'px',
                'display': 'none'
        });
}

function hideStaticOverlay()
{
        $('StaticBoxOverlay').setStyles({
                'height': window.getScrollHeight() + 'px',
                'width': window.getScrollWidth() + 'px',
                'display': 'none'
        });
}

var Overlay = new Element('div', {
        'id': 'BoxOverlay',
        'styles': {
                'display': 'none',
                'z-index': '20000',
                'position': 'absolute',
                'top': '0',
                'left': '0',
                'background-color': '#333333',
                'opacity': 0.8,
                'height': window.getScrollHeight() + 'px',
                'width': window.getScrollWidth() + 'px'
        }
});

var StaticOverlay = new Element('div', {
        'id': 'StaticBoxOverlay',
        'styles': {
                'display': 'none',
                'z-index': '0',
                'position': 'absolute',
                'top': '0',
                'left': '0',
                'background-color': '#333333',
                'opacity': 0.8,
                'height': window.getScrollHeight() + 'px',
                'width': window.getScrollWidth() + 'px'
        }
});

var loading = new Element('img', {
        'id': 'BoxOverlayImage',
        'src': base_url + 'img/loading.gif',
        'alt': 'Loading',
        'styles': {
                'z-index': '21000',
                'position': 'absolute',
                'top': window.getScrollHeight()/2 + 'px',
                'left': (window.getScrollWidth()/2).toInt() - 25 + 'px'
        }
});

window.addEvent('scroll', function() 
        {
                if($('BoxOverlay').getStyle('display')=='inline')
                {
                        moveBoxOverlayImage();
                }
        }
);
