$(function() {
	slide_text();
});

// =============================================================
// tweet
// =============================================================
function slide_text(text_num){
	var tweet = "div.tweet p";
	var text = $(tweet).text();

	show_text = text.replace(/( |　|^)*((https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+))/g, '$1<a href="$2" target="_blank">$2</a>');
	show_text = show_text.replace(/\@([0-9a-zA-Z_]{1,15})/g, '@<a class="id_link" href="http://twitter.com/$1" target="_blank">$1</a>');
	$(tweet).html(show_text);

	var text_num = text.length - 40;
	if (text_num < 0) {
		text_num = 0;
	}

	var slide_time = text_num * 180;
	var slide_width = -(text_num * 12);
	var timeout = slide_time + 3000 + 3000;
	var hidden = timeout - 1000;
	$(tweet).animate({ marginLeft:'0px' },0, "linear");
	$(tweet).animate({ marginLeft:'0px' },3000, "linear");
	$(tweet).animate({ marginLeft:slide_width },slide_time, "linear");
	setTimeout(function(){ $(tweet).animate({ marginTop:'25px' },1000, "linear"); }, hidden);
	setInterval(
		function(){
			$(tweet).animate({ marginTop:'0px' },0, "linear");
			$(tweet).animate({ marginLeft:'0px' },0, "linear");
			$(tweet).animate({ marginLeft:'0px' },3000, "linear");
			$(tweet).animate({ marginLeft:slide_width },slide_time, "linear");
			setTimeout(function(){ $(tweet).animate({ marginTop:'25px' },1000, "linear"); }, hidden);
		}, 
		timeout
	);
}
