// JavaScript Document
function getWindowWidth(){
	return (self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0);
}
function getWindowHeight(){
	return (self.innerHeight ||  document.documentElement.clientHeight || document.body.clientHeight || 0);
}
function getDocumentWidth(){
	return Math.min(document.body.scrollWidth,getWindowWidth());
}
function getDocumentHeight(){
	return Math.max(document.body.scrollHeight,getWindowHeight());
}

function center(element){
	if(!element._absolutized){
		element.setStyle({
			position: 'absolute'
		}); 
		element._absolutized = true;
	}
	var dimensions = element.getDimensions();
	Position.prepare();
	var offset_left = (Position.deltaX + Math.floor((getWindowWidth() - dimensions.width) / 2));
	var offset_top = (Position.deltaY + ((getWindowHeight() > dimensions.height) ? Math.floor((getWindowHeight() - dimensions.height) / 2) : 0));
	element.setStyle({
		top: ((dimensions.height <= getDocumentHeight()) ? ((offset_top != null && offset_top > 0) ? offset_top : '0') + 'px' : 0),
		left: ((dimensions.width <= getDocumentWidth()) ? ((offset_left != null && offset_left > 0) ? offset_left : '0') + 'px' : 0)
	});
}

function verticalCenter(element){
	if(!element._absolutized){
		element.setStyle({
			position: 'absolute'
		}); 
		element._absolutized = true;
	}
	var dimensions = element.getDimensions();
	Position.prepare();
	var offset_top = (Position.deltaY + ((getWindowHeight() > dimensions.height) ? Math.floor((getWindowHeight() - dimensions.height) / 2) : 0));
	element.setStyle({
		top: ((dimensions.height <= getDocumentHeight()) ? ((offset_top != null && offset_top > 0) ? offset_top : '0') + 'px' : 0)
	});
}

function hide(element){
	document.getElementById(element).style.display = "none";
}

function overWriteOnLoad(elementId){
	var oldonload=window.onload;
	if(typeof(oldonload)=='function'){
		window.onload=function(){
			hide(elementId);
			oldonload();
		};
	}
	else {
		window.onload=function(){
			hide(elementId);
		};
	}

}
