/*!
 * jQuery JavaScript Plugin randomDisp v1.0
 * http://sakunyo.com/
 *
 * Copyright 2010, Sakuya Sugo
 * licensed MIT
 *
 * Date: Tue April 27 12:30:00 2010 +0900
 */
jQuery.fn.randomDisp = function(delay){
	var selector = this;
	var delay = (delay)?delay:6000;
	var current = 0;
	var currentCls = 'rendomDisp-current';
	var l = selector.length;

	function randomVal(){
		return Math.floor(Math.random() * l);
	}
	function swapimage(){
		var current = randomVal();
		selector.filter('.'+currentCls)
			.css('z-index','0').removeClass(currentCls);
		selector.eq(current).addClass(currentCls)
			.css('z-index','10').fadeIn('',function(){
				$(this).css('z-index','10');
				selector.not('.'+currentCls).each(function(){
					$(this).css('z-index','0').hide();
			})
		});

	}
	selector.each(function(){$(this).hide();});
	selector.eq(randomVal()).addClass(currentCls).show().css('z-index','10');
	setInterval(function(){swapimage()},delay);
}
$(function(){
	$('#mainImg li').randomDisp(6000);
})
