// JavaScript Document
$(function(){ 

	var keyword1 = "sele_kana";
	var keyword2 = "sele_hama";
	var keyword3 = "sele_koba";
	var keyword4 = "sele_oka";
	var keyword5 = "xxx";
	var keyword6 = "xxx";
	var keyword7 = "xxx";
	var keyword8 = "xxx";
	var keyword9 = "xxx";
	var keyword10 = "xxx";

	var count_flg = 0;
	var count_flg1 = 0;
	var count_flg2 = 0;
	var count_flg3 = 0;
	var count_flg4 = 0;
	var count_flg5 = 0;
	var count_flg6 = 0;
	var count_flg7 = 0;
	var count_flg8 = 0;
	var count_flg9 = 0;
	var count_flg10 = 0;
	
	var account = "selection_int"; 
	var twitAPI = "http://api.twitter.com/1/statuses/user_timeline/"+account+".json?callback=?&count=100"; 
	
	function jsonTwit(){ 
		$.getJSON(twitAPI, function(data){ 
			$.each(data, function(i, item){ 
				var txt = item.text 
				.replace(/(https?:\/\/[-a-z0-9._~:\/?#@!$&amp;amp;amp;\'()*+,;=%]+)/ig,"<a href='$1'>$1</a>") 
				.replace(/@+([_A-Za-z0-9-]+)/ig,"<a href='http://twitter.com/$1'>@$1</a>") 
				.replace(/#+([_A-Za-z0-9-]+)/ig,"<a href='http://search.twitter.com/search?q=$1'>#$1</a>"); 
				
				if(count_flg1 != 1){
					if(txt.indexOf(keyword1) != -1){
						$("#tweet1").append(txt); 
						count_flg1=1;
					}
				}
				if(count_flg2 != 1){
					if(txt.indexOf(keyword2) != -1){
						$("#tweet2").append(txt); 
						count_flg2=1;
					}
				}
				if(count_flg3 != 1){
					if(txt.indexOf(keyword3) != -1){
						$("#tweet3").append(txt); 
						count_flg3=1;
					}
				}
				if(count_flg4 != 1){
					if(txt.indexOf(keyword4) != -1){
						$("#tweet4").append(txt); 
						count_flg4=1;
					}
				}
				if(count_flg5 != 1){
					if(txt.indexOf(keyword5) != -1){
						$("#tweet5").append(txt); 
						count_flg5=1;
					}
				}
				if(count_flg6 != 1){
					if(txt.indexOf(keyword6) != -1){
						$("#tweet6").append(txt); 
						count_flg6=1;
					}
				}
				if(count_flg7 != 1){
					if(txt.indexOf(keyword7) != -1){
						$("#tweet7").append(txt); 
						count_flg7=1;
					}
				}
				if(count_flg8 != 1){
					if(txt.indexOf(keyword8) != -1){
						$("#tweet8").append(txt); 
						count_flg8=1;
					}
				}
				if(count_flg9 != 1){
					if(txt.indexOf(keyword9) != -1){
						$("#tweet9").append(txt); 
						count_flg9=1;
					}
				}
				if(count_flg10 != 1){
					if(txt.indexOf(keyword10) != -1){
						$("#tweet10").append(txt); 
						count_flg10=1;
					}
				}
				
				if(count_flg == 1){ return false; } 
			}); 
		},"json"); 
	}; 
	
	jsonTwit(); 
}); 

