/*

© korrekturlesen.org

Dieses Skript ist Eigentum von korrekturlesen.org.

Unerlaubte Vervielfältigung wird strafrechtlich verfolgt.

*/


LoadingBox = 
{
    quirks : typeof document.compatMode == 'undefined' || document.compatMode == 'BackCompat' ? true : false,

    open : function (id)
    {
        if (document.getElementById(id) == null)
        {
            return;
        }

        var curtain = $('#curtain');
        var loadingBox = $('#loadingBox');
        var documentHeight = this.getDocumentHeight();
        var windowInnerWidth = this.getWindowInnerWidth(), windowInnerHeight = this.getWindowInnerHeight();

        curtain.height(documentHeight);
        curtain.show();


        loadingBox.css('left', '-1000000px');
        loadingBox.css('top', '-1000000px');
        loadingBox.fadeIn('slow');

        var loadingBoxHeight = document.getElementById(id).offsetHeight;
        var loadingBoxWidth = document.getElementById(id).offsetWidth;

        if (!window.offscreenBuffering)
        {
            var width = windowInnerWidth;
            var height = windowInnerHeight;
        }
        else
        {
            var width = windowInnerWidth + 20;
            var height = windowInnerHeight;
        }

        loadingBox.css('left', ((width - loadingBoxWidth) / 2) + 'px');
        loadingBox.css('top', ((height - loadingBoxHeight) / 2) + this.getPageYOffset() + 'px');
    },


    getDocumentHeight: function()
    {
        var height_1 = window.innerHeight ? window.innerHeight : $('html')[0].height;
        var height_2 = this.quirks ? document.body.scrollHeight : document.documentElement.scrollHeight;

        var documentHeight = height_1 > height_2 ? height_1 : height_2;
        if (window.offscreenBuffering)
        {
            documentHeight += 20;
        }

        return documentHeight;
    },


    getWindowInnerWidth : function()
    {
        return window.innerWidth ? window.innerWidth : $('html')[0].width;
    },


    getWindowInnerHeight : function()
    {
        return window.innerHeight ? window.innerHeight : $('html')[0].height;           
    },


    getPageYOffset : function()
    {
       if (window.pageYOffset)
           return window.pageYOffset;
       else 
       {
           if (!this.quirks)
               return document.documentElement.scrollTop;
           else
               return document.body.scrollTop;
       }
    }
}
