﻿Window = {

	//Returns an integer representing the width of the browser window (without the scrollbar).
	getWindowWidth : function() {
		if(document.layers || (document.getElementById && !document.all)) return window.outerWidth;		
		if(document.all) return document.body.clientWidth;
		
		return 0;
	},
 
	//Returns an integer representing the height of the browser window (without the scrollbar).
	getWindowHeight : function() {
		if(window.innerHeight) return window.innerHeight;		
		if(document.getBoxObjectFor) return Math.min(document.documentElement.clientHeight, document.body.clientHeight);		
		if(document.documentElement.clientHeight != 0) return document.documentElement.clientHeight;		
		if(document.body) return document.body.clientHeight;
		
		return 0;
	},	
	
	//Returns an integer representing the scrollHeight of the window.
	getScrollHeight : function() {			
		if(document.all) return Math.max(Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.body.scrollHeight));	
		if(document.body && document.body.scrollHeight > document.body.offsetHeight) return document.body.scrollHeight;	
		if(document.documentElement.scrollHeight != 0) return document.documentElement.scrollHeight;
		
		return 0;
	},
	
	//Returns an integer representing the scrollWidth of the window. 
	getScrollWidth : function() {
		if(document.all) return Math.max(Math.max(document.documentElement.offsetWidth, document.documentElement.scrollWidth), Math.max(document.body.offsetWidth, document.body.scrollWidth));
		if(document.documentElement.scrollWidth != 0) return document.documentElement.scrollWidth;
		if(document.body) return document.body.scrollWidth;
		
		return 0;
	},
	
	//Returns an integer representing the scrollLeft of the window (the number of pixels the window has scrolled from the left).
	getScrollLeft : function() {
		if(document.all) {
			if(!document.documentElement.scrollLeft) return document.body.scrollLeft;
			else return document.documentElement.scrollLeft;
		}	
		if(window.pageXOffset != 0) return window.pageXOffset;
		
		return 0;
	},
 
	//Returns an integer representing the scrollTop of the window (the number of pixels the window has scrolled from the top).
	getScrollTop : function() {
		if(document.all) {
			if(!document.documentElement.scrollTop) return document.body.scrollTop;
			else return document.documentElement.scrollTop;
		}
		if(window.pageYOffset != 0) return window.pageYOffset;
		
		return 0;
	},
	
	getViewport : function() {
		var viewport = new Object();
		viewport.height = Window.getWindowHeight();
		viewport.width = Window.getWindowWidth();
		return viewport;
	},
	
	getPage : function() {
		var page = new Object();
		page.height = Window.getScrollHeight();
		page.width = Window.getScrollWidth();
		return page;
	},
	
	getScroll : function() {
		var scroll = new Object();
		scroll.top = Window.getScrollTop();
		scroll.left = Window.getScrollLeft();
		return scroll;
	}
}
