/*
 * Center 1.0
 *
 * Requires the dimensions plug-in
 *
 * Copyright (c) 2007 Andreas Lagerkvist (exscale.se)
 */
jQuery.fn.center = function()
{
	// Always return each...
	return this.each(function()
	{
		// Set position to absolute (so element shrink-wraps) so that width/height is calculated properly
		jQuery(this).css({position: 'fixed'});

		var leftMargin = jQuery(this).outerWidth() / 2, 
			topMargin = jQuery(this).outerHeight() / 2;

		jQuery(this).css({position: 'fixed', left: '50%', top: '50%', marginLeft: '-' +leftMargin +'px', marginTop: '-' +topMargin +'px', zIndex: '1000'});

		/* Use this code if you care about IE<7
		// Calculate left and top pos values
		var leftPos = (jQuery(window).width() - jQuery(this).outerWidth()) / 2 + jQuery(window).scrollLeft(), 
			topPos = (jQuery(window).height() - jQuery(this).outerHeight()) / 2 + jQuery(window).scrollTop();

		// Make sure element is not out of bounds
		leftPos = (leftPos < 0) ? 0 : leftPos;
		topPos = (topPos < 0) ? 0 : topPos;

		jQuery(this).css({left: leftPos +'px', top: topPos +'px', zIndex: '1000'});
		*/
	});
};