/* environment information v1.1 030204 (c)ch c@cdot.de
 *  browser version
 *  clientBorder
 *  screenW screenH					screen size
 *  getWinW() getWinH()				window size
 *  getDocW() getDocH()				document size (1.0: only IE)
 *  getDocScrollX() getDocScrollY()	document scroll position
 */
var isOpera = (navigator.appVersion.indexOf('opera') > -1);
var isSafari = (navigator.appVersion.indexOf('Safari') > -1);
var w3c = (document.getElementById) ? true : false;
var ie 	= (document.all && !isOpera) ? true : false;
var ie4 = (ie && !w3c);
var ieMac = (ie && (navigator.appVersion.indexOf('Mac') > -1 ) );
var ie6up = (w3c && navigator.appVersion.indexOf("MSIE 6") > -1);
var ns4 = (document.layers) ? true : false;
var ns6 = (w3c && !ie);
var dhtml = (w3c);

//client (new)
var envClient = new Object();

//NEEDS OPENER
function envClientBorder() {
	var w, h;
	//get from opener if present
	if (window.opener.envClientBorderWidth && window.opener.envClientBorderHeight) {
		w = window.opener.envClientBorderWidth;
		h = window.opener.envClientBorderHeight;
		}
	else {
		//n4 n6
		if (self.innerWidth) {
			w = window.outerWidth - window.innerWidth;
			h = window.outerWidth - window.innerWidth;
		}
		//ie5-6
		else if (document.body)
		{
			var testWindow = window.open("about:blank", "", "scrollbars=no, resizable=no, width=100, height=100");
			while (testWindow.document.documentElement.clientWidth == "undefined") {}
			testWindow.resizeTo(100,100);
			w = 100 - testWindow.document.body.clientWidth;
			h = 100 - testWindow.document.body.clientHeight;
			if (!testWindow.closed) testWindow.close();
		}
		//ie6 standard
		else if (document.documentElement && document.documentElement.clientWidth)
		{
			var testWindow = window.open("about:blank", "", "scrollbars=no, resizable=no, width=100, height=100");
			testWindow.resizeTo(100,100);
			while (testWindow.document.documentElement.clientWidth == "undefined") {}
			w = 100 - testWindow.document.documentElement.clientWidth;
			h = 100 - testWindow.document.documentElement.clientHeight;
			if (!testWindow.closed) testWindow.close();
		}
		//store in opener for reuse;
		window.opener.envClientBorderWidth = w;
		window.opener.envClientBorderHeight = h;
	}
	return { width: w, height: h }
}


/*	envScreen object
 *	attributes:	width
 *				height
 */
var envScreen = {
	width: (screen.availWidth) ? screen.availWidth : 640,
	height: (screen.availHeight) ? screen.availHeight : 480
	}
//old:
var screenW = (screen.availWidth) ? screen.availWidth : 640;
var screenH = (screen.availHeight) ? screen.availHeight : 480;

//window
function getWinW() { 
	if (ie6up) return getInnerSize().width;
	return (ie) ? document.body.offsetWidth - hasScrollW() : window.innerWidth - hasScrollW(); 
	}
function getWinH() { 
	if (ie6up) return getInnerSize().height;
	return (ie) ? document.body.offsetHeight - hasScrollH() : window.innerHeight - hasScrollH(); 
	}
	//ie6:
function getInnerSize() {
   var el = window.document.compatMode == "CSS1Compat" ?
               window.document.documentElement : window.top.document.body;
   return {
      width:   el.clientWidth,
      height:  el.clientHeight
   };
}

function getDocW() {
	if (ie && !ieMac) return document.body.scrollWidth;
	else if (w3c || ieMac) return document.body.offsetWidth; //mac special!
	else return 0; //ns4
	}
function getDocH() {
	if (ie && !ieMac) return document.body.scrollHeight;
	else if (w3c || ieMac) return document.body.offsetHeight; //ieMac special!
	else return 0; //ns4
	}
function hasScrollW() {
 	if (ie) { if (getDocW() > document.body.offsetWidth) return 20; else return 0; }
 	else 	{ if (getDocW() > window.innerWidth) return 16; else return 0; }
	}
function hasScrollH() {
 	if (ie) { if (getDocH() > document.body.offsetHeight) return 20; else return 0; }
 	else 	{ if (getDocH() > window.innerHeight) return 16; else return 0; }
	}
function getDocScrollX() { 
	if (isSafari) return 0; // safari positions on window (giveaword)
	if (ie6up) return document.documentElement.scrollLeft;
	return (ie) ? document.body.scrollLeft : window.pageXOffset; 
	}
function getDocScrollY() { 
	if (isSafari) return 0; // safari positions on window (giveaword)
	if (ie6up) return document.documentElement.scrollTop;
	return (ie) ? document.body.scrollTop : window.pageYOffset; 
	}
	
