// start info
if(typeof jsReport != 'undefined'){
	jsVersion = new Array(
	/*Name			=*/ 'Layout Guard',
	/*Version 		=*/ '1.5',
	/*Date 			=*/ 20040216,
	/*Author		=*/ 'Maurice van Creij',
	/*ProjectCode	=*/ 'app_layoutguard',
	/*Summary		=*/ 'Monitor resizes and restrain an element to a maximum size.',
	/*Dependencies	=*/ new Array('app_layoutguard.js'),
	/*Browsers		=*/ new Array('MO','IE','OP'),
	/*Changes		=*/ new Array(
						'1.5: A small addition to the stylesheet will enable the script to operate in strict doctypes.',
						'1.4: Configuration is now stored in an array',
						'1.3: Added height as well as width',
						'1.2: Doesn\'t wait for onload event anymore',
						'1.1: Added a minimum width as well as the maximum width',
					  	'1.0: Basic functionality'
					  	),
	/*Usage			=*/ new Array(
							'<style>html, body {height : 100%;}</style>',
							'<script language="javascript" src="/~wmittensrdx/resources/layout_guard.js"></script>'
					  	)
	)
}else{
// end info

	// constants/configuration
		var intLayoutCorr	= (document.all) ? 4 : 0 ; // possible MSIE adjustment for the offsetHeight
		var arrLayoutHyst	=	new Array(
									//	new Array(strResizeId,new Array(intXmin,intXmax,intXoff),new Array(intYmin,intYmax,intYoff)),
									new Array('mainCanvas',	new Array(0,1004,0),	null),
									new Array('canvas1',	new Array(800,1024,0),	new Array(0,9999,0)),
									new Array('canvas',	null,	new Array(0,9999,230))
									//new Array('content11',	null,					new Array(0,9999,180))
								);
	// functionality
		// guess/measure the height of the document
		function getDocHeight(){
			// choose the biggest value for the height
			var intMaxHeight = (document.body.scrollHeight>document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight-intLayoutCorr;
			// pass the value back
			return intMaxHeight;
		}
		// guess/measure the width of the document
		function getDocWidth(){
			// choose the smallest value for the width
			var intMaxWidth = (document.body.scrollWidth<document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth;
			// pass the value back
			return intMaxWidth;
		}
		// set the elements' dimensions if the window dimensions pass a treshold
		function setDimensions(){
			var strResizeId, strWidth, strHeight;
			// document dimensions
			var intWidthDoc = getDocWidth();
			var intHeightDoc = getDocHeight();
			// for all listed elements
			for(var intA=0; intA<arrLayoutHyst.length; intA++){
				if(document.getElementById(arrLayoutHyst[intA][0])!=null){
					// width limits
					if(arrLayoutHyst[intA][1]!=null){
						// pick element width by limit
						//if		(intWidthDoc<arrLayoutHyst[intA][1][0]){	strWidth = (arrLayoutHyst[intA][1][0]-arrLayoutHyst[intA][1][2]) + 'px';}
						/*else */if	(intWidthDoc>arrLayoutHyst[intA][1][1]){	strWidth = (arrLayoutHyst[intA][1][1]-arrLayoutHyst[intA][1][2]) + 'px';}
						else {												strWidth = '100%';}
						// set element width*/
						document.getElementById(arrLayoutHyst[intA][0]).style.width = strWidth;
					}
					// height limits
					if(arrLayoutHyst[intA][2]!=null){
						// pick element height by limit
						if		(intHeightDoc<arrLayoutHyst[intA][2][0]){	strHeight = (arrLayoutHyst[intA][2][0]-arrLayoutHyst[intA][2][2]) + 'px';}
						else if	(intHeightDoc>arrLayoutHyst[intA][2][1]){	strHeight = (arrLayoutHyst[intA][2][1]-arrLayoutHyst[intA][2][2]) + 'px';}
						else {												strHeight = (intHeightDoc-arrLayoutHyst[intA][2][2]) + 'px';}
						// set element height
						document.getElementById(arrLayoutHyst[intA][0]).style.height = strHeight;
					}
				}
			}
		}
	// constructors


	// event handlers 
		function handleResize(){
			setTimeout("setDimensions()",128);
		}

	// executed inline
		//  if there's DOM support capture the resize event
		if(typeof(document.getElementById)!='undefined'){
			setDimensions();
			if(document.body.getAttribute('onload')==null) onload = handleResize;
			onresize = handleResize;
		}

}
