// twitterbox
(function($) {
    $.fn.twitterBox = function(user_id) {
    	var height = $("#twitter_box").height();
    	return this.each(function() {
    		var $$		= $(this);
    		var baseY = 0, count = 0;
    		
    		function getTweets() {
    			$.get("/external/get_tweets/"+user_id,
    				function(res){
    					$$.html(res);
    				}
    			);
    		}
    		function slideTweets() {
    			count++;
    			if(count > 10) {
    				$("#twitter_box_"+user_id).animate({ marginTop : 0 }, 400);
    				baseY = count = 0;
    			} else {
    				//baseY -= 114;
    				baseY -= height;
    				$("#twitter_box_"+user_id).animate({ marginTop : baseY }, 200);
    			}
    			
    		}
    		function init() {
    			getTweets();
    			$.timer(6000, function(timer) {
    				slideTweets();
    			});
    		}
    		init();
    	});
    };
}
)(jQuery);
