/*
 *  jquery.cyclelist
 *  Version: 0.1
 *
 *  CSS example code
 *  ul#events-ticler { width:88px;border:solid;position:relative;overflow:hidden;height:30px; }
 *  ul#events-ticker li { visibility:hidden; opacity:0;position:absolute; }
 */
 
(function($){ $.fn.cyclelist = function(options){

    var defaults = {
		ms: 2000
	};
  
	var options = $.extend(defaults, options);
	
	return this.each(function(index) {
		
		var $this = $(this);
		var j = 0;
		var jmax = $this.children().length -1;

		function cycleThru (){
			$this.children().filter(":eq(" + j + ")").each(function(index,item){
				$(item).css("top", "40px");
				$(item).css("visibility", "visible");
				$(item).css("display", "block");
				$(item).animate({top : "25px", opacity : "1"}, 800);
				$(item).animate({opacity : "1"}, options.ms);
				$(item).animate({top : "10px", opacity : "0"}, 800, function(){
					(j == jmax) ? j=0 : j++;
					cycleThru();
					$(item).css("display", "none");
				});

			});
		};
		if(jmax>=1) {
			cycleThru();
		} else {
			$this.children().filter(":eq(0)").css("visibility", "visible");
			$this.children().filter(":eq(0)").css("top", "40px");
			$this.children().filter(":eq(0)").animate({top : "25px", opacity : "1"}, 800);
		}

	});
  
}})(jQuery);
