function CenterElement(element, relativeObj)
{
	this.element = element;
	this.relativeObj = relativeObj;
	
	var _object = this;
	
	this.init = function()
	{
		setInterval(function(){
			_object.centerElement();	
		}, 100);
	}
	
	this.centerElement = function()
	{
		var global_x;
		var global_y;
		var globalWidth;
		var globalHeight;
		
		if(_object.relativeObj == "window")
		{
			globalWidth = $(window).width()/2;
			globalHeight = $(window).height()/2;
			global_x = 0;
			global_y = 0;
		}
		else if(_object.relativeObj == "document")
		{
			globalWidth = $(document).width()/2;
			globalHeight = $(document).height()/2;
			global_x = 0;
			global_y = 0;
		}
		else
		{
			globalWidth = $(_object.relativeObj).width()/2;
			globalHeight = $(_object.relativeObj).height()/2;
			globalPos = $(_object.relativeObj).offset();
			global_x = globalPos.left;
			global_y = globalPos.top;
		}

		objWidth = $(_object.element).outerWidth()/2;
		objHeight = $(_object.element).outerHeight()/2;

		x_pos = global_x + (globalWidth) - (objWidth);
		y_pos = global_y + (globalHeight) - (objHeight) + $(document).scrollTop();
		
		$(_object.element).css({ position : 'absolute', 'top' : 0, 'left' : 0});
		$(_object.element).css({ 'top' : y_pos, 'left' : x_pos});
	}
}
