/*
	This is pretty much a copy of code from David Flanagan's book
	on Javascript.  It defines a Geometry object that stores functions
	that will query the read-only dimensions of the user's screen, window, etc.
	We own a copy of the book and believe we are entitled to use the code.
	Flanagan, David (2006) Javascript:  The Definitive Guide.  Sebastapol, CA:  O'Reilly Media.
*/
function makeGeometry() {
	var Geometry = {};

	if (window.screenLeft) { //IE and others
		Geometry.getWindowX = function() { return window.screenLeft; };
		Geometry.getWindowY = function() { return window.screenTop; };
	}
	else if (window.screenX) { //Firefox and others
		Geometry.getWindowX = function() { return window.screenX; };
		Geometry.getWindowY = function() { return window.screenY; };
	}

	if (window.innerWidth) { // all but IE
		Geometry.getViewportWidth = function() { return window.innerWidth; };
		Geometry.getViewportHeight = function() { return window.innerHeight; };
		Geometry.getHorizontalScroll = function() { return window.pageXOffset; };
		Geometry.getVerticalScroll = function() { return window.pageYOffset; }; 
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
	// IE 6 with DOCTYPE declaraton
		Geometry.getViewportWidth = function() { return document.documentElement.clientWidth; };
		Geometry.getViewportHeight = function() { return document.documentElement.clientHeight; };
		Geometry.getHorizontalScroll = function() { return document.documentElement.scrollLeft; };
		Geometry.getVerticalScroll = function() { return document.documentElement.scrollTop; }; 
	}
	else if (document.body.clientWidth) { //IE 4, 5, 6 without DOCTYPE
		Geometry.getViewportWidth = function() { return document.body.clientWidth; };
		Geometry.getViewportHeight = function() { return document.body.clientHeight; };
		Geometry.getHorizontalScroll = function() { return document.body.scrollLeft; };
		Geometry.getVerticalScroll = function() { return document.body.scrollTop; }; 
	}

	// document sizes
	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; };
	}
	return Geometry;
	
} //makeGeometry()
