(function($) {
	$.fn.menuStretcher = function(options) {

		var settings = { 'compress': false };

		return this.each(function() {
			if (options) {
				$.extend(settings, options);
			}

			var $lastItems = $(this).children().slice(1);
			$lastItems.css('margin-left', '0');

			var containerWidth = $(this).width();
			var currentWidth = 0;

			$(this).children().each(function() {
				currentWidth += $(this).outerWidth(true);
			});

			if (currentWidth < containerWidth || settings.compress) {
				var widthDelta = Math.floor((containerWidth - currentWidth) / $lastItems.size());

				$(this).children().each(function() {
					$(this).css('width', $(this).width() + 'px');
					$(this).css('text-align', 'center');
				});

				$lastItems.css('margin-left', widthDelta + 'px');
			}
		});

	};
})(jQuery);

