var height, width;
var x, y;

function calcXPos(){
	height = document.documentElement.clientHeight;
	width  = document.documentElement.clientWidth;
	
	x = (height/2 - elementHeight/2);
	y = (width/2 - elementWidth/2);
		
	if ( x<xMin ) x = xMin;
	if ( y<yMin ) y = yMin;
		
	element.style.top = x + "px";
	element.style.left = y + "px";
}

/* Definitions of element, xMin and yMin are required */