/**
* Window size script by Tudor Barbu (tudor@it-base.ro)
*
* You can use it for free as long as you keep my copyright
* notice intact. Thank you!
*
*/


/**
* returns a hashtable (array):
*
* width         : the width of the viewport
* height        : the height of the viewport
* vScroll       : the vertical scroll
* hScroll       : the horizontal scroll
* totalWidth    : the width of the page
* totalHeight   : the height of the page
*/
window.getSize = function() {
    var width = 0, height = 0, vScroll = 0, hScroll = 0, tWidth = 0, tHeight = 0;
    if ( typeof( window.innerWidth ) == 'number' ) {
        width  = window.innerWidth;
        height = window.innerHeight;
    }
    else {
        if ( document.documentElement && document.documentElement.clientWidth ) {
            width  = document.documentElement.clientWidth;
            height = document.documentElement.clientHeight;
        }
        else {
            if ( document.body && document.body.clientWidth ) {
                width  = document.body.clientWidth;
                height = document.body.clientHeight;
            }
        }
    }
    if( document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {
        vScroll = document.body.scrollTop;
        hScroll = document.body.scrollLeft;
    }
    else {
        if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
            vScroll = document.documentElement.scrollTop;
            hScroll = document.documentElement.scrollLeft;
        }
        else {
            if( window.pageYOffset ) {
                vScroll = window.pageYOffset;
                hScroll = window.pageXOffset;
            }
        }
    }

    var xScroll = 0, yScroll = 0;
    if ( window.innerHeight && window.scrollMaxY ) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    }
    else {
        if (document.body.scrollHeight > document.body.offsetHeight ) {
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        }
        else {
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
    }
    tWidth  = Math.max( width, xScroll );
    tHeight = Math.max( height, yScroll );
    return { width: width, height: height, vScroll: vScroll, hScroll: hScroll, totalWidth: tWidth, totalHeight: tHeight };
}