// Created by Andreas Lagerkvist http://exscale.se
// A center-function (uses dimensions plugin)
$.fn.center = function()
{
	return this.each(function()
	{
		$(this).css({position: 'absolute'});

		var leftPos = ($(window).width() - $(this).outerWidth()) / 2 + $(window).scrollLeft();
		var topPos = ($(window).height() - $(this).outerHeight()) / 2 + $(window).scrollTop();

		if(topPos < 0) topPos = 0;
		if(leftPos < 0) leftPos = 0;

		$(this).css({left: '' +leftPos +'px', top: '' +topPos +'px', zIndex: '1000'});
	});
}