// Geometry.js
// These functions are for getting the various window properties. Adapted from JavaScript the Definitive Guide 5 Edition

//First check the name space...

var com;
if (!com || !com.jchristy) { throw new Error("com.jchristy: Required object 'com.jchristy.Support' does not exist."); }
if (!document.body) { throw new Error("com.jchristy.Geometry: You must include this script AFTER <body>"); }
//Name space is ready.

com.jchristy.Geometry = {};

if (window.screenX) {
	com.jchristy.Geometry.getWindowX = function() { return window.screenX; }
	com.jchristy.Geometry.getWindowY = function() { return window.screenY; }
	
} else if (window.screenLeft) {
	com.jchristy.Geometry.getWindowX = function() { return window.screenLeft; }
	com.jchristy.Geometry.getWindowY = function() { return window.screenTop; }
}

if (window.innerWidth) {
	com.jchristy.Geometry.getInnerWidth = function() { return window.innerWidth; }
	com.jchristy.Geometry.getInnerHeight = function() { return window.innerHeight; }
	com.jchristy.Geometry.getXOffset = function() { return window.pageXOffset; }
	com.jchristy.Geometry.getYOffset = function() { return window.pageYOffset; }
} else if (document.documentElement && document.documentElement.clientWidth) {
	com.jchristy.Geometry.getInnerWidth = function() { return document.documentElement.clientWidth; }
	com.jchristy.Geometry.getInnerHeight = function() { return document.documentElement.clientHeight; }
	com.jchristy.Geometry.getXOffset = function() { return document.documentElement.scrollLeft; }
	com.jchristy.Geometry.getYOffset = function() { return document.documentElement.scrollTop; }
} else if (document.body.clientWidth) {
	com.jchristy.Geometry.getInnerWidth = function() { return document.body.clientWidth; }
	com.jchristy.Geometry.getInnerHeight = function() { return document.body.clientHeight; }
	com.jchristy.Geometry.getXOffset = function() { return document.body.scrollLeft; }
	com.jchristy.Geometry.getYOffset = function() { return document.body.scrollTop; }
}

if (document.documentElement && document.documentElement.scrollWidth) {
	com.jchristy.Geometry.getDocWidth = function() { return document.documentElement.scrollWidth; }
	com.jchristy.Geometry.getDocHeight = function() { return document.documentElement.scrollHeight; }
	
} else if (document.body.scrollWidth) {
	com.jchristy.Geometry.getDocWidth = function() { return document.body.scrollWidth; }
	com.jchristy.Geometry.getDocHeight = function() { return document.body.scrollHeight; }
}