/*
 *  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,
		initdelay:0,
		abovepos:"10px",
		pausepos:"25px",
		belowpos:"40px"
	};
  
	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", options.belowpos);
				$(item).css("visibility", "visible");
				$(item).css("display", "block");
				$(item).animate({top : options.pausepos, opacity : "1"}, 800);
				$(item).animate({opacity : "1"}, options.ms);
				$(item).animate({top : options.abovepos, 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", options.belowpos);
			$this.children().filter(":eq(0)").animate({top : options.pausepos, opacity : "1"}, 800);
		}

	});
  
}})(jQuery);

