var OT_Position = {
	center: function(element){
		var dimensions = element.getDimensions();
		Position.prepare();
		var offset_left = (Position.deltaX + Math.floor((this.getWindowWidth() - dimensions.width) / 2));
		var offset_top = (Position.deltaY + Math.floor((this.getWindowHeight() - dimensions.height) / 2));
		element.setStyle({
			top: ((dimensions.height <= this.getWindowHeight()) ? ((offset_top != null && offset_top > 0) ? offset_top : '0') + 'px' : 0),
			left: ((dimensions.width <= this.getWindowWidth()) ? ((offset_left != null && offset_left > 0) ? offset_left : '0') + 'px' : 0)
		});
	},
	
	getWindowWidth: function(){
		return (self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0) - this.getScrollBarWidth();
	},
	getWindowHeight: function(){
		return (self.innerHeight ||  document.documentElement.clientHeight || document.body.clientHeight || 0);
	},
	getDocumentWidth: function(){
		return Math.min(document.body.scrollWidth,this.getWindowWidth());
	},
	getDocumentHeight: function(){
		return Math.max(document.body.scrollHeight,this.getWindowHeight());
	},
	
	getScrollBarWidth: function(){
		var scroller_div = document.createElement('div');
		Object.extend(scroller_div.style,{
			position: 'absolute',
			top:'-1000px',
			left: '-1000px',
			width: '100px',
			height: '50px',
			overflow: 'hidden'
		});
		var inner_div = document.createElement('div');
		inner_div.style.width = '100%';
		inner_div.style.height = '200px';
		scroller_div.appendChild(inner_div);
		document.body.appendChild(scroller_div);
		var withNoScroll = inner_div.offsetWidth;
		scroller_div.style.overflow = 'auto';
		var withScroll = inner_div.offsetWidth;
		document.body.removeChild(document.body.lastChild);
		return (withNoScroll - withScroll);
	}
};
