/*

ランダム表示

指定タグの子のタグを、指定個数だけランダムに表示する。

使い方
head内に次の2行を追加する。
<script language="JavaScript" type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery.randomdisplay.js"></script>
親のタグに属性 randomdisplay="表示数" を追加する。
例：<ul randomdisplay="3">

*/

jQuery(function($) {

$.fn.extend({
	randomdisplay : function(num) {
		return this.each(function() {
			var chn = $(this).children().hide().length;
			for(var i = 0; i < num && i < chn; i++) {
				var r = parseInt(Math.random() * (chn - i)) + i;
				$(this).children().eq(r).show().prependTo($(this));
			}
		});
	}
});

$(function(){
	$("[randomdisplay]").each(function() {
		$(this).randomdisplay($(this).attr("randomdisplay"));
	});
});

});

