jQuery.fn.tagCloud = function(settings) {
	settings = jQuery.extend({
		margin: 5,
		height: this.parent().height()
	}, settings);
	
	var totalWidth = 0;

	jQuery('li', this).each(function() {
		totalWidth += jQuery(this).width() + settings.margin*2;
		jQuery(this).css('margin', '0 ' + settings['margin'] + 'px');
		jQuery(this).css('position', 'relative');
	});
	
	var nbLines = Math.ceil(totalWidth / this.width());

	//this.css('margin', '0 ' + Math.abs((this.width() - (totalWidth / nbLines)*1.1)/2) + 'px');
	
	var lineHeight = settings.height / nbLines;
	
	jQuery('li', this).each(function() {
		var topPos = Math.floor(Math.random() * (lineHeight - jQuery(this).height()));
		jQuery(this).css('top', topPos + 'px');
	});
	
	return this;
}

