// File:	window-utils.js
// Author:	VMS <http://www.vmsinfo.com/>
// Date:	23/12/2004
// Updated:	23/12/2004
//
// First cut of basic Window management library. (c) VMS 2004.
//
// =================================================================================================


var storedWindowHeight;
var storedWindowWidth;

// storeCurrentWindowSize
//
// Store the current dimensions of the window so that we can restore them
// when required.

function storeCurrentWindowSize() {

	// Try using 'innerWidth/Height' first
	
	if (self.innerWidth) {
		storedWindowWidth = self.innerWidth;
		storedWindowHeight = self.innerHeight;
	}
	
	// Otherwise, try using 'clientWidth' on 'documentElement'
	
	else if (document.documentElement && document.documentElement.clientWidth) {
		storedWindowWidth = document.documentElement.clientWidth;
		storedWindowHeight = document.documentElement.clientHeight;
	}
	
	// Or on 'document.body'
	
	else if (document.body) {
		storedWindowWidth = document.body.clientWidth;
		storedWindowHeight = document.body.clientHeight;
	}
	
	// Otherwise just try to use 'offsetWidth'
	
	else {
		storedWindowWidth = document.body.offsetWidth;
		storedWindowHeight = document.body.offsetHeight;
	}
}

function changeWindowSizeIfNeeded(width,height) {
	if (("" + (typeof window.opener)) != "object") {
		changeWindowSize(width,height);
	}
}

// changeWindowSize
//
// Change with size of the window as specified.

function changeWindowSize(width,height) {
	if (document.all || document.layers) {
    	window.resizeTo(width,height);
	}
	else {
		if (self.innerWidth) {
			window.innerWidth = width;
			window.innerHeight = height;
		}
		else if (document.documentElement && document.documentElement.clientWidth) {
			document.documentElement.clientWidth = width;
			document.documentElement.clientHeight = height;
		}
		else if (document.body) {
			document.body.clientWidth = width;
			document.body.clientHeight = height;
		}
		else {
			document.body.offsetWidth = width;
			document.body.offsetHeight = height;
		}
	}
}
