/*
 * Center 1.0
 *
 * Requires the dimensions plug-in
 *
 * Copyright (c) 2007 Andreas Lagerkvist (exscale.se)
 */
var processed = Array();
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'});
		
		if (jQuery.browser.msie)
			var ieVersion = parseFloat(navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/)[1]);
			
		if (jQuery.browser.msie && ieVersion < 7) {
			//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({position:'absolute', left: leftPos +'px', top: topPos +'px', zIndex: '1000'});
		}
		else {
			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'});
		}
	});
};