// Center Class
Center = Class.create();
Center.create = function(options) {
	return (new Center(options));
}
Center.prototype = {
	initialize : function(options) {
		this._setOptions(options);
	},
	_setOptions: function(options) {
		this.options = {
			id : ''
		}
		Object.extend(this.options, options || {});
	},
	both : function() {
		this.setX();
		this.setY();
	},
	setY : function() {
		var dimensions = Element.getDimensions($(this.options.id));
		Position.prepare();
		var offsetTop = (Position.deltaY + Math.floor((this._getWindowHeight() - dimensions.height) / 2));
		
		Element.setStyle($(this.options.id), {
			position : 'absolute',
			//top      : ((dimensions.height <= this._getWindowHeight()) ? ((offsetTop  != null && offsetTop  > 0) ? offsetTop  : '0') + 'px' : 0),
			top      : ((offsetTop  != null && offsetTop  > 0) ? offsetTop  : '0') + 'px'
		});
	},
	top : function() {
		var dimensions = Element.getDimensions($(this.options.id));
		Position.prepare();
		var offsetTop = Position.deltaY;
		
		Element.setStyle($(this.options.id), {
			position : 'absolute',
			//top      : ((dimensions.height <= this._getWindowHeight()) ? ((offsetTop  != null && offsetTop  > 0) ? offsetTop  : '0') + 'px' : 0),
			top      : ((offsetTop  != null && offsetTop  > 0) ? offsetTop  : '0') + 'px'
		});
	},
	setX : function() {
		var dimensions = Element.getDimensions($(this.options.id));
		Position.prepare();
		var offsetLeft = (Position.deltaX + Math.floor((this._getWindowWidth() - dimensions.width) / 2));
		
		Element.setStyle($(this.options.id), {
			position : 'absolute',
			left     : ((dimensions.width  <= this._getWindowWidth())  ? ((offsetLeft != null && offsetLeft > 0) ? offsetLeft : '0') + 'px' : 0)
		});
	},
	left : function() {
		var dimensions = Element.getDimensions($(this.options.id));
		Position.prepare();
		var offsetLeft = Position.deltaX;
		
		Element.setStyle($(this.options.id), {
			position : 'absolute',
			left     : ((dimensions.width  <= this._getWindowWidth())  ? ((offsetLeft != null && offsetLeft > 0) ? offsetLeft : '0') + 'px' : 0)
		});
	},
	overlay : function() {
		Element.setStyle($(this.options.id), {
			position : 'absolute',
			top      : 0,
			left     : 0,
			height   : this._getDocumentHeight() + 'px',
			width    : this._getDocumentWidth() + 'px'
		});
	},
	_getWindowWidth : function() {
		return (self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0);
	},
	_getWindowHeight : function() {
		return (self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0);
	},
	_getDocumentWidth: function(){
		return Math.max(document.body.scrollWidth, this._getWindowWidth());
	},
	_getDocumentHeight: function(){
		return Math.max(document.body.scrollHeight, this._getWindowHeight());
	}
};

