/**
 * Simple Tweet plugin
 * @author Jeroen van Leeuwen
 */

(function($) {
	var elm;
	var height = 110;
	var marginTop = 110;
	var total = 0;
	
    $.fn.extend({
		tweets: function(){
			elm = $(this).find('ul');
			total = elm.height();
			if(elm.html() != null)
				setInterval(function(){$(this).toggleTweet()}, 5000);
        },
		toggleTweet: function(){
			
			marginTop = marginTop - height;
			
			//alert(marginTop);
			
			elm.animate(
				{
					'top': (marginTop - height) + 'px'	
				},
				'slow',
				function(){
					if(elm.height() + (marginTop - height) == 0){
						marginTop = 110;
						elm.css('top', '0px')
					}
				}
			);
		
			//var third = 
			//alert(second.html());
			/*
			$(this).fadeOut();
			if($(this).next('div').html() == null)
			{
				$('section.tweets div:first').fadeIn('slow');
			}
			else
			{ 
				$(this).next('div').fadeIn('slow');
			}			
			
			
			alert(elm.html());
			*/
			
		}
  });
})(jQuery);
