jQuery.fn.showRandomItem = function(settings) {
	return this.each(function(){
		var c = $(this).children().length;
		var r = Math.ceil(Math.random() * c);
		$(this).filter(':nth-child(' + r + ')').show();
	});
};

$(function() {
	num_ads = 2;
	
	$display_ads = $('#ads').children('ul:first');

    $random_ads_pool = $('#random-ads-pool').children('li');
    $random_ads_pool.hide();
    
    if (num_ads > $random_ads_pool.length) { num_ads = $random_ads_pool.length };
    
    for (i=0; i < num_ads; i++) {
    	var r = Math.ceil(Math.random() * ($random_ads_pool.length - i));
    	$random_ads_pool.filter(':nth-child(' + r + ')').appendTo($display_ads).show();
    }
    
});