// Cross browser DHTML utility functions

		function getWindowSize(pstrDimension) {
			// Get size of client area of window - cross-browser
			var myWidth = 0, myHeight = 0;
			if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
			} else if( document.documentElement &&
				( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
			}
			if (pstrDimension.toLowerCase() == 'width')
				return	myWidth;
			else
				return myHeight;
		}
		function getWindowWidth() {
			return getWindowSize('width');
		}
		function getWindowHeight() {
			return getWindowSize('height');
		}
		
		function getPageHeight(){
		    // get the size of the page
		    if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				return document.documentElement.offsetHeight;
			} else if( document.documentElement &&
				( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				return document.documentElement.scrollHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				return document.body.scrollHeight;
			}
		}

		
		function getRefToDiv(divID) {
			// cross-browser reference
			if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
				return document.getElementById(divID); }
			if( document.layers ) { //Netscape layers
				return document.layers[divID]; }
			if( document.all ) { //Proprietary DOM; IE4
				return document.all[divID]; }
			if( document[divID] ) { //Netscape alternative
				return document[divID]; }
			return false;
		}

		function rSDiv(oName,newWidth,newHeight) {
			// resize div cross-browser
			var myReference = getRefToDiv(oName);
			var noPx = document.childNodes ? 'px' : 0;
			if( myReference.style ) { myReference = myReference.style; }
			if( myReference.resizeTo ) { myReference.resizeTo( newWidth, newHeight ); }

            if (newWidth)
            {
			    myReference.width = newWidth + noPx; 
			    myReference.pixelWidth = newWidth;
			}
			if (newHeight)
			{
			    myReference.height = newHeight + noPx; 
			    myReference.pixelHeight = newHeight;
			}
		}

		function mvDiv(divID_as_a_string) {
			var myReference = getRefToDiv(divID_as_a_string), noPx = document.childNodes ? 'px' : 0;
			if( !myReference ) { window.alert('Nothing works in this browser'); return; }
			if( myReference.style ) { myReference = myReference.style; }
			if( parseInt(myReference.left) ) {
				window.alert('Sorry, I will not allow you to move this element too far,\ninstead I will reset it.');
				myReference.left = 0 + noPx; myReference.top = 0 + noPx; } else {
				myReference.left = 20 + noPx; myReference.top = 10 + noPx; }
		}

		function getDivHeight(divID_as_a_string) {
			var myReference = getRefToDiv(divID_as_a_string), noPx = document.childNodes ? 'px' : 0;
			if( !myReference ) { return; } // nothing works in this browser
            if( myReference.offsetHeight ) {return myReference.offsetHeight;}
			if( myReference.style ) { myReference = myReference.style; }
			if (! myReference.pixelHeight)
			{
				if(isNaN(parseInt(myReference.height, 10)))
					return false;
				else
					return parseInt(myReference.height, 10);
			}
			else
				return myReference.pixelHeight;		
		}

		function getDivWidth(divID_as_a_string) {
			var myReference = getRefToDiv(divID_as_a_string), noPx = document.childNodes ? 'px' : 0;
			if( !myReference ) {  return; } // nothing works in this browser
			if( myReference.style ) { myReference = myReference.style; }
			if (! myReference.pixelWidth) {
				return false;
			} else
				return myReference.pixelWidth;
		}

		function findPosition( oLink ) {
		if( oLink.offsetParent ) {
			for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
			}
			return [ posX, posY ];
		} else {
			return [ oLink.x, oLink.y ];
		}
		}

		function findTop( oLink ) {
		if( oLink.offsetParent ) {
			for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
			}
			return posY;
		} else {
			return oLink.y;
		}
		}

		function findLeft( oLink ) {
		if( oLink.offsetParent ) {
			for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
			}
			return posX;
		} else {
			return oLink.x;
		}
		}
	
