jQuery.fn.latestNews = function() {
	this.each(function() {
		var _self = this;
		var interval;
		
		_self.init = function() {
			jQuery('.news-latest-item', _self).each(function() {
				var current_item = jQuery(this);
				var target_url = jQuery('a', this).attr("href");
				var whitebox = jQuery('<div class="whitebox"></div>').appendTo(current_item);
				
				current_item.css({top: "-200px"});
				current_item.bind('mousemove', function() {
					clearInterval(interval);
				}).bind('mouseout', function() {
					clearInterval(interval);
					interval = setInterval(function(){
						_self.showNext();
					}, 1000);
				}).bind('click', function() {
					window.location.href = target_url;
				});
			});
		
			_self.showNext();
		}
		
		_self.showNext = function() {
			clearInterval(interval);
			
			var current = (jQuery('.active', _self) ? jQuery('.active', _self) : jQuery('.news-latest-item:first', _self));
			var current_whitebox = jQuery('.whitebox', current);
			var next = (current.next('.news-latest-item').length ? current.next('.news-latest-item') : jQuery('.news-latest-item:first', _self));
			var next_whitebox = jQuery('.whitebox', next);
			
			current.removeClass('active').animate({top: "200px"}, 1000, "swing"); //, opacity: 0.0
			current_whitebox.animate({opacity: 1.0}, 900, "swing");
			next.addClass('active').css({top: "-200px"}).animate({top: "0px"}, 1000, "swing"); //, opacity: 1.0
			next_whitebox.animate({opacity: 0.0}, 900, "swing");
			
			interval = setInterval(function(){
				_self.showNext();
			}, 7000);
		}
		
		_self.init();
	});
}
