/*****************************
   Geometry.js 
  Routines for getting screen geometry
  From JavaScript: The Definitive Guide 5th Ed pp276-277
*****************************/

// getWindowX/Y - return the position of the window on the screen
// getViewportWidth/Height - return size of bowser viewport area
// getDocumentWidth/Height - return size of the rendered HTML doc
// getVertical/HorizontalScroll - position of acrollbar

var Geometry = {};


Geometry.setup = function() {

    // getWindowX/Y - return the position of the window on the screen
    if (window.screenLeft) { // IE
        Geometry.getWindowX = function() { return window.screenLeft; }
        Geometry.getWindowY = function() { return window.screenTop; }
    } else if (window.screenX) { // Firefox et al
        Geometry.getWindowX = function() { return window.screenX; }
        Geometry.getWindowY = function() { return window.screenY; }
    }

    if (window.innerWidth) {
        // Firefox
        Geometry.getViewportWidth = function() { return window.innerWidth; }
        Geometry.getViewportHeight = function() { return window.innerHeight; }
        Geometry.getVerticalScroll = function() { return window.pageYOffset; }
        Geometry.getHorizontalScroll = function() { return window.pageXOffset; }
    } else if (document.documentElement && document.documentElement.clientWidth) {
        // IE 6+ in standards mode
        Geometry.getViewportWidth = function() { return document.documentElement.clientWidth; }
        Geometry.getViewportHeight = function() { return document.documentElement.clientHeight; }
        Geometry.getVerticalScroll = function() { return document.documentElement.scrollTop; }
        Geometry.getHorizontalScroll = function() { return document.documentElement.scrollLeft; }
    } else if (document.body.clientWidth) {
        // IE 4,5; and 6+ in slapdash mode
        Geometry.getViewportWidth = function() { return document.body.clientWidth; }
        Geometry.getViewportHeight = function() { return document.body.clientHeight; }
        Geometry.getVerticalScroll = function() { return document.body.scrollTop; }
        Geometry.getHorizontalScroll = function() { return document.body.scrollLeft; }
    }

    if (document.documentElement && document.documentElement.scrollWidth) { 
        Geometry.getDocumentWidth = function() { return document.documentElement.scrollWidth; }
        Geometry.getDocumentHeight = function() { return document.documentElement.scrollHeight; }       
    } else if (document.body.scrollWidth) { 
        Geometry.getDocumentWidth = function() { return document.body.scrollWidth; }
        Geometry.getDocumentHeight = function() { return document.body.scrollHeight; }
    }

}

onloadHooks.addHook(Geometry.setup);
