

function isWinIE5() {
	var winIE5 = false;
	var ieVersion = /msie (\d\.\d*)/

	if (navigator.appName.toLowerCase().indexOf('microsoft') != -1)
		if (navigator.appVersion.toLowerCase().indexOf('macintosh') == -1) {

			var findVersion = ieVersion.exec(navigator.appVersion.toLowerCase())

			if (findVersion)

				if (parseFloat(findVersion[1]) < 8.0)  // IE6 isn't much better and I guess IE7 will be the same
					winIE5 = true;
		}

	return winIE5;
}

function fixWinIEStyle(styleStr) {
	if (isWinIE5()) {
		document.write("<style>" + styleStr + "</style>");
	}
}

function fullScreenWindow() {
	if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
		if (window.outerWidth != screen.availWidth)
			window.resizeTo(screen.availWidth, screen.availHeight - 24);  // is -24 for Mac only?
		if (window.screenX != screen.availLeft || window.screenY != 0)
			window.moveTo(0, 0);	// must be done last
	}
	else {
		var leftPos = screen.availLeft;
		var topPos = screen.availTop;
		if (navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
			if (leftPos > 2) leftPos -= 2;
			if (topPos > 2) topPos -= 2;
		}
		window.moveTo(leftPos, topPos);
		window.resizeTo(screen.availWidth, screen.availHeight);
	}
}

function getWindowWidth() {
	if (navigator.appName.toLowerCase().indexOf('microsoft') != -1)
		return document.body.clientWidth;
	return window.innerWidth;
}
function getWindowHeight() {
	if (navigator.appName.toLowerCase().indexOf('microsoft') != -1)
		return document.body.clientHeight;
	return window.innerHeight;
}

function getWindowWidth() {
	var winWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		// Non-IE
		winWidth = window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		//IE 6+ in 'standards compliant mode'
		winWidth = document.documentElement.clientWidth;
	}
	else if (document.body && document.body.clientWidth) {
		//IE 4 compatible
		winWidth = document.body.clientWidth;
	}
	return winWidth;
}

function getWindowHeight() {
	var winHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		// Non-IE
		winHeight = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		//IE 6+ in 'standards compliant mode'
		winHeight = document.documentElement.clientHeight;
	}
	else if (document.body && document.body.clientHeight) {
		//IE 4 compatible
		winHeight = document.body.clientHeight;
	}
	return winHeight;
}
