jQuery.fn.tagCloud = function() {
	return this.each(function() {
		var cloudContainer = jQuery(this);
		var _data = cloudContainer.metadata();  
		// get an array of all the <li>'s  
		var categories = cloudContainer.find('ul li');  
		var cloudMarkup = '';  
		// set maxPercent/minPercent preferences  
		var maxPercent = parseInt(_data['maxpercent']), minPercent = parseInt(_data['minpercent']);  
		// note that max is initialized to a number that I know is lower than the max count  
		// and that min is set to a number larger than the known min count  
		var max = 0, min = 99999999, count = 0;  
		// loop through each li and calculate statistics  
		categories.each(function(i) {
			var _data = jQuery(this).metadata();
			count = parseInt(_data['count']); 
			max = (count > max ? count : max);  
			min = (min > count ? count : min);
		});  
		var total, link, size; 
		var multiplier = (maxPercent-minPercent)/(max-min);  
		//trace("multiplier="+multiplier);
		// loop through each li and generate the markup for the new tag cloud  
		categories.each(function(i) {
			var _data = jQuery(this).metadata();
			count = parseInt(_data['count']);  
			//link = $(this).find('a');  
			size = minPercent + ((max-(max-(count-min)))*multiplier) + '%';
			cloudMarkup += '<a class="cloudlink" style="font-size:' + size + '" href="'+_data['href']+'">' + jQuery(this).text() + '</a> ';  
 		});  
		// replace the html content of the parent container with the new tag cloud  
		cloudContainer.html(cloudMarkup);
		cloudContainer.show();
	});
};