$.fn.centerInClient = function(options) {
	var opt = {
		forceabsolute: false
		, container: window
		, 'margin-top': -999999
	};
	$.extend(opt, options);
 
	return this.each(function(i){
		var el = $(this);
		var w = $(opt.container);
		var isWin = opt.container == window;

		// force to document top to to force document abs positioning ability
		if (opt.forceabsolute){
			if (isWin)
				el.remove().appendTo( "body" );
			else
				el.remove().appendTo( w.get(0) );
		}

		// have to make absolute
		el.css('position', 'absolute');

		// height is off a bit so fudge it
		var heightFudge = isWin ? 2.0 : 1.8;

		realDim = (isWin)
			? {width: w.width(), height: w.height()}
			: {width: w.outerWidth(), height: w.outerHeight()};
			
		var x = realDim.width / 2 - el.outerWidth() / 2;
		var y = realDim.height / heightFudge - el.outerHeight() / 2;
		
		y += w.scrollTop();
		if (y < (opt['margin-top'] + w.scrollTop()))
			y = opt['margin-top'] + w.scrollTop();
		el.css({
			left: x + w.scrollLeft()
			, top: y
			});
	});
};
