$.fn.extend({
	allenSlide: function() {
		var news = $(this).find('ul:first li');
		var self = this;
		var n = news.length;
		var h = news.height();
		var t = 3000;
		var speed = 'normal';
		var curPage = 0;
		if(n > 1) {
			$(this).children('ul:first').append($(this).find('ul:first li:first').clone());
			autoSlide();
		}

		function slideTo(page) {
			curPage = page;
			var ml = -1 * h * (page - 1);
			$(self).children('ul:first').stop();
			if(page > n) {
				curPage = 1;
			} else if(page == 2) {
				$(self).children('ul:first').css('marginTop', '0px');
			}
			$(self).children('ul:first').animate({ marginTop: ml }, speed);
		}
		
		function autoSlide() {
			var tp = curPage;
			slideTo(tp + 1);
			eval('setTimeout(function() { autoSlide(); }, ' + t + ');');
		}

	}
});

$('#news-b').allenSlide();
