/*************************************************************************
  Redimensionnement de la fenetre principale
  
  TTI 2007 (Thierry TURQUIN)
*************************************************************************/

function getWindowHeight() {
		var windowHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			windowHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			windowHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			windowHeight = document.body.clientHeight;
		}
/*	window.alert( 'windowHeight = ' + windowHeight );*/
		return windowHeight;
	}
	
function getWindowWidth() {
		var windowWidth = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			windowWidth = window.innerWidth;
//	window.alert( 'Navigateur NON IE : windowWidth = ' + windowWidth );
			decal = 5;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			windowWidth = document.documentElement.clientWidth;
//	window.alert( 'Navigateur IE 6+ Std Mode: windowWidth = ' + windowWidth );
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			windowWidth = document.body.clientWidth;
//	window.alert( 'Navigateur IE 4 Comp : windowWidth = ' + windowWidth );
		}
		return windowWidth;
	}
	
function GetDecal() {
	var decal = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		decal = 4;
	} else {
		decal = 0;
	}
	return decal ;
	}
	
function CalcMaxHauteur() {
		if (document.getElementById) {
			var windowHeight = getWindowHeight();
			var windowWidth = getWindowWidth();
			var BrowserSpace = document.getElementById( "BrowserSpace" ).style.height ;
//			var hPadding = document.getElementById( "mainpanel" ).style.paddingRight + document.getElementById( "mainpanel" ).style.paddingLeft;
//			var vPadding = document.getElementById( "mainpanel" ).style.paddingTop + document.getElementById( "mainpanel" ).style.paddingBotton;
			var hPadding = 10 ;
			var vPadding = 10 ;
			
			if (windowHeight > 0) {
				var layerMain = document.getElementById( "mainpanel" );
				var largeurMenu = Math.min( Math.floor((windowWidth - 264-58) / 5), 100) ;
				
//	window.alert( 'Content Width = ' + layerMain.style.width + ' Largeur Menu = ' + document.getElementById( "m1tlm0" ).style.width ); 
//	window.alert( 'Vert Padding = ' + vPadding + ' horz Padding = ' + hPadding ); 
	
				if( typeof( window.innerWidth ) == 'number' ) {
					//Non-IE
					layerMain.style.width = (windowWidth - 244 - hPadding ) + 'px';
					layerMain.style.height = (windowHeight - 157 - 13 - 4 - vPadding - BrowserSpace - 2) + 'px';
				} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
					//IE 6+ in 'standards compliant mode'
					layerMain.style.width = (windowWidth - 244 - hPadding ) + 'px';
					layerMain.style.height = (windowHeight - 157 - 13 - vPadding - BrowserSpace - 2) + 'px';
				} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
					//IE 4 compatible
					layerMain.style.width = (windowWidth - 244) + 'px';
					layerMain.style.height = (windowHeight - 157 - 13 - GetDecal() - BrowserSpace - 2) + 'px';
				}
				
				document.getElementById( "container" ).style.height = (windowHeight) + 'px';

 	 			if (document.getElementById("bg").value != null)
				    document.getElementById( "bg" ).style.top = (windowHeight - 223) + 'px';

				document.getElementById( "m1tlm0" ).style.width = largeurMenu ;
				document.getElementById( "m1tlm1" ).style.width = largeurMenu ;
				document.getElementById( "m1tlm2" ).style.width = largeurMenu ;
				document.getElementById( "m1tlm3" ).style.width = largeurMenu ;
				document.getElementById( "m1tlm4" ).style.width = largeurMenu ;
	
//				layerMain.style.width = Math.max((windowWidth - 244), 680 ) + 'px';
//				layerTop.style.width = Math.max((windowWidth - 244), 680 ) + 'px';
			}
		}
	}	


