(function(a){a.fn.fade=function(b){this.each(function(){var d={animationtype:"fade",speed:"normal",timeout:2000,type:"sequence",containerheight:"auto",runningclass:"fade"};if(b){a.extend(d,b)}if(!b.indexArea){d.indexArea=a(this).next().children()}d.current=1;var f=function(){var g=a(this).text().replace(/[\[,\]]/g,"")-1;if(d.current-1==g){return}clearTimeout(d.timeoutId);d.timeoutId=setTimeout(function(){a.fade.next(e,d,g,d.last?d.last:0)},0)};d.indexArea.click(f);var e=a(this).children();if(e.length>1){a(this).css("position","relative");a(this).css("height",d.containerheight);a(this).addClass(d.runningclass);for(var c=0;c<e.length;c++){a(e[c]).css("position","absolute");a(e[c]).hide()}if(d.type=="sequence"){a(e[0]).fadeIn(0);d.timeoutId=setTimeout(function(){a.fade.next(e,d,1,0)},d.timeout);d.indexArea.removeClass("on").eq(0).addClass("on")}else{if(d.type=="random"){setTimeout(function(){do{current=Math.floor(Math.random()*(e.length))}while(current==0);a.fade.next(e,d,current,0)},d.timeout);a(e[0]).show()}else{alert("type must either be 'sequence' or 'random'")}}}})};a.fade=function(){};a.fade.next=function(d,b,e,c){if(b.animationtype=="slide"){a(d[c]).slideUp(b.speed,a(d[e]).slideDown(b.speed))}else{if(b.animationtype=="fade"){a(d[c]).fadeOut(b.speed);a(d[e]).fadeIn(b.speed);b.indexArea.removeClass("on").eq(e).addClass("on")}else{alert("animationtype must either be 'slide' or 'fade'")}}if(b.type=="sequence"){if((e+1)<d.length){e=e+1;c=e-1}else{e=0;c=d.length-1}}else{if(b.type=="random"){c=e;while(e==c){e=Math.floor(Math.random()*(d.length))}}else{alert("type must either be 'sequence' or 'random'")}}b.last=c;b.current=e;var f=setTimeout((function(){a.fade.next(d,b,e,c)}),b.timeout);clearTimeout(b.timeoutId);b.timeoutId=f}})(jQuery);
