

jQuery(function() {
	jQuery('#product-list.mixed-cases > ul').each(function() {
			makeGridList(this, 2);
	});

});

function makeGridList(element, numCols) {
	var gridRowHolder = jQuery("<div class='gridRowHolder'></div>").insertAfter(element);			// a container for the new ULs
	jQuery(element).children("li").each(function(i) {
			  jQuery(this).css("min-height", "0");			// get rid of min-height
			  if (i % numCols == 0) {
							jQuery("<ul class='clearfix products gridRow'></ul>").appendTo(gridRowHolder);
			  }
			jQuery(this).clone().appendTo($(this).parent().eq(0).siblings("div.gridRowHolder").children("ul:last")[0]);
	});
	jQuery(element).eq(0).remove();	  // remove the original UL
	
	jQuery("ul.gridRow li:last-child").css("margin-right","0");		// gets rid of any right margin on the last item of each row
}