function screenHeight(){
	return screen.availHeight;

}

function screenWidth(){
	return screen.availWidth;
}



function innerHeight(win){
	if (win==null) alert("innerHeight(win) : win is null");
  if( typeof( win.innerHeight ) == 'number' ) {
    return win.innerHeight;
    }
  else if( win.document.documentElement && ( win.document.documentElement.clientWidth || win.document.documentElement.clientHeight ) ) {
    return win.document.documentElement.clientHeight;
    }
  else if( win.document.body && ( win.document.body.clientWidth || win.document.body.clientHeight ) ) {
    return win.document.body.clientHeight;
    }
  else {
    return -1;
  }
}


function innerWidth(win){
	if (win==null) alert("innerHeight(win) : win is null");
  if( typeof( win.innerWidth ) == 'number' ) {
    return win.innerWidth;
    }
  else if( win.document.documentElement && ( win.document.documentElement.clientWidth || win.document.documentElement.clientHeight ) ) {
    return win.document.documentElement.clientWidth;
    }
  else if( win.document.body && ( win.document.body.clientWidth || win.document.body.clientHeight ) ) {
    return win.document.body.clientWidth;
    }
  else {
    return -1;
  }
}



function maximizeWindow(win){
	win.resizeTo(screenWidth(),screenHeight());
	win.moveTo(0,0);
}

function resizeBlock(id,width,height){
	var obj=new getObj(id);
	obj.style.width=width;
	obj.style.height=height;
}

function centerDiv(id){
	var div=new getObj(id);
	var width=div.obj.clientWidth;
	//width=parseInt(width);
	div.style.left=((innerWidth(window)-width)/2)+"px";
	var height=div.obj.clientHeight;
	//height=parseInt(height);
	div.style.top=((innerHeight(window)-height)/2)+"px";
}


function customizeImageSize(imageId,maxWidth,maxHeight){
	var ratioW,ratioH,ratio;ratio=1;
	var myimg=new Image(); 
	var docimg;
	var newWidth,newHeight,marginH,marginW;
	var i;
	docimg=new getObj(imageId);
	myimg.src=docimg.obj.src;
	if (! myimg.complete && ! docimg.obj.complete) {
		if (myimg.width==0 && myimg.height==0) {
			/*alert("" + docimg.obj.complete +"\nErreur : \nChargement de l'image '" + myimg.src + "' impossible.");*/
			return false;
		}
	}

	ratioW=maxWidth/myimg.width;
	ratioH=maxHeight/myimg.height;
	
	ratio=Math.min(ratioW,ratioH);
	newWidth=Math.round(myimg.width*ratio);
	newHeight=Math.round(myimg.height*ratio);
	
	docimg.style.width= "" + newWidth + "px";
	docimg.style.height= "" + newHeight + "px";
	
	marginH=Math.round((maxHeight-newHeight)/2);
	marginW=Math.round((maxWidth-newWidth)/2);
	
	docimg.style.margin= "" + marginH+"px "+marginW + "px " + marginH+"px "+marginW + "px ";

}


