(function() {
	$.fn.newsTicker = function (options) {
		var defaults = {
			items: 'li',
			show: 1,
			height: 170,
			duration: 5000,
			selector: 'news_item'
		}
		var options = $.extend(defaults, options);
		return this.each(function() {
			var $this 		= $(this);
			var items		= $this.find(options.items).css('height', (options.height/2));
			//hide overflow + height
			$this.css({'overflow':'hidden', 'height' : options.height });
			var ticker  = function(count) {
				if(count == undefined || count == 0) {
					//first items append active class
					for(var i = 0; i <= (options.show-1); i++) {
						$(items[i]).addClass('active');
					}
					var count = 0;
				}									
				var timer = setTimeout(function() {									
					for(var x = 0; x < items.length; x++) {				
						//give unique id
						$(items[x]).attr('id', options.selector+"_"+x);					
						if($(items[x]).hasClass('active')) {				
							count++;			
							$(items[x]).slideUp( function() {												
								$(this).removeClass('active');
								var clone = $(this).css('display', 'block').clone();						
								$(this).remove();
								$this.append(clone);																								
								$(items[count]).addClass('active');						
							});				
						}//endif active														
					}//endfor					
					ticker(count);										
				}, options.duration);//end timeout				
				$this.children().hover(function() {
					clearTimeout(timer);
				},function() {
					setTimeout(ticker(),options.duration);
				}); 				
			}//end ticker	
			ticker();			
		});
	}
})(jQuery);
